# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1102466 | 2024-10-18T07:40:56 Z | yavuzskarahan | Kutije (COCI21_kutije) | C++11 | 135 ms | 1864 KB |
#include <iostream> #include <algorithm> using namespace std; const int N = 1000 + 5; int n, m, q, a, b, arr[N]; struct DSU{ int par[N], stsize[N]; DSU(){ for(int i = 1; i < N; i++) par[i] = i, stsize[i] = 1; } int setfind(int a){ if(par[a] == a) return a; else return par[a] = setfind(par[a]); } void setunion(int a, int b){ a = setfind(a), b = setfind(b); if(a != b){ if(stsize[b] > stsize[a]) swap(a, b); par[b] = par[a]; stsize[a] += stsize[b]; } } }; DSU dsu; int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); scanf("%d", &n); scanf("%d", &m); scanf("%d", &q); for(int i = 1; i <= m; i++){ for(int i = 1; i <= n; i++) scanf("%d", &arr[i]); for(int i = 1; i <= n; i++) dsu.setunion(i, arr[i]); } while(q--){ scanf("%d", &a); scanf("%d", &b); if(dsu.setfind(a) == dsu.setfind(b)) printf("DA\n"); else printf("NE\n"); } }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 74 ms | 1816 KB | Output is correct |
2 | Correct | 62 ms | 1588 KB | Output is correct |
3 | Correct | 55 ms | 1692 KB | Output is correct |
4 | Correct | 63 ms | 1864 KB | Output is correct |
5 | Correct | 69 ms | 1864 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 504 KB | Output is correct |
2 | Correct | 1 ms | 504 KB | Output is correct |
3 | Correct | 1 ms | 336 KB | Output is correct |
4 | Correct | 1 ms | 336 KB | Output is correct |
5 | Correct | 1 ms | 336 KB | Output is correct |
6 | Correct | 1 ms | 336 KB | Output is correct |
7 | Correct | 1 ms | 336 KB | Output is correct |
8 | Correct | 1 ms | 336 KB | Output is correct |
9 | Correct | 1 ms | 336 KB | Output is correct |
10 | Correct | 1 ms | 336 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 504 KB | Output is correct |
2 | Correct | 1 ms | 504 KB | Output is correct |
3 | Correct | 1 ms | 336 KB | Output is correct |
4 | Correct | 1 ms | 336 KB | Output is correct |
5 | Correct | 1 ms | 336 KB | Output is correct |
6 | Correct | 1 ms | 336 KB | Output is correct |
7 | Correct | 1 ms | 336 KB | Output is correct |
8 | Correct | 1 ms | 336 KB | Output is correct |
9 | Correct | 1 ms | 336 KB | Output is correct |
10 | Correct | 1 ms | 336 KB | Output is correct |
11 | Correct | 2 ms | 336 KB | Output is correct |
12 | Correct | 1 ms | 336 KB | Output is correct |
13 | Correct | 2 ms | 336 KB | Output is correct |
14 | Correct | 1 ms | 336 KB | Output is correct |
15 | Correct | 1 ms | 336 KB | Output is correct |
16 | Correct | 2 ms | 336 KB | Output is correct |
17 | Correct | 2 ms | 336 KB | Output is correct |
18 | Correct | 2 ms | 336 KB | Output is correct |
19 | Correct | 1 ms | 336 KB | Output is correct |
20 | Correct | 2 ms | 336 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 74 ms | 1816 KB | Output is correct |
2 | Correct | 62 ms | 1588 KB | Output is correct |
3 | Correct | 55 ms | 1692 KB | Output is correct |
4 | Correct | 63 ms | 1864 KB | Output is correct |
5 | Correct | 69 ms | 1864 KB | Output is correct |
6 | Correct | 2 ms | 504 KB | Output is correct |
7 | Correct | 1 ms | 504 KB | Output is correct |
8 | Correct | 1 ms | 336 KB | Output is correct |
9 | Correct | 1 ms | 336 KB | Output is correct |
10 | Correct | 1 ms | 336 KB | Output is correct |
11 | Correct | 1 ms | 336 KB | Output is correct |
12 | Correct | 1 ms | 336 KB | Output is correct |
13 | Correct | 1 ms | 336 KB | Output is correct |
14 | Correct | 1 ms | 336 KB | Output is correct |
15 | Correct | 1 ms | 336 KB | Output is correct |
16 | Correct | 2 ms | 336 KB | Output is correct |
17 | Correct | 1 ms | 336 KB | Output is correct |
18 | Correct | 2 ms | 336 KB | Output is correct |
19 | Correct | 1 ms | 336 KB | Output is correct |
20 | Correct | 1 ms | 336 KB | Output is correct |
21 | Correct | 2 ms | 336 KB | Output is correct |
22 | Correct | 2 ms | 336 KB | Output is correct |
23 | Correct | 2 ms | 336 KB | Output is correct |
24 | Correct | 1 ms | 336 KB | Output is correct |
25 | Correct | 2 ms | 336 KB | Output is correct |
26 | Correct | 119 ms | 1752 KB | Output is correct |
27 | Correct | 119 ms | 1736 KB | Output is correct |
28 | Correct | 95 ms | 1484 KB | Output is correct |
29 | Correct | 125 ms | 1864 KB | Output is correct |
30 | Correct | 119 ms | 1488 KB | Output is correct |
31 | Correct | 108 ms | 1488 KB | Output is correct |
32 | Correct | 111 ms | 1740 KB | Output is correct |
33 | Correct | 122 ms | 1864 KB | Output is correct |
34 | Correct | 112 ms | 1864 KB | Output is correct |
35 | Correct | 135 ms | 1864 KB | Output is correct |