# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
56486 | aquablitz11 | Teleporters (IOI08_teleporters) | C11 | 934 ms | 66560 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <stdio.h>
#include <stdlib.h>
#define N 1000002
int n, m;
int A[N], B[N], pos[2*N], coord[2*N], nxt[2*N], cc;
int comp(const void *a, const void *b) {
return *(int*)a - *(int*)b;
}
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];
}
qsort(coord, 2*n+1, sizeof(int), comp);
for (int i = 0; i < 2*n+1; ++i)
pos[coord[i]] = i;
for (int i = 0; i < n; ++i) {
nxt[pos[A[i]]-1] = pos[B[i]];
nxt[pos[B[i]]-1] = pos[A[i]];
}
for (int i = 0; i < 2*n+1; ++i)
pos[i] = 0;
int ans = 0;
for (int s = 0; s < 2*n; ++s) {
if (pos[s]) continue;
for (int u = s, c = 1; ; ++c) {
pos[u] = 1;
u = nxt[u];
if (pos[u]) {
A[cc++] = c;
break;
} else if (u == 2*n) {
ans = c;
break;
}
}
}
qsort(A, cc, sizeof(int), comp);
while (m--) {
if (cc > 0) {
ans += A[--cc]+2;
} else {
++ans;
A[cc++] = 1;
}
}
printf("%d\n", ans);
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |