답안 #876407

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
876407 2023-11-21T16:52:12 Z JoksimKaktus Kutije (COCI21_kutije) C++17
70 / 70
119 ms 13748 KB
#include <bits/stdc++.h>

using namespace std;
using ll = long long;
void output(bool yes){yes ? cout << "Yes" << "\n" : cout << "No" << "\n";}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(0);
    int n,m,q;
    cin >> n >> m >> q;
    vector <vector<int>>arr(n,vector<int>(m));
    for(int i = 0;i < m;i++){
        for(int j = 0;j < n;j++){
            cin >> arr[j][i];
            arr[j][i]--;
        }
    }
    vector <int> res(n,-1);
    for(int i = 0;i < n;i++){
        if(res[i] != -1)continue;
        queue <int> qu;
        qu.push(i);
        while(!qu.empty()){
            int j = qu.front();
            qu.pop();
            if(res[j] == i)continue;
            res[j]=i;
            for(int k : arr[j])qu.push(k);
        }
    }
    while(q--){
        int a,b;
        cin >> a >> b;
        a--;
        b--;
        if(res[a] == res[b]){
            cout << "DA\n";
        }else{
            cout << "NE\n";
        }
    }
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 62 ms 5720 KB Output is correct
2 Correct 54 ms 4996 KB Output is correct
3 Correct 51 ms 4692 KB Output is correct
4 Correct 60 ms 5732 KB Output is correct
5 Correct 61 ms 5696 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 524 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 524 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 524 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 524 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 344 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 62 ms 5720 KB Output is correct
2 Correct 54 ms 4996 KB Output is correct
3 Correct 51 ms 4692 KB Output is correct
4 Correct 60 ms 5732 KB Output is correct
5 Correct 61 ms 5696 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 524 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 524 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 ms 344 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 119 ms 13748 KB Output is correct
27 Correct 114 ms 13512 KB Output is correct
28 Correct 98 ms 11224 KB Output is correct
29 Correct 112 ms 13248 KB Output is correct
30 Correct 94 ms 11604 KB Output is correct
31 Correct 96 ms 11600 KB Output is correct
32 Correct 112 ms 13484 KB Output is correct
33 Correct 119 ms 13412 KB Output is correct
34 Correct 111 ms 13392 KB Output is correct
35 Correct 109 ms 13396 KB Output is correct