답안 #521469

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
521469 2022-02-02T08:14:43 Z errorgorn Kutije (COCI21_kutije) C++17
70 / 70
159 ms 10592 KB
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define ii pair<ll,ll>
#define fi first
#define se second
#define endl '\n'

#define puf push_front
#define pof pop_front
#define pub push_back
#define pob pop_back
#define ub upper_bound
#define lb lower_bound

#define rep(x,s,e) for (auto x=(s)-((s)>(e));x!=(e)-((s)>(e));(s)<(e)?x++:x--)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int) (x).size()

mt19937 rng(177013);

struct UFDS{
	int p[300005];
	
	UFDS(){
		rep(x,0,300005) p[x]=x;
	}
	
	int par(int i){
		if (i==p[i]) return i;
		else return p[i]=par(p[i]);
	}
	
	void unions(int i,int j){
		p[par(i)]=par(j);
	}
} ufds;

int n,k,q;
int arr[1005];

int main(){
	cin.tie(0);
	cout.tie(0);
	cin.sync_with_stdio(false);
	
	cin>>n>>k>>q;
	
	rep(zzz,0,k){
		rep(x,1,n+1) cin>>arr[x];
		
		rep(x,1,n+1) ufds.unions(arr[x],x);
	}
	
	int a,b;
	while (q--){
		cin>>a>>b;
		
		if (ufds.par(a)==ufds.par(b)) cout<<"DA"<<endl;
		else cout<<"NE"<<endl;
	}
}
# 결과 실행 시간 메모리 Grader output
1 Correct 83 ms 6688 KB Output is correct
2 Correct 73 ms 6064 KB Output is correct
3 Correct 67 ms 5828 KB Output is correct
4 Correct 85 ms 6816 KB Output is correct
5 Correct 92 ms 6708 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 1484 KB Output is correct
2 Correct 2 ms 1524 KB Output is correct
3 Correct 2 ms 1484 KB Output is correct
4 Correct 2 ms 1484 KB Output is correct
5 Correct 2 ms 1516 KB Output is correct
6 Correct 2 ms 1508 KB Output is correct
7 Correct 2 ms 1484 KB Output is correct
8 Correct 2 ms 1528 KB Output is correct
9 Correct 1 ms 1484 KB Output is correct
10 Correct 1 ms 1484 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 1484 KB Output is correct
2 Correct 2 ms 1524 KB Output is correct
3 Correct 2 ms 1484 KB Output is correct
4 Correct 2 ms 1484 KB Output is correct
5 Correct 2 ms 1516 KB Output is correct
6 Correct 2 ms 1508 KB Output is correct
7 Correct 2 ms 1484 KB Output is correct
8 Correct 2 ms 1528 KB Output is correct
9 Correct 1 ms 1484 KB Output is correct
10 Correct 1 ms 1484 KB Output is correct
11 Correct 2 ms 1508 KB Output is correct
12 Correct 1 ms 1484 KB Output is correct
13 Correct 1 ms 1484 KB Output is correct
14 Correct 1 ms 1508 KB Output is correct
15 Correct 2 ms 1524 KB Output is correct
16 Correct 2 ms 1484 KB Output is correct
17 Correct 3 ms 1484 KB Output is correct
18 Correct 2 ms 1484 KB Output is correct
19 Correct 2 ms 1484 KB Output is correct
20 Correct 1 ms 1484 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 83 ms 6688 KB Output is correct
2 Correct 73 ms 6064 KB Output is correct
3 Correct 67 ms 5828 KB Output is correct
4 Correct 85 ms 6816 KB Output is correct
5 Correct 92 ms 6708 KB Output is correct
6 Correct 2 ms 1484 KB Output is correct
7 Correct 2 ms 1524 KB Output is correct
8 Correct 2 ms 1484 KB Output is correct
9 Correct 2 ms 1484 KB Output is correct
10 Correct 2 ms 1516 KB Output is correct
11 Correct 2 ms 1508 KB Output is correct
12 Correct 2 ms 1484 KB Output is correct
13 Correct 2 ms 1528 KB Output is correct
14 Correct 1 ms 1484 KB Output is correct
15 Correct 1 ms 1484 KB Output is correct
16 Correct 2 ms 1508 KB Output is correct
17 Correct 1 ms 1484 KB Output is correct
18 Correct 1 ms 1484 KB Output is correct
19 Correct 1 ms 1508 KB Output is correct
20 Correct 2 ms 1524 KB Output is correct
21 Correct 2 ms 1484 KB Output is correct
22 Correct 3 ms 1484 KB Output is correct
23 Correct 2 ms 1484 KB Output is correct
24 Correct 2 ms 1484 KB Output is correct
25 Correct 1 ms 1484 KB Output is correct
26 Correct 153 ms 10472 KB Output is correct
27 Correct 155 ms 10588 KB Output is correct
28 Correct 136 ms 8888 KB Output is correct
29 Correct 144 ms 10300 KB Output is correct
30 Correct 128 ms 9152 KB Output is correct
31 Correct 141 ms 9152 KB Output is correct
32 Correct 145 ms 10564 KB Output is correct
33 Correct 159 ms 10592 KB Output is correct
34 Correct 146 ms 10548 KB Output is correct
35 Correct 151 ms 10552 KB Output is correct