# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
56482 | 2018-07-11T12:54:03 Z | aquablitz11 | Teleporters (IOI08_teleporters) | C++14 | 1000 ms | 36160 KB |
#include <bits/stdc++.h> using namespace std; const int N = 1000002; int n, m; int A[N], B[N], coord[2*N], nxt[2*N], cc; bool vis[2*N]; int main() { scanf("%d%d", &n, &m); for (int i = 0; i < n; ++i) { scanf("%d%d", &A[i], &B[i]); coord[2*i+1] = A[i]; coord[2*i+2] = B[i]; } sort(coord, coord+2*n+1); for (int i = 0; i < n; ++i) { int pa = lower_bound(coord, coord+2*n+1, A[i])-coord; int pb = lower_bound(coord, coord+2*n+1, B[i])-coord; nxt[pa-1] = pb; nxt[pb-1] = pa; } int ans = 0; for (int s = 0; s < 2*n; ++s) { if (vis[s]) continue; for (int u = s, c = 1; ; ++c) { vis[u] = true; u = nxt[u]; if (vis[u]) { A[cc++] = c; break; } else if (u == 2*n) { ans = c; break; } } } sort(A, A+cc); while (m--) { if (cc > 0) { ans += A[--cc]+2; } else { ++ans; A[cc++] = 1; } } printf("%d\n", ans); return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 376 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 420 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 612 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 612 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 632 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 636 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 772 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 772 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 772 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 772 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 9 ms | 792 KB | Output is correct |
2 | Correct | 9 ms | 1080 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 1080 KB | Output is correct |
2 | Correct | 12 ms | 1080 KB | Output is correct |
3 | Correct | 28 ms | 1568 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 15 ms | 1568 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 16 ms | 1568 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 109 ms | 4000 KB | Output is correct |
2 | Correct | 324 ms | 8444 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 209 ms | 8444 KB | Output is correct |
2 | Correct | 461 ms | 12216 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 805 ms | 16784 KB | Output is correct |
2 | Correct | 958 ms | 19896 KB | Output is correct |
3 | Correct | 989 ms | 33660 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1068 ms | 33660 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1078 ms | 36160 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |