답안 #1102453

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1102453 2024-10-18T07:24:49 Z yavuzskarahan Kutije (COCI21_kutije) C++14
70 / 70
787 ms 2008 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
 
int n, m, q, a, b, u, v;
vector<int> adj[1002];
int parent[1002];
 
inline int find(int a){
    if (a==parent[a]) return a;
    else return parent[a] = find(parent[a]);
}
 
inline void unite(int a, int b){
    a = find(a);
    b = find(b);
    parent[b] = a;
    return;
}
 
inline int solve(){
 
    cin >> n >> m >> q;
 
    FOR(i,1,n) parent[i] = i;
 
    FOR(i,1,m){
        FOR(j,1,n){
            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 726 ms 1832 KB Output is correct
2 Correct 621 ms 1652 KB Output is correct
3 Correct 601 ms 1556 KB Output is correct
4 Correct 733 ms 1740 KB Output is correct
5 Correct 738 ms 1864 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 2 ms 348 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 2 ms 348 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 504 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 508 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 2 ms 336 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 726 ms 1832 KB Output is correct
2 Correct 621 ms 1652 KB Output is correct
3 Correct 601 ms 1556 KB Output is correct
4 Correct 733 ms 1740 KB Output is correct
5 Correct 738 ms 1864 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 2 ms 348 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 504 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 508 KB Output is correct
22 Correct 1 ms 336 KB Output is correct
23 Correct 1 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 771 ms 1752 KB Output is correct
27 Correct 769 ms 1732 KB Output is correct
28 Correct 644 ms 1596 KB Output is correct
29 Correct 734 ms 1796 KB Output is correct
30 Correct 636 ms 1544 KB Output is correct
31 Correct 622 ms 1576 KB Output is correct
32 Correct 772 ms 1864 KB Output is correct
33 Correct 787 ms 1864 KB Output is correct
34 Correct 774 ms 2008 KB Output is correct
35 Correct 771 ms 1952 KB Output is correct