# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
503211 | 2022-01-07T14:00:12 Z | rainboy | Kutije (COCI21_kutije) | C | 226 ms | 9124 KB |
#include <stdio.h> #include <string.h> #define N 1000 int ds[N]; int find(int i) { return ds[i] < 0 ? i : (ds[i] = find(ds[i])); } void join(int i, int j) { i = find(i); j = find(j); if (i == j) return; if (ds[i] > ds[j]) ds[i] = j; else { if (ds[i] == ds[j]) ds[i]--; ds[j] = i; } } int main() { int n, m, q, i, j; scanf("%d%d%d", &n, &m, &q); memset(ds, -1, n * sizeof *ds); while (m--) for (i = 0; i < n; i++) { scanf("%d", &j), j--; join(i, j); } while (q--) { scanf("%d%d", &i, &j), i--, j--; printf(find(i) == find(j) ? "DA\n" : "NE\n"); } return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 114 ms | 4636 KB | Output is correct |
2 | Correct | 93 ms | 4748 KB | Output is correct |
3 | Correct | 92 ms | 4568 KB | Output is correct |
4 | Correct | 109 ms | 5432 KB | Output is correct |
5 | Correct | 120 ms | 5380 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
2 | Correct | 1 ms | 208 KB | Output is correct |
3 | Correct | 1 ms | 204 KB | Output is correct |
4 | Correct | 1 ms | 204 KB | Output is correct |
5 | Correct | 1 ms | 292 KB | Output is correct |
6 | Correct | 1 ms | 292 KB | Output is correct |
7 | Correct | 1 ms | 292 KB | Output is correct |
8 | Correct | 1 ms | 332 KB | Output is correct |
9 | Correct | 1 ms | 204 KB | Output is correct |
10 | Correct | 1 ms | 204 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
2 | Correct | 1 ms | 208 KB | Output is correct |
3 | Correct | 1 ms | 204 KB | Output is correct |
4 | Correct | 1 ms | 204 KB | Output is correct |
5 | Correct | 1 ms | 292 KB | Output is correct |
6 | Correct | 1 ms | 292 KB | Output is correct |
7 | Correct | 1 ms | 292 KB | Output is correct |
8 | Correct | 1 ms | 332 KB | Output is correct |
9 | Correct | 1 ms | 204 KB | Output is correct |
10 | Correct | 1 ms | 204 KB | Output is correct |
11 | Correct | 2 ms | 204 KB | Output is correct |
12 | Correct | 1 ms | 292 KB | Output is correct |
13 | Correct | 2 ms | 460 KB | Output is correct |
14 | Correct | 1 ms | 204 KB | Output is correct |
15 | Correct | 1 ms | 284 KB | Output is correct |
16 | Correct | 1 ms | 204 KB | Output is correct |
17 | Correct | 1 ms | 208 KB | Output is correct |
18 | Correct | 1 ms | 204 KB | Output is correct |
19 | Correct | 1 ms | 208 KB | Output is correct |
20 | Correct | 1 ms | 204 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 114 ms | 4636 KB | Output is correct |
2 | Correct | 93 ms | 4748 KB | Output is correct |
3 | Correct | 92 ms | 4568 KB | Output is correct |
4 | Correct | 109 ms | 5432 KB | Output is correct |
5 | Correct | 120 ms | 5380 KB | Output is correct |
6 | Correct | 1 ms | 204 KB | Output is correct |
7 | Correct | 1 ms | 208 KB | Output is correct |
8 | Correct | 1 ms | 204 KB | Output is correct |
9 | Correct | 1 ms | 204 KB | Output is correct |
10 | Correct | 1 ms | 292 KB | Output is correct |
11 | Correct | 1 ms | 292 KB | Output is correct |
12 | Correct | 1 ms | 292 KB | Output is correct |
13 | Correct | 1 ms | 332 KB | Output is correct |
14 | Correct | 1 ms | 204 KB | Output is correct |
15 | Correct | 1 ms | 204 KB | Output is correct |
16 | Correct | 2 ms | 204 KB | Output is correct |
17 | Correct | 1 ms | 292 KB | Output is correct |
18 | Correct | 2 ms | 460 KB | Output is correct |
19 | Correct | 1 ms | 204 KB | Output is correct |
20 | Correct | 1 ms | 284 KB | Output is correct |
21 | Correct | 1 ms | 204 KB | Output is correct |
22 | Correct | 1 ms | 208 KB | Output is correct |
23 | Correct | 1 ms | 204 KB | Output is correct |
24 | Correct | 1 ms | 208 KB | Output is correct |
25 | Correct | 1 ms | 204 KB | Output is correct |
26 | Correct | 201 ms | 8624 KB | Output is correct |
27 | Correct | 210 ms | 8880 KB | Output is correct |
28 | Correct | 184 ms | 7284 KB | Output is correct |
29 | Correct | 194 ms | 8544 KB | Output is correct |
30 | Correct | 182 ms | 7580 KB | Output is correct |
31 | Correct | 169 ms | 7456 KB | Output is correct |
32 | Correct | 202 ms | 8900 KB | Output is correct |
33 | Correct | 226 ms | 8948 KB | Output is correct |
34 | Correct | 195 ms | 9124 KB | Output is correct |
35 | Correct | 204 ms | 8660 KB | Output is correct |