# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
83411 | 2018-11-07T13:46:08 Z | Tusk | Teleporters (IOI08_teleporters) | C++14 | 636 ms | 36992 KB |
#include <bits/stdc++.h> using namespace std; const int N = 2e6+1; int n, m; bitset<N> chk; int sz[N], mp[N], pos[N], comp; vector<int> dp(N); int main() { scanf("%d %d", &n, &m); for(int i = 1, a, b; i <= n; i++) { scanf("%d %d", &a, &b); mp[a] = b, mp[b] = a; ++dp[a], ++dp[b]; } int ptr = 0; for(int i = 1; i < N; i++) { dp[i] += dp[i-1]; if(dp[i] != dp[i-1]) pos[ptr++] = i; } for(int i = 0; i < 2*n; i++) if(!chk[i]) { ++comp; chk[i] = true; int u = i; while(1) { ++sz[comp]; int v = dp[mp[pos[u]]]; if(chk[v] || v == 2*n) break; chk[v] = true; u = v; } } int ans = sz[1]; for(int i = 2; i <= comp; i++) dp[i-2] = sz[i]; sort(dp.begin(), dp.begin() + comp - 1, greater<int>()); for(int i = 0; i < comp-1 && m; i++, m--) ans += dp[i] + 2; if(m) ans += 2*(m - (m & 1)) + (m & 1); printf("%d\n", ans); return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 14 ms | 8180 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 14 ms | 8272 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 14 ms | 8272 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 14 ms | 8288 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 14 ms | 8380 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 14 ms | 8412 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 16 ms | 8464 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 14 ms | 8464 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 16 ms | 8508 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 14 ms | 8508 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 14 ms | 8508 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 15 ms | 8600 KB | Output is correct |
2 | Correct | 18 ms | 8888 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 15 ms | 8888 KB | Output is correct |
2 | Correct | 20 ms | 9304 KB | Output is correct |
3 | Correct | 23 ms | 9672 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 18 ms | 9672 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 26 ms | 9812 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 82 ms | 12812 KB | Output is correct |
2 | Correct | 222 ms | 18952 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 157 ms | 18952 KB | Output is correct |
2 | Correct | 352 ms | 22484 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 361 ms | 25124 KB | Output is correct |
2 | Correct | 484 ms | 26468 KB | Output is correct |
3 | Correct | 398 ms | 27396 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 615 ms | 27560 KB | Output is correct |
2 | Correct | 635 ms | 28800 KB | Output is correct |
3 | Correct | 481 ms | 28800 KB | Output is correct |
4 | Correct | 493 ms | 28800 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 636 ms | 29576 KB | Output is correct |
2 | Correct | 606 ms | 35828 KB | Output is correct |
3 | Correct | 301 ms | 36936 KB | Output is correct |
4 | Correct | 499 ms | 36992 KB | Output is correct |