Submission #1022151

# Submission time Handle Problem Language Result Execution time Memory
1022151 2024-07-13T10:33:25 Z UmairAhmadMirza Kutije (COCI21_kutije) C++17
70 / 70
830 ms 23636 KB
#include <bits/stdc++.h>
using namespace std;

#define ll long long
int const N=2e5+5;
int const mod=1e9+7;

vector<int> adj[N];
int com[N],c=0;
void dfs(int node){
    com[node]=c;
    for(int i:adj[node])
        if(com[i]==0)
            dfs(i);
}

int main(){
    int n,m,q;
    cin>>n>>m>>q;
    while(m--){
        for(int i=1;i<=n;i++){
            int p;
            cin>>p;
            adj[p].push_back(i);
            adj[i].push_back(p);
        }
    }
    for (int i = 1; i <=n; ++i)
        if(com[i]==0){
            c++;
            dfs(i);
        }
    while(q--){
        int u,v;
        cin>>u>>v;
        if(com[u]==com[v])
            cout<<"DA"<<endl;
        else
            cout<<"NE"<<endl;
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 698 ms 10852 KB Output is correct
2 Correct 612 ms 10460 KB Output is correct
3 Correct 597 ms 10068 KB Output is correct
4 Correct 681 ms 10932 KB Output is correct
5 Correct 710 ms 10968 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 5212 KB Output is correct
2 Correct 4 ms 5136 KB Output is correct
3 Correct 3 ms 5720 KB Output is correct
4 Correct 6 ms 5720 KB Output is correct
5 Correct 3 ms 5208 KB Output is correct
6 Correct 4 ms 5212 KB Output is correct
7 Correct 3 ms 5212 KB Output is correct
8 Correct 5 ms 5212 KB Output is correct
9 Correct 4 ms 5212 KB Output is correct
10 Correct 3 ms 5212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 5212 KB Output is correct
2 Correct 4 ms 5136 KB Output is correct
3 Correct 3 ms 5720 KB Output is correct
4 Correct 6 ms 5720 KB Output is correct
5 Correct 3 ms 5208 KB Output is correct
6 Correct 4 ms 5212 KB Output is correct
7 Correct 3 ms 5212 KB Output is correct
8 Correct 5 ms 5212 KB Output is correct
9 Correct 4 ms 5212 KB Output is correct
10 Correct 3 ms 5212 KB Output is correct
11 Correct 3 ms 5740 KB Output is correct
12 Correct 3 ms 5724 KB Output is correct
13 Correct 4 ms 5208 KB Output is correct
14 Correct 5 ms 5464 KB Output is correct
15 Correct 4 ms 5212 KB Output is correct
16 Correct 4 ms 5208 KB Output is correct
17 Correct 5 ms 5152 KB Output is correct
18 Correct 4 ms 5724 KB Output is correct
19 Correct 3 ms 5212 KB Output is correct
20 Correct 4 ms 5236 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 698 ms 10852 KB Output is correct
2 Correct 612 ms 10460 KB Output is correct
3 Correct 597 ms 10068 KB Output is correct
4 Correct 681 ms 10932 KB Output is correct
5 Correct 710 ms 10968 KB Output is correct
6 Correct 4 ms 5212 KB Output is correct
7 Correct 4 ms 5136 KB Output is correct
8 Correct 3 ms 5720 KB Output is correct
9 Correct 6 ms 5720 KB Output is correct
10 Correct 3 ms 5208 KB Output is correct
11 Correct 4 ms 5212 KB Output is correct
12 Correct 3 ms 5212 KB Output is correct
13 Correct 5 ms 5212 KB Output is correct
14 Correct 4 ms 5212 KB Output is correct
15 Correct 3 ms 5212 KB Output is correct
16 Correct 3 ms 5740 KB Output is correct
17 Correct 3 ms 5724 KB Output is correct
18 Correct 4 ms 5208 KB Output is correct
19 Correct 5 ms 5464 KB Output is correct
20 Correct 4 ms 5212 KB Output is correct
21 Correct 4 ms 5208 KB Output is correct
22 Correct 5 ms 5152 KB Output is correct
23 Correct 4 ms 5724 KB Output is correct
24 Correct 3 ms 5212 KB Output is correct
25 Correct 4 ms 5236 KB Output is correct
26 Correct 783 ms 23636 KB Output is correct
27 Correct 801 ms 23508 KB Output is correct
28 Correct 738 ms 21268 KB Output is correct
29 Correct 754 ms 23048 KB Output is correct
30 Correct 640 ms 21100 KB Output is correct
31 Correct 632 ms 21328 KB Output is correct
32 Correct 763 ms 22868 KB Output is correct
33 Correct 766 ms 22868 KB Output is correct
34 Correct 830 ms 22960 KB Output is correct
35 Correct 814 ms 23336 KB Output is correct