# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
98633 | 2019-02-25T02:12:44 Z | PeppaPig | Teleporters (IOI08_teleporters) | C++14 | 720 ms | 42744 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 | 8192 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 14 ms | 8192 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 15 ms | 8192 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 14 ms | 8192 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 15 ms | 8192 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 15 ms | 8192 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 14 ms | 8192 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 14 ms | 8220 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 15 ms | 8192 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 14 ms | 8192 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 15 ms | 8320 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 14 ms | 8320 KB | Output is correct |
2 | Correct | 17 ms | 8628 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 16 ms | 8320 KB | Output is correct |
2 | Correct | 21 ms | 8888 KB | Output is correct |
3 | Correct | 23 ms | 8960 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 18 ms | 8576 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 19 ms | 8704 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 95 ms | 13112 KB | Output is correct |
2 | Correct | 290 ms | 21952 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 170 ms | 18040 KB | Output is correct |
2 | Correct | 386 ms | 26728 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 428 ms | 31840 KB | Output is correct |
2 | Correct | 491 ms | 35016 KB | Output is correct |
3 | Correct | 425 ms | 36388 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 688 ms | 37448 KB | Output is correct |
2 | Correct | 720 ms | 39620 KB | Output is correct |
3 | Correct | 511 ms | 38408 KB | Output is correct |
4 | Correct | 518 ms | 38648 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 691 ms | 41068 KB | Output is correct |
2 | Correct | 631 ms | 41580 KB | Output is correct |
3 | Correct | 296 ms | 42744 KB | Output is correct |
4 | Correct | 530 ms | 42720 KB | Output is correct |