코드포스
-
Codeforces Round 849 (Div. 4)코드포스 2023. 11. 11. 12:37
Dashboard - Codeforces Round 849 (Div. 4) - Codeforces codeforces.com D 배열 a[0...N-1] 을 왼쪽과 오른쪽 두 개의 subsequence로 나누었을 때, 나눌 수 있는 모든 경우에 대해, 왼쪽/오른쪽 subsequence에 포함된 알파벳의 개수를 세는 방법은 다음과 같다. 배열 a[0...N-1]에 포함된 알파벳의 개수를 모두 센다. -> 오른쪽 subsequence에 포함된 알파벳. 이제 왼쪽 subsequence의 영역을 하나씩 넓혀간다. E 편의상 0을 positive integer, -0을 negative integer 이라고 하자. 그러면, 모든 정수(0, -0 포함) negative 이거나 positive 이다. 이때 임의의 두 ..
-
Codeforces Round 835 (Div. 4)코드포스 2023. 11. 11. 12:27
Dashboard - Codeforces Round 835 (Div. 4) - Codeforces codeforces.com D 함수값이 일정한 부분은 valley 판정에 중요한 부분이 아니다. 중요한 건 양 끝 점이 다음 조건을 만족하는지 여부이다. 따라서 배열 a를 입력받을 때 함수값의 변화가 있는 부분만 받아서 문제를 해결하면 편하다. E 경우의 수를 다루는 문제는 답이 (중간 과정이 모두 int라도) long long일 수 있다. G a에서 출발하여 인접한 노드로 움직일 때 각 노드에서의 x의 값은 유일하게 결정된다(∵ xor의 항등원이 0). 따라서 각 노드에서의 x 값은 a와 그 노드의 단순 경로의 weight 들로 계산할 수 있다. 먼저 a에서 b로 teleport를 사용하지 않고 이동하는 ..
-
1651-C코드포스 2022. 3. 15. 15:05
Problem - C - Codeforces codeforces.com 모든 경우를 세세히 따지지 않아서 틀렸다 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 #include #define endl "\n" // don't use when you cover interactive problem #define ooop(i, n) for(int i = 0; i t; while(t--){ int n; cin >> n; vector v(2, vector(n)); ooop(i, n) cin >> v[0][i]; ..
-
1307-D, *1900코드포스 2022. 1. 7. 01:05
Problem - D - Codeforces codeforces.com 풀이 Xa+Yb 가 가장 클 때를 찾아야하는 이유는 Xa+Yb+1 이 노드 1부터 n 까지 (노트 a, b를 경유하는) 최단거리이기 때문 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 #include #define endl "\n" #define ooop(i, n) for(int i = 0; i n ..
-
1307-C, *1500코드포스 2022. 1. 7. 01:02
Problem - C - Codeforces codeforces.com 풀이 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 #include #define endl "\n" #define ooop(i, n) for(int i = 0; i s; map d; ooop(i, s.size()) d[s[i]-'a'].emplace_back(i); ll res = 0; for(const auto& [_, v]: d){ if(res
-
1622-C코드포스 2021. 12. 29. 22:46
Problem - C - Codeforces codeforces.com 풀이 tutorial 봤음 Educational Codeforces Round 120 Editorial - Codeforces codeforces.com 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 #include #define endl "\n" #define ooop(i, n) for(int i = 0; i t; while(t--){ ll n, k; cin >> n >> k; vector a(n); for(auto& e: a) cin >> e; sort(all(a)); vector p(n+1..
-
1623-C코드포스 2021. 12. 29. 20:43
Problem - C - Codeforces codeforces.com 풀이 ※ 결과가 최소가 되게하는 최대 ~, 결과가 최대가 되게하는 최소 ~ 가 나오면 parametric search 고려해보자 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 #include #define endl "\n" #define ooop(i, n) for(int i = 0; i t; while(t--){ int n; cin >> n; vector p(n); for(auto& e: p) cin..
-
1623-B코드포스 2021. 12. 29. 20:40
Problem - B - Codeforces codeforces.com 풀이 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 #include #define endl "\n" #define ooop(i, n) for(int i = 0; i t; while(t--){ int n; cin >> n; vector cnt(n); stack st; ooop(i, n){ int s, e; cin >> s >> e; st.push({s, e}); for(int j = s; j