# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
80157 | 2018-10-19T08:22:13 Z | Sherazin | Teleporters (IOI08_teleporters) | C++14 | 658 ms | 43280 KB |
#include <bits/stdc++.h> #define pii pair<int, int> #define x first #define y second 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 | 8184 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 14 ms | 8192 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 14 ms | 8400 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 14 ms | 8412 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 13 ms | 8412 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 13 ms | 8412 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 14 ms | 8412 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 14 ms | 8412 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 17 ms | 8416 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 15 ms | 8420 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 14 ms | 8424 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 16 ms | 8612 KB | Output is correct |
2 | Correct | 19 ms | 8888 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 15 ms | 8888 KB | Output is correct |
2 | Correct | 19 ms | 9204 KB | Output is correct |
3 | Correct | 23 ms | 9204 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 20 ms | 9204 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 19 ms | 9204 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 69 ms | 11820 KB | Output is correct |
2 | Correct | 319 ms | 17900 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 153 ms | 17900 KB | Output is correct |
2 | Correct | 324 ms | 20524 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 417 ms | 23136 KB | Output is correct |
2 | Correct | 410 ms | 24492 KB | Output is correct |
3 | Correct | 380 ms | 24844 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 602 ms | 25080 KB | Output is correct |
2 | Correct | 647 ms | 26172 KB | Output is correct |
3 | Correct | 455 ms | 26172 KB | Output is correct |
4 | Correct | 478 ms | 26172 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 579 ms | 27000 KB | Output is correct |
2 | Correct | 658 ms | 27196 KB | Output is correct |
3 | Correct | 301 ms | 43280 KB | Output is correct |
4 | Correct | 473 ms | 43280 KB | Output is correct |