Submission #536489

# Submission time Handle Problem Language Result Execution time Memory
536489 2022-03-13T12:15:34 Z l3nl3 Kutije (COCI21_kutije) C++17
70 / 70
147 ms 9540 KB
/*#pragma GCC optimize("O3")
#pragma GCC target ("avx2")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
*/
#include <bits/stdc++.h>

#define int long long

using namespace std;

const int N = 1e3 + 7;

int n, m, q, p[N], r[N];

int getp (int x) {
	if (x == p[x]) return x;
	return p[x] = getp(p[x]);
}

void unite (int a, int b) {
	a = getp(a);
	b = getp(b);
	if (a == b) return;
	if (r[b] > r[a]) swap(a, b);
	p[b] = a;
	r[a] += r[b];
}

signed main () {
//	freopen("", "r", stdin);
//	freopen("", "w", stdout);
	ios_base::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);  
	cin >> n >> m >> q;
	for (int i = 1; i <= n; i++) {
		p[i] = i;
		r[i] = 1;
	}
	for (int i = 1; i <= m; i++) {
		for (int j = 1; j <= n; j++) {
			int x;
			cin >> x;
			unite(x, j);
		}
	}
	while (q--) {
		int a, b;
		cin >> a >> b;
		if (getp(a) == getp(b)) cout << "DA\n";
		else cout << "NE\n";
	}
}
# Verdict Execution time Memory Grader output
1 Correct 79 ms 5592 KB Output is correct
2 Correct 64 ms 4928 KB Output is correct
3 Correct 61 ms 4620 KB Output is correct
4 Correct 73 ms 5580 KB Output is correct
5 Correct 79 ms 5548 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 1 ms 360 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 1 ms 360 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 79 ms 5592 KB Output is correct
2 Correct 64 ms 4928 KB Output is correct
3 Correct 61 ms 4620 KB Output is correct
4 Correct 73 ms 5580 KB Output is correct
5 Correct 79 ms 5548 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 1 ms 360 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 364 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 139 ms 9540 KB Output is correct
27 Correct 132 ms 9420 KB Output is correct
28 Correct 112 ms 7884 KB Output is correct
29 Correct 139 ms 9020 KB Output is correct
30 Correct 120 ms 8004 KB Output is correct
31 Correct 118 ms 7996 KB Output is correct
32 Correct 130 ms 9396 KB Output is correct
33 Correct 147 ms 9396 KB Output is correct
34 Correct 131 ms 9356 KB Output is correct
35 Correct 139 ms 9388 KB Output is correct