Round 1
나는 총합 516.5 점으로 1라운드를 마감하였다.
인류의 적 모기 퇴치
#include <vector>
#include <algorithm>
#include <queue>
#include <iostream>
#include <map>
#include <set>
#include <math.h>
#include <numeric>
#include <cassert>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
int lastTimes[105];
int main()
{
cin.tie(0);
cout.tie(0);
int n, m;
cin >> n >> m;
if (m % 2 == 1)
{
cout << "NO";
return 0;
}
for (int i = 0; i <= n; i++)
{
lastTimes[i] = -100;
}
for (int i = 0; i < m; i++)
{
int time, index, status;
cin >> time >> index >> status;
if (status == 0)
{
// 시작했는데 시작한 경우
if (lastTimes[index] != -100)
{
cout << "NO";
return 0;
}
else
{
// 정상
lastTimes[index] = time;
}
}
else if (status == 1)
{
// 시작도 안했는데 끝난경우
if (lastTimes[index] == -100)
{
cout << "NO";
return 0;
}
// 1분이 안됬는데 끝난경우
if (time - lastTimes[index] < 60)
{
cout << "NO";
return 0;
}
else
{
// 정상
lastTimes[index] = -100;
}
}
}
for (int i = 0; i <= n; i++)
{
if (lastTimes[i] != -100)
{
cout << "NO";
return 0;
}
}
cout << "YES";
return 0;
}
카트라이더 보드게임
이건 코딩으로는 못풀었고 시뮬레이터를 사용해 풀었다.
[1번 OUTPUT] [2번 OUTPUT] [3번 OUTPUT] [4번 OUTPUT] [5번 OUTPUT] [6번 OUTPUT]
뒤집기
29점을 받은 코드이다.
#include <vector>
#include <algorithm>
#include <queue>
#include <iostream>
#include <map>
#include <set>
#include <math.h>
#include <numeric>
#include <cassert>
#include <climits>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
vector<int> arr;
int n;
int reverseSt = 0;
int reverseEd = 0;
int lastReverstSt = 0;
ll dynamic_programming()
{
ll max_so_far = arr[1];
if (reverseSt == 1)
max_so_far = arr[reverseEd];
ll curr_max = max_so_far;
if (reverseSt == lastReverstSt && reverseSt >= 2)
{
lastReverstSt = reverseSt;
for (int j = reverseSt; j <= n; j++)
{
int i = j;
if (reverseSt <= j && j <= reverseEd)
{
// (8 - 1) - (5-1)
i = reverseEd - (j - reverseSt);
}
curr_max = max((ll)arr[i], curr_max + (ll)arr[i]);
max_so_far = max(max_so_far, curr_max);
}
}
else
{
for (int j = 2; j <= n; j++)
{
int i = j;
if (reverseSt <= j && j <= reverseEd)
{
// (8 - 1) - (5-1)
i = reverseEd - (j - reverseSt);
}
curr_max = max((ll)arr[i], curr_max + (ll)arr[i]);
max_so_far = max(max_so_far, curr_max);
}
}
return max_so_far;
}
ll getMaxSum()
{
return dynamic_programming();
}
int main()
{
cin.tie(0);
cout.tie(0);
ios_base::sync_with_stdio(false);
cin >> n;
arr.resize(n + 1);
ll ans = LLONG_MIN;
for (int i = 1; i <= n; i++)
{
cin >> arr[i];
ans = max(ans, (ll)arr[i]);
}
for (int i = 1; i <= n; i++)
{
reverseSt = i;
for (int j = i; j <= n; j++)
{
if (i != j)
{
reverseEd = j;
// reverse(arr.begin() + i, arr.begin() + j);
ans = max(ans, getMaxSum());
// reverse(arr.begin() + i, arr.begin() + j);
}
}
}
cout << ans;
}
카트 제작
어디서 Hash를 배웠다고 인터넷에서 복붙을 해서 Hash 함수를 사용해 푼 나는 뭘까..?
#include <vector>
#include <algorithm>
#include <queue>
#include <iostream>
#include <map>
#include <set>
#include <math.h>
#include <numeric>
#include <cassert>
#include <unordered_map>
using namespace std;
typedef long long ll;
typedef unsigned long ull;
typedef pair<int, int> pii;
typedef uint32_t Hash;
/*
This hash function is from http://www.azillionmonkeys.com/qed/hash.html
*/
#include <stdint.h> /* Replace with <stdint.h> if appropriate */
#include <string>
using namespace std;
#undef get16bits
#if (defined(__GNUC__) && defined(__i386__)) || defined(__WATCOMC__) || defined(_MSC_VER) || defined(__BORLANDC__) || defined(__TURBOC__)
#define get16bits(d) (*((const uint16_t *)(d)))
#endif
#if !defined(get16bits)
#define get16bits(d) ((((uint32_t)(((const uint8_t *)(d))[1])) << 8) + (uint32_t)(((const uint8_t *)(d))[0]))
#endif
uint32_t SuperFastHash(const char *data, int len)
{
uint32_t hash = len, tmp;
int rem;
if (len <= 0 || data == NULL)
return 0;
rem = len & 3;
len >>= 2;
/* Main loop */
for (; len > 0; len--)
{
hash += get16bits(data);
tmp = (get16bits(data + 2) << 11) ^ hash;
hash = (hash << 16) ^ tmp;
data += 2 * sizeof(uint16_t);
hash += hash >> 11;
}
/* Handle end cases */
switch (rem)
{
case 3:
hash += get16bits(data);
hash ^= hash << 16;
hash ^= ((signed char)data[sizeof(uint16_t)]) << 18;
hash += hash >> 11;
break;
case 2:
hash += get16bits(data);
hash ^= hash << 11;
hash += hash >> 17;
break;
case 1:
hash += (signed char)*data;
hash ^= hash << 10;
hash += hash >> 1;
}
/* Force "avalanching" of final 127 bits */
hash ^= hash << 3;
hash += hash >> 5;
hash ^= hash << 4;
hash += hash >> 17;
hash ^= hash << 25;
hash += hash >> 6;
return hash;
}
/*
Make easy for string hashing
*/
uint32_t SuperFastHash(string str)
{
return SuperFastHash(str.c_str(), str.size());
}
/************* Hash Function Done *************/
enum PartID
{
Body = 0,
Wheel = 1,
Handle = 2,
Engine = 3,
Booster = 4,
};
int printOrder[] = {0, 2, 1, 3, 4};
struct Part
{
Hash bounusHash;
ull score;
};
PartID GetPartID(string str)
{
if (str[0] == 'H')
return PartID::Handle;
else if (str[0] == 'W')
return PartID::Wheel;
else if (str[0] == 'E')
return PartID::Engine;
else if (str[2] == 'd')
return PartID::Body;
else if (str[2] == 'o')
return PartID::Booster;
return PartID::Body;
}
// use for output
unordered_map<Hash, string> partName;
// use for dfs
vector<Part> parts[6];
int engineIdx = -1;
int boosterIdx = -1;
ull ebScore = 0;
bool fd = 0;
ull ans = 0;
ull gonnanFind = 0;
ull Abs(ull a, ull b)
{
return a > b ? a - b : b - a;
}
int main()
{
cin.tie(0);
cout.tie(0);
int n;
cin >> n;
for (int i = 0; i < n; i++)
{
string partType_str, bonusName;
ull score;
cin >> partType_str >> bonusName >> score;
Hash hashed_bounusName = SuperFastHash(bonusName);
PartID partType = GetPartID(partType_str);
parts[partType].push_back({hashed_bounusName, score});
partName.insert(make_pair(hashed_bounusName, bonusName));
}
}
달팽이
#include <vector>
#include <algorithm>
#include <queue>
#include <iostream>
#include <map>
#include <set>
#include <math.h>
#include <numeric>
#include <cassert>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
pair<int, int> snail(int s, ull fv)
{
int size = s, direction = 1;
int x = -1, y = 0;
ull n = 0;
for (; size > 0;)
{
// printf("x : %d, y : %d, direction : %d\n", x, y, direction);
if (n <= fv && n + size * 2 - 1 >= fv)
{
if (fv - n <= size)
{
x += (fv - n) * direction;
return {x + 1, y + 1};
}
else
{
x += size * direction;
n += size;
y += (fv - n) * direction;
return {x + 1, y + 1};
}
return {0, 0};
}
x += direction * size;
y += direction * (size - 1);
n += size * 2 - 1;
size -= 1;
direction = -direction;
}
return {0, 0};
}
int main()
{
cin.tie(0);
cout.tie(0);
int t;
cin >> t;
while (t--)
{
ull n, a, b;
cin >> n >> a >> b;
// cout << "sa---\n";
pii sa = snail(n, a);
// cout << "sb---\n";
pii sb = snail(n, b);
// printf("(%d, %d) ~ (%d , %d) / ", sa.first, sa.second, sb.first, sb.second);
int xd = abs(sa.first - sb.first);
int yd = abs(sa.second - sb.second);
if (xd != yd)
cout << "NO\n";
else
cout << "YES\n";
}
}
바텐더
이 문제 어덯게 풀지..?
MBTI 궁합을 이용한 조 구성
이 문제 어덯게 풀지..?
드리프트 주행
이 문제도 시뮬레이터를 사용해 풀었다.
- [1번 OUTPUT]
- [2번 OUTPUT]
- [3번 OUTPUT]
- [4번 OUTPUT]
- [5번 OUTPUT]
- [6번 OUTPUT]
- [7번 OUTPUT]
- [8번 OUTPUT]
- [9번 OUTPUT]
- [10번 OUTPUT]
250점만 넘으면 됬던 1라운드, python조금 배워 풀던 친구2 도 통과는 할 수 있던 난이도 였다.
Round 2-A
내가 지식이 부족하여 사진작가 100점을 받고 대회가 끝났다..
문제 1 / 사진 작가
블로그 글을 쓸걸 예상을 안하고 문제만 풀었어서 문제가 없다. 자료실에 나오면 올리겠다.
#include <vector>
#include <algorithm>
#include <queue>
#include <iostream>
#include <map>
#include <set>
#include <math.h>
#include <numeric>
#include <cassert>
using namespace std;
typedef long long ll;
typedef unsigned long ull;
typedef pair<int, int> pii;
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
int buildings[200002];
bool used[1000002];
int n;
int main()
{
cin.tie(0);
cout.tie(0);
cin >> n;
int maxShown = 0;
int nowShowing = 0;
for (int i = 0; i < n; i++)
{
cin >> buildings[i];
}
int left = 0;
int right = 0;
while (right < n && left < n)
{
if (used[buildings[right]] == false)
{
used[buildings[right]] = 1;
right++;
nowShowing++;
// cout << "NEW";
}
else
{
used[buildings[left]] = 0;
left++;
nowShowing--;
// cout << "REMOVE";
}
// cout << " " << left << " ~ " << right << "\n";
maxShown = max(maxShown, nowShowing);
}
cout << maxShown;
}
본선 진출자 발표 날
내 이름이 본선 진출자 명단에 올라간 것을 보고 너무 기뻐 소리를 빽뺵 질러서 목이 쉬었다. 이걸로 친구한테 똑떨똑떨 하면서 놀렸다 ㅋㅋ
본선
내 인생 처음이자 마지막이 될지 모르는 넥슨 본사에 가보는 경험을 했다. 부모님이 점수가 처음 점수가 공개 되었을 때에는 4등이였다고 한다. 하지만 시간이 지나면서 6등.. 결국 8등으로 마감하였다고 한다. 쪼금만 더 점수를 긁었다면 6등까지 됬을지도 모르는데.. 너무 아쉽니다. 내년에는 더 괜찮은 점수가 있기를 기대한다. 이래서 아.. 상을 못받겠구나 라고 하고있던 와중 특별상으로 상을 받게 되었다!
코딩 학원을 다닌뒤 첫 상이다! 특별상만 으로도 기쁘다 ㅎㅎ
마감
본선에 참가만 해도 많은 보상을 준다.
- 메이플 스토리 무드등
- GK888 키보드
- NYPC 키캡
- NYPC가 각인된 텀블러
- 볼펜
- 메이플 USB
- 빵?
역시 기업에서 하는거라서 보상이 크다!! 메이플 무드등은 무선충전도 되서 침대위에 놓고 잘 쓰고 있고 받은 키보드도 주 키보드로 사용중이다. 두번째 참가에서 특별상을 받은 것 많으로도 뿌듯하고 행복하다. 내가 코딩에 쏟은 시간을 보상으로 되돌려 받는 느낌이다. 내년에는 더욱 많이 공부하여 대상을 탈 수 있기를..