답안 #1111359

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1111359 2024-11-12T07:36:35 Z yhkhoo Drivers (BOI24_drivers) C++17
100 / 100
127 ms 7752 KB
#include <bits/stdc++.h>
using namespace std;

typedef pair<int, int> pii;
typedef pair<int, pii> pip;
typedef pair<pii, pii> ppp;
#define fi first
#define se second

const int MAXN = 200005;
int p[MAXN];
int get_parent(int x){
	if(p[x] == x) return x;
	p[x] = get_parent(p[x]);
	return p[x];
}
void union_set(int u, int v){
	u = get_parent(u);
	v = get_parent(v);
	if(u==v) return;
	p[u] = v;
}

int main(){
	cin.tie(0); ios_base::sync_with_stdio(0);
	int n, m, u;
	cin >> n >> m >> u;
	deque<pip> r;
	for(int i=0; i<m; i++){
		pip tmp;
		cin >> tmp.se.fi >> tmp.se.se >> tmp.fi;
		r.push_back(tmp);
	}
	sort(r.begin(), r.end());
	deque<ppp> c;
	for(int i=0; i<u; i++){
		ppp tmp;
		cin >> tmp.se.fi >> tmp.se.se >> tmp.fi.fi;
		tmp.fi.se = i;
		c.push_back(tmp);
	}
	sort(c.begin(), c.end());
	for(int i=1; i<=n; i++){
		p[i] = i;
	}
	vector<bool> ans(u, 0);
	for(auto i: c){
		while(r.size() && r.front().fi <= i.fi.fi){
			union_set(r.front().se.fi, r.front().se.se);
			r.pop_front();
		}
		ans[i.fi.se] = get_parent(i.se.fi) == get_parent(i.se.se);
	}
	for(auto i: ans){
		if(i){
			cout << "TAIP\n";
		}
		else{
			cout << "NE\n";
		}
	}
	return 0;
}
		
		
	
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 2 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 59 ms 4692 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 504 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 500 KB Output is correct
8 Correct 2 ms 336 KB Output is correct
9 Correct 2 ms 336 KB Output is correct
10 Correct 2 ms 336 KB Output is correct
11 Correct 2 ms 336 KB Output is correct
12 Correct 3 ms 592 KB Output is correct
13 Correct 2 ms 336 KB Output is correct
14 Correct 3 ms 592 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 1 ms 336 KB Output is correct
17 Correct 1 ms 336 KB Output is correct
18 Correct 2 ms 336 KB Output is correct
19 Correct 6 ms 808 KB Output is correct
20 Correct 1 ms 336 KB Output is correct
21 Correct 1 ms 336 KB Output is correct
22 Correct 1 ms 336 KB Output is correct
23 Correct 1 ms 336 KB Output is correct
24 Correct 5 ms 592 KB Output is correct
25 Correct 1 ms 336 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 2 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 59 ms 4692 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 2 ms 336 KB Output is correct
8 Correct 2 ms 336 KB Output is correct
9 Correct 2 ms 548 KB Output is correct
10 Correct 3 ms 592 KB Output is correct
11 Correct 3 ms 592 KB Output is correct
12 Correct 2 ms 336 KB Output is correct
13 Correct 1 ms 336 KB Output is correct
14 Correct 1 ms 336 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 2 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 59 ms 4692 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 504 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 1 ms 500 KB Output is correct
13 Correct 2 ms 336 KB Output is correct
14 Correct 2 ms 336 KB Output is correct
15 Correct 2 ms 336 KB Output is correct
16 Correct 2 ms 336 KB Output is correct
17 Correct 3 ms 592 KB Output is correct
18 Correct 2 ms 336 KB Output is correct
19 Correct 3 ms 592 KB Output is correct
20 Correct 1 ms 336 KB Output is correct
21 Correct 1 ms 336 KB Output is correct
22 Correct 1 ms 336 KB Output is correct
23 Correct 2 ms 336 KB Output is correct
24 Correct 6 ms 808 KB Output is correct
25 Correct 1 ms 336 KB Output is correct
26 Correct 1 ms 336 KB Output is correct
27 Correct 1 ms 336 KB Output is correct
28 Correct 1 ms 336 KB Output is correct
29 Correct 5 ms 592 KB Output is correct
30 Correct 1 ms 336 KB Output is correct
31 Correct 1 ms 336 KB Output is correct
32 Correct 2 ms 336 KB Output is correct
33 Correct 2 ms 336 KB Output is correct
34 Correct 2 ms 548 KB Output is correct
35 Correct 3 ms 592 KB Output is correct
36 Correct 3 ms 592 KB Output is correct
37 Correct 2 ms 336 KB Output is correct
38 Correct 1 ms 336 KB Output is correct
39 Correct 1 ms 336 KB Output is correct
40 Correct 1 ms 336 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 2 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 59 ms 4692 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 504 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 1 ms 500 KB Output is correct
13 Correct 2 ms 336 KB Output is correct
14 Correct 2 ms 336 KB Output is correct
15 Correct 2 ms 336 KB Output is correct
16 Correct 2 ms 336 KB Output is correct
17 Correct 3 ms 592 KB Output is correct
18 Correct 2 ms 336 KB Output is correct
19 Correct 3 ms 592 KB Output is correct
20 Correct 1 ms 336 KB Output is correct
21 Correct 1 ms 336 KB Output is correct
22 Correct 1 ms 336 KB Output is correct
23 Correct 2 ms 336 KB Output is correct
24 Correct 6 ms 808 KB Output is correct
25 Correct 1 ms 336 KB Output is correct
26 Correct 1 ms 336 KB Output is correct
27 Correct 1 ms 336 KB Output is correct
28 Correct 1 ms 336 KB Output is correct
29 Correct 5 ms 592 KB Output is correct
30 Correct 1 ms 336 KB Output is correct
31 Correct 1 ms 336 KB Output is correct
32 Correct 2 ms 336 KB Output is correct
33 Correct 2 ms 336 KB Output is correct
34 Correct 2 ms 548 KB Output is correct
35 Correct 3 ms 592 KB Output is correct
36 Correct 3 ms 592 KB Output is correct
37 Correct 2 ms 336 KB Output is correct
38 Correct 1 ms 336 KB Output is correct
39 Correct 1 ms 336 KB Output is correct
40 Correct 1 ms 336 KB Output is correct
41 Correct 127 ms 7496 KB Output is correct
42 Correct 9 ms 848 KB Output is correct
43 Correct 9 ms 848 KB Output is correct
44 Correct 14 ms 984 KB Output is correct
45 Correct 11 ms 848 KB Output is correct
46 Correct 7 ms 848 KB Output is correct
47 Correct 93 ms 5704 KB Output is correct
48 Correct 12 ms 848 KB Output is correct
49 Correct 83 ms 7752 KB Output is correct