답안 #1102456

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1102456 2024-10-18T07:28:52 Z yavuzskarahan Kutije (COCI21_kutije) C++14
70 / 70
781 ms 1944 KB
// In the name of God, the Most Gracious, the Most Merciful.
// iflbot(); - @yavuzskarahan
 
#include <bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0); cin.tie(0);
#define FOR(i, L, R) for(int i = (L); i <= (R); i++)
#define pb push_back
 
short n, m, a, b;
int q;
short parent[1002];
 
inline short find(short a){
    if (a==parent[a]) return a;
    else return parent[a] = find(parent[a]);
}
 
inline void unite(short a, short b){
    a = find(a);
    b = find(b);
    parent[b] = a;
    return;
}
 
inline int solve(){
 
    cin >> n >> m >> q;
 
    for(short i = 1; i <= n; i++) parent[i] = i;
 
    for(short i = 1; i <= m; i++){
        for(short j = 1; j <= n; j++){
            cin >> a;
            unite(j,a);
        }
    }
 
    while(q--){
        cin >> a >> b;
        if (find(a) == find(b)) cout << "DA" << endl;
        else cout << "NE" << endl;
    }
 
    return 0;
 
}
 
int main() {
 
    fast;
    solve();
    return 0;
  
}
# 결과 실행 시간 메모리 Grader output
1 Correct 720 ms 1744 KB Output is correct
2 Correct 619 ms 1608 KB Output is correct
3 Correct 595 ms 1516 KB Output is correct
4 Correct 721 ms 1708 KB Output is correct
5 Correct 725 ms 1828 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 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 1 ms 336 KB Output is correct
2 Correct 1 ms 336 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 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 1 ms 336 KB Output is correct
17 Correct 1 ms 336 KB Output is correct
18 Correct 1 ms 336 KB Output is correct
19 Correct 2 ms 336 KB Output is correct
20 Correct 1 ms 336 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 720 ms 1744 KB Output is correct
2 Correct 619 ms 1608 KB Output is correct
3 Correct 595 ms 1516 KB Output is correct
4 Correct 721 ms 1708 KB Output is correct
5 Correct 725 ms 1828 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 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 1 ms 336 KB Output is correct
17 Correct 1 ms 336 KB Output is correct
18 Correct 1 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 1 ms 336 KB Output is correct
22 Correct 1 ms 336 KB Output is correct
23 Correct 1 ms 336 KB Output is correct
24 Correct 2 ms 336 KB Output is correct
25 Correct 1 ms 336 KB Output is correct
26 Correct 768 ms 1860 KB Output is correct
27 Correct 758 ms 1944 KB Output is correct
28 Correct 649 ms 1496 KB Output is correct
29 Correct 736 ms 1864 KB Output is correct
30 Correct 664 ms 1600 KB Output is correct
31 Correct 618 ms 1464 KB Output is correct
32 Correct 770 ms 1732 KB Output is correct
33 Correct 768 ms 1736 KB Output is correct
34 Correct 781 ms 1864 KB Output is correct
35 Correct 777 ms 1744 KB Output is correct