본문 바로가기

전체 글

[코드포스 Practice8] B. 2048 Game You are playing a variation of game 2048. Initially you have a multiset s of n integers. Every integer in this multiset is a power of two. 당신은 2048 변형 게임을 하고 있다. 처음에 당신은 n개의 정수가 있는 다중집합 s를 가지고 있다. 이 집합에 있는 모든 정수는 2의 제곱이다. You may perform any number (possibly, zero) operations with this multiset. 당신은 이 집합으로 몇번의 연산을 수행할 수 있다 (0번도 가능) During each operation you choose two equal integers from s, remo.. 더보기
[코드포스 Practice8] A. Alex and a Rhombus While playing with geometric figures Alex has accidentally invented a concept of a n-th order rhombus in a cell grid. 기하학적인 도형으로 놀다가 Alex는 우연히 좌표계에서 n번째 순서의 마름모 개념을 발명합니다 A 1-st order rhombus is just a square 1×1 (i.e just a cell). 첫번째 순서의 마름모는 단지 하나의 네모입니다 (즉, 한 칸임) A n-th order rhombus for all n≥2 one obtains from a n−1th order rhombus adding all cells which have a common side with it to it (l.. 더보기
[코드포스 Practice8] 후기 크리스마스라고 겨울 분위기 낸 코포 (이런거 좋아함) 닉네임 색깔이 이상하다 했더니 연말이라고 닉네임 색 바꿀 수 있었다! 게다가 문제 풀면 Accepted 안 뜨고 해피 뉴 이어 뜬다ㅋㅋㅋ 귀엽네 A - 11분 B - 30분 C - x분 D - 24분 E - x분 A번은 문제 이해를 잘못해서 다시 해석한다고 좀 걸렸고 B번은 어케풀지 하다가 투포인터!가 떠올라서 바로 투포인터로 풀었다. 아 미리 투포인터 연습 좀 할껄ㅋㅋㅋㅋㅋ 풀다가 낯설어서 당황했음. 당황한 30분.. C는 풀려고 했는데 도저히 몰라서 한시간 남을때까지만 고민하자 하다가 결국 못 풀어서 D번으로 넘어갔다. D번은 간단해서 규칙찾고 바로 E번으로 넘어갔다. E번 시작할때 한 35분 남았었나? 그래서 15분정도 고민하다가 모르겠어서 C번.. 더보기
코드포스 풀기 전 준비사항 열어야 할 텝 시간복잡도와 공간복잡도 https://burningjeong.tistory.com/48 온라인 C++ IDE https://www.jdoodle.com/online-compiler-c++14/ 파파고 https://papago.naver.com/ 영어사전 https://en.dict.naver.com/#/main 복붙해놓을거 #include #include #include #include #include #include #include #include #include #include #define xx first #define yy second #define all(x) (x).begin(), (x).end() #pragma warning(disable:4996) using namespac.. 더보기
[코드포스 Practice7] B. Fake NP 어.. 이거 딱봐도 2인데??? 해서 바로 2출력했다가 틀렸다. 홀수일 경우를 빼먹어서 홀수인 경우에는 자기자신을 출력하게 했다. #include using namespace std; int main() { int l, r; cin >> l >> r; if(l == r) cout 더보기
[코드포스 Practice7] A. A pile of stones #include #include #include #include #include #include using namespace std; using i64 = long long; int main() { int n; scanf("%d", &n); //printf("%d", n); string s; cin >> s; int count = 0; for(int i = 0; i < s.size(); i++){ if(s[i] == '-') count--; else count++; count = max(count, 0); } printf("%d", count); return 0; } 쉬워서 이제 쓴다. -이면 --하고 +이면 ++ 하는데 음수가 되면 안되니깐 음수이면 0으로 바꿔준다. 더보기
[코드포스 Practice7] E. Bear and Forgotten Tree 3 겁 먹고 패스한 문제 겁쟁이 풀어보니 그리 어려운 문제가 아니었다. 이해하는데 조금 시간이 걸리고 조건이 좀 있었을 뿐 일단 -1 조건부터 정의해줬다. 높이의 2배보다 d가 클 수 없으니 이 때는 -1을 출력하고 종료한다. 또 쉬운게 이게 이진트리처럼 자식의 개수가 정해져 있는게 아니다. 그래서 부모 노드에 따닥따닥 붙어있어도 된다. 그래서 기본적으로 1번 노드에 자식노드를 붙이고 h와 d조건만 따로 만족시켜준다. 하지만 두 부분에서 빠트린 조건이 있었음.. 만약 이걸 대회중에 풀었다면 조건 못 찾아서 틀렸을 것 같다. 하나는 d와 h가 같을 때 내가 푼 대로 풀면 기본적으로 1번 노드에 자식 노드가 붙어있어서 d가 4가 되고만다. 그래서 그 때는 2번 노드에 자식노드를 붙이면 d와 h가 같아질 수 있다.. 더보기
[코드포스 Practice7] D. Array Splitting You are given a sorted array a1,a2,…,ana1,a2,…,an (for each index i>1i>1 condition ai≥ai−1ai≥ai−1 holds) and an integer kk. You are asked to divide this array into kk non-empty consecutive subarrays. Every element in the array should be included in exactly one subarray. Let max(i)max(i) be equal to the maximum in the ii-th subarray, and min(i)min(i) be equal to the minimum in the ii-th subarray... 더보기