Submission #497229

# Submission time Handle Problem Language Result Execution time Memory
497229 2021-12-22T19:33:15 Z Abrar_Al_Samit Kutije (COCI21_kutije) C++17
70 / 70
166 ms 18232 KB
#include<bits/stdc++.h>
using namespace std;
const int MX = 1005;
vector<int>g[MX];
bool vis[MX];
int comp[MX];
void DFS(int v, int no) {
	vis[v] = 1;
	comp[v] = no;
	for(auto u : g[v]) if(!vis[u]) {
		DFS(u, no);
	}
}
void PlayGround() {
	int n, m, q; cin >> n >> m >> q;
	while(m--) {
		for(int i=1; i<=n; ++i) {
			int to; cin >> to;
			g[i].push_back(to);
			g[to].push_back(i);
		}
	}
	int cur = 1;
	for(int i=1; i<=n; ++i) if(!vis[i]) {
		DFS(i, cur);
		++cur;
	}
	while(q--) {
		int a, b; cin >> a >> b;
		if(comp[a]==comp[b]) {
			cout << "DA\n";
		} else {
			cout << "NE\n";
		}
	}
}
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	PlayGround();
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 71 ms 5572 KB Output is correct
2 Correct 65 ms 4840 KB Output is correct
3 Correct 78 ms 4676 KB Output is correct
4 Correct 71 ms 5644 KB Output is correct
5 Correct 72 ms 5660 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 400 KB Output is correct
2 Correct 1 ms 460 KB Output is correct
3 Correct 1 ms 460 KB Output is correct
4 Correct 1 ms 460 KB Output is correct
5 Correct 1 ms 400 KB Output is correct
6 Correct 1 ms 460 KB Output is correct
7 Correct 2 ms 460 KB Output is correct
8 Correct 1 ms 460 KB Output is correct
9 Correct 2 ms 396 KB Output is correct
10 Correct 1 ms 396 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 400 KB Output is correct
2 Correct 1 ms 460 KB Output is correct
3 Correct 1 ms 460 KB Output is correct
4 Correct 1 ms 460 KB Output is correct
5 Correct 1 ms 400 KB Output is correct
6 Correct 1 ms 460 KB Output is correct
7 Correct 2 ms 460 KB Output is correct
8 Correct 1 ms 460 KB Output is correct
9 Correct 2 ms 396 KB Output is correct
10 Correct 1 ms 396 KB Output is correct
11 Correct 1 ms 452 KB Output is correct
12 Correct 1 ms 440 KB Output is correct
13 Correct 1 ms 460 KB Output is correct
14 Correct 1 ms 460 KB Output is correct
15 Correct 2 ms 460 KB Output is correct
16 Correct 2 ms 460 KB Output is correct
17 Correct 1 ms 396 KB Output is correct
18 Correct 1 ms 460 KB Output is correct
19 Correct 1 ms 460 KB Output is correct
20 Correct 1 ms 460 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 71 ms 5572 KB Output is correct
2 Correct 65 ms 4840 KB Output is correct
3 Correct 78 ms 4676 KB Output is correct
4 Correct 71 ms 5644 KB Output is correct
5 Correct 72 ms 5660 KB Output is correct
6 Correct 1 ms 400 KB Output is correct
7 Correct 1 ms 460 KB Output is correct
8 Correct 1 ms 460 KB Output is correct
9 Correct 1 ms 460 KB Output is correct
10 Correct 1 ms 400 KB Output is correct
11 Correct 1 ms 460 KB Output is correct
12 Correct 2 ms 460 KB Output is correct
13 Correct 1 ms 460 KB Output is correct
14 Correct 2 ms 396 KB Output is correct
15 Correct 1 ms 396 KB Output is correct
16 Correct 1 ms 452 KB Output is correct
17 Correct 1 ms 440 KB Output is correct
18 Correct 1 ms 460 KB Output is correct
19 Correct 1 ms 460 KB Output is correct
20 Correct 2 ms 460 KB Output is correct
21 Correct 2 ms 460 KB Output is correct
22 Correct 1 ms 396 KB Output is correct
23 Correct 1 ms 460 KB Output is correct
24 Correct 1 ms 460 KB Output is correct
25 Correct 1 ms 460 KB Output is correct
26 Correct 166 ms 18232 KB Output is correct
27 Correct 164 ms 18156 KB Output is correct
28 Correct 126 ms 15856 KB Output is correct
29 Correct 149 ms 17732 KB Output is correct
30 Correct 126 ms 15564 KB Output is correct
31 Correct 128 ms 15936 KB Output is correct
32 Correct 148 ms 17604 KB Output is correct
33 Correct 156 ms 17508 KB Output is correct
34 Correct 143 ms 17488 KB Output is correct
35 Correct 145 ms 18024 KB Output is correct