Submission #507670

# Submission time Handle Problem Language Result Execution time Memory
507670 2022-01-13T00:46:30 Z penguinhacker Kutije (COCI21_kutije) C++14
70 / 70
156 ms 10204 KB
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define ar array

const int mxN=1000;
int n, m, q, cmp[mxN], c;
bool adj[mxN][mxN];

void dfs(int u) {
	cmp[u]=c;
	for (int v=0; v<n; ++v)
		if (adj[u][v]&&!cmp[v])
			dfs(v);
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> n >> m >> q;
	for (int i=0; i<m; ++i)
		for (int j=0; j<n; ++j) {
			int k;
			cin >> k, --k;
			adj[j][k]=adj[k][j]=1;
		}
	for (int i=0; i<n; ++i)
		if (!cmp[i])
			++c, dfs(i);
	while(q--) {
		int u, v;
		cin >> u >> v, --u, --v;
		cout << (cmp[u]==cmp[v]?"DA":"NE") << "\n";
	}
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 79 ms 5616 KB Output is correct
2 Correct 71 ms 5760 KB Output is correct
3 Correct 73 ms 5396 KB Output is correct
4 Correct 77 ms 6464 KB Output is correct
5 Correct 79 ms 6468 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 328 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 424 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 2 ms 440 KB Output is correct
8 Correct 1 ms 428 KB Output is correct
9 Correct 1 ms 324 KB Output is correct
10 Correct 1 ms 432 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 328 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 424 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 2 ms 440 KB Output is correct
8 Correct 1 ms 428 KB Output is correct
9 Correct 1 ms 324 KB Output is correct
10 Correct 1 ms 432 KB Output is correct
11 Correct 1 ms 440 KB Output is correct
12 Correct 2 ms 332 KB Output is correct
13 Correct 1 ms 428 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 440 KB Output is correct
16 Correct 1 ms 336 KB Output is correct
17 Correct 1 ms 332 KB Output is correct
18 Correct 1 ms 332 KB Output is correct
19 Correct 3 ms 332 KB Output is correct
20 Correct 1 ms 420 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 79 ms 5616 KB Output is correct
2 Correct 71 ms 5760 KB Output is correct
3 Correct 73 ms 5396 KB Output is correct
4 Correct 77 ms 6464 KB Output is correct
5 Correct 79 ms 6468 KB Output is correct
6 Correct 1 ms 328 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 424 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 2 ms 440 KB Output is correct
13 Correct 1 ms 428 KB Output is correct
14 Correct 1 ms 324 KB Output is correct
15 Correct 1 ms 432 KB Output is correct
16 Correct 1 ms 440 KB Output is correct
17 Correct 2 ms 332 KB Output is correct
18 Correct 1 ms 428 KB Output is correct
19 Correct 1 ms 332 KB Output is correct
20 Correct 1 ms 440 KB Output is correct
21 Correct 1 ms 336 KB Output is correct
22 Correct 1 ms 332 KB Output is correct
23 Correct 1 ms 332 KB Output is correct
24 Correct 3 ms 332 KB Output is correct
25 Correct 1 ms 420 KB Output is correct
26 Correct 154 ms 7492 KB Output is correct
27 Correct 143 ms 7616 KB Output is correct
28 Correct 120 ms 8440 KB Output is correct
29 Correct 156 ms 9828 KB Output is correct
30 Correct 120 ms 8644 KB Output is correct
31 Correct 120 ms 8584 KB Output is correct
32 Correct 136 ms 10204 KB Output is correct
33 Correct 139 ms 10184 KB Output is correct
34 Correct 140 ms 10180 KB Output is correct
35 Correct 141 ms 10068 KB Output is correct