답안 #698260

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
698260 2023-02-13T02:15:45 Z AaW Kutije (COCI21_kutije) C++14
70 / 70
144 ms 1812 KB
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define endl '\n'
#define AI(x) begin(x),end(x)
#ifdef DEBUG 
#define debug(args...) LKJ("\033[1;32m[ "+string(#args)+" ]\033[0m", args)
template<class I> void LKJ(I&&x){ cerr << x << '\n'; }
template<class I, class...T> void LKJ(I&&x, T&&...t){ cerr << x << ", ", LKJ(t...); }
template<class I> void OI(I a, I b){ while(a < b) cerr << *a << " \n"[next(a) == b], ++a; }
#else
#define debug(...) 0
#define OI(...) 0
#endif
#define _ ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
struct DSU{
	int n;
	vector<int> arr;
	void init(int _n) {
		n = _n;
		arr.clear();
		arr.resize(n+1);
		for (int i = 0; i <= n; ++i) {
			arr[i] = i;
		}
	}
	int query(int a) {
		if (arr[a] == a) return a;
		arr[a] = query(arr[a]);
		return arr[a];
	}
	void modify(int a, int b) {
		a = query(a);
		b = query(b);
		arr[a] = b;
	}
}djs;


signed main(){_
	int n, m, q;
	cin >> n >> m >> q;
	djs.init(n);
	for (int i = 0; i < m; ++i) {
		for (int j = 1; j <= n; ++j) {
			int temp;
			cin >> temp;
			djs.modify(temp, j);
		}
	}	
	for (int i = 0; i < q; ++i){
		int a, b;
		cin >> a >> b;
		if (djs.query(a) == djs.query(b)) {
			cout << "DA\n";
		} else {
			cout << "NE\n";
		}
	}

	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 72 ms 1804 KB Output is correct
2 Correct 62 ms 1600 KB Output is correct
3 Correct 63 ms 1416 KB Output is correct
4 Correct 85 ms 1812 KB Output is correct
5 Correct 73 ms 1804 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 2 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 72 ms 1804 KB Output is correct
2 Correct 62 ms 1600 KB Output is correct
3 Correct 63 ms 1416 KB Output is correct
4 Correct 85 ms 1812 KB Output is correct
5 Correct 73 ms 1804 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 2 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 133 ms 1740 KB Output is correct
27 Correct 144 ms 1692 KB Output is correct
28 Correct 114 ms 1464 KB Output is correct
29 Correct 127 ms 1708 KB Output is correct
30 Correct 122 ms 1532 KB Output is correct
31 Correct 122 ms 1512 KB Output is correct
32 Correct 128 ms 1792 KB Output is correct
33 Correct 132 ms 1792 KB Output is correct
34 Correct 133 ms 1712 KB Output is correct
35 Correct 130 ms 1724 KB Output is correct