# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1085878 | 2024-09-08T23:51:03 Z | anastasiskolio | Drivers (BOI24_drivers) | C++14 | 158 ms | 21548 KB |
#include <bits/stdc++.h> #define MAXN 200000 #define MAXM 200000 #define MAXU 200000 using namespace std; vector<array<int, 3>> edges(MAXM); vector<array<int, 4>> queries(MAXU); vector<int> parent(MAXN), comp_size(MAXN); vector<string> ans(MAXU); int N, M, U; void disjointSets() { for (int a = 0; a < N; a++) { parent[a] = a; comp_size[a] = 1; } } int find(int a) { return a == parent[a] ? a : parent[a] = find(parent[a]); } void unite(int a, int b) { a = find(a); b = find(b); if (a != b) { if (comp_size[a] < comp_size[b]) swap(a, b); parent[b] = a; comp_size[a] += comp_size[b]; } } int main() { scanf("%d %d %d", &N, &M, &U); for (int i = 0; i < M; i++) { scanf("%d %d %d", &edges[i][1], &edges[i][2], &edges[i][0]); --edges[i][1]; --edges[i][2]; } for (int i = 0; i < U; i++) { scanf("%d %d %d", &queries[i][1], &queries[i][2], &queries[i][0]); --queries[i][1]; --queries[i][2]; queries[i][3] = i; } sort(edges.begin(), edges.begin() + M); sort(queries.begin(), queries.begin() + U); disjointSets(); int j = 0; for (int i = 0; i < U; i++) { while (j < M && edges[j][0] <= queries[i][0]) { unite(edges[j][1], edges[j][2]); ++j; } ans[queries[i][3]] = find(queries[i][1]) == find(queries[i][2]) ? "TAIP" : "NE"; } for (int i = 0; i < U; i++) printf("%s\n", ans[i].c_str()); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 13660 KB | Output is correct |
2 | Correct | 7 ms | 13660 KB | Output is correct |
3 | Correct | 6 ms | 13660 KB | Output is correct |
4 | Correct | 6 ms | 13600 KB | Output is correct |
5 | Correct | 83 ms | 16756 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 13656 KB | Output is correct |
2 | Correct | 6 ms | 13660 KB | Output is correct |
3 | Correct | 6 ms | 13636 KB | Output is correct |
4 | Correct | 6 ms | 13660 KB | Output is correct |
5 | Correct | 6 ms | 13712 KB | Output is correct |
6 | Correct | 6 ms | 13660 KB | Output is correct |
7 | Correct | 6 ms | 13688 KB | Output is correct |
8 | Correct | 7 ms | 13660 KB | Output is correct |
9 | Correct | 6 ms | 13660 KB | Output is correct |
10 | Correct | 6 ms | 13660 KB | Output is correct |
11 | Correct | 7 ms | 13816 KB | Output is correct |
12 | Correct | 8 ms | 13656 KB | Output is correct |
13 | Correct | 7 ms | 13660 KB | Output is correct |
14 | Correct | 8 ms | 13660 KB | Output is correct |
15 | Correct | 7 ms | 13736 KB | Output is correct |
16 | Correct | 6 ms | 13656 KB | Output is correct |
17 | Correct | 6 ms | 13660 KB | Output is correct |
18 | Correct | 6 ms | 13704 KB | Output is correct |
19 | Correct | 14 ms | 13916 KB | Output is correct |
20 | Correct | 9 ms | 13660 KB | Output is correct |
21 | Correct | 7 ms | 13660 KB | Output is correct |
22 | Correct | 6 ms | 13704 KB | Output is correct |
23 | Correct | 6 ms | 13660 KB | Output is correct |
24 | Correct | 10 ms | 14028 KB | Output is correct |
25 | Correct | 6 ms | 13660 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 13660 KB | Output is correct |
2 | Correct | 7 ms | 13660 KB | Output is correct |
3 | Correct | 6 ms | 13660 KB | Output is correct |
4 | Correct | 6 ms | 13600 KB | Output is correct |
5 | Correct | 83 ms | 16756 KB | Output is correct |
6 | Correct | 6 ms | 13660 KB | Output is correct |
7 | Correct | 7 ms | 13660 KB | Output is correct |
8 | Correct | 7 ms | 13716 KB | Output is correct |
9 | Correct | 7 ms | 13660 KB | Output is correct |
10 | Correct | 7 ms | 13660 KB | Output is correct |
11 | Correct | 8 ms | 13656 KB | Output is correct |
12 | Correct | 6 ms | 13660 KB | Output is correct |
13 | Correct | 5 ms | 13660 KB | Output is correct |
14 | Correct | 6 ms | 13632 KB | Output is correct |
15 | Correct | 6 ms | 13912 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 13660 KB | Output is correct |
2 | Correct | 7 ms | 13660 KB | Output is correct |
3 | Correct | 6 ms | 13660 KB | Output is correct |
4 | Correct | 6 ms | 13600 KB | Output is correct |
5 | Correct | 83 ms | 16756 KB | Output is correct |
6 | Correct | 6 ms | 13656 KB | Output is correct |
7 | Correct | 6 ms | 13660 KB | Output is correct |
8 | Correct | 6 ms | 13636 KB | Output is correct |
9 | Correct | 6 ms | 13660 KB | Output is correct |
10 | Correct | 6 ms | 13712 KB | Output is correct |
11 | Correct | 6 ms | 13660 KB | Output is correct |
12 | Correct | 6 ms | 13688 KB | Output is correct |
13 | Correct | 7 ms | 13660 KB | Output is correct |
14 | Correct | 6 ms | 13660 KB | Output is correct |
15 | Correct | 6 ms | 13660 KB | Output is correct |
16 | Correct | 7 ms | 13816 KB | Output is correct |
17 | Correct | 8 ms | 13656 KB | Output is correct |
18 | Correct | 7 ms | 13660 KB | Output is correct |
19 | Correct | 8 ms | 13660 KB | Output is correct |
20 | Correct | 7 ms | 13736 KB | Output is correct |
21 | Correct | 6 ms | 13656 KB | Output is correct |
22 | Correct | 6 ms | 13660 KB | Output is correct |
23 | Correct | 6 ms | 13704 KB | Output is correct |
24 | Correct | 14 ms | 13916 KB | Output is correct |
25 | Correct | 9 ms | 13660 KB | Output is correct |
26 | Correct | 7 ms | 13660 KB | Output is correct |
27 | Correct | 6 ms | 13704 KB | Output is correct |
28 | Correct | 6 ms | 13660 KB | Output is correct |
29 | Correct | 10 ms | 14028 KB | Output is correct |
30 | Correct | 6 ms | 13660 KB | Output is correct |
31 | Correct | 6 ms | 13660 KB | Output is correct |
32 | Correct | 7 ms | 13660 KB | Output is correct |
33 | Correct | 7 ms | 13716 KB | Output is correct |
34 | Correct | 7 ms | 13660 KB | Output is correct |
35 | Correct | 7 ms | 13660 KB | Output is correct |
36 | Correct | 8 ms | 13656 KB | Output is correct |
37 | Correct | 6 ms | 13660 KB | Output is correct |
38 | Correct | 5 ms | 13660 KB | Output is correct |
39 | Correct | 6 ms | 13632 KB | Output is correct |
40 | Correct | 6 ms | 13912 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 13660 KB | Output is correct |
2 | Correct | 7 ms | 13660 KB | Output is correct |
3 | Correct | 6 ms | 13660 KB | Output is correct |
4 | Correct | 6 ms | 13600 KB | Output is correct |
5 | Correct | 83 ms | 16756 KB | Output is correct |
6 | Correct | 6 ms | 13656 KB | Output is correct |
7 | Correct | 6 ms | 13660 KB | Output is correct |
8 | Correct | 6 ms | 13636 KB | Output is correct |
9 | Correct | 6 ms | 13660 KB | Output is correct |
10 | Correct | 6 ms | 13712 KB | Output is correct |
11 | Correct | 6 ms | 13660 KB | Output is correct |
12 | Correct | 6 ms | 13688 KB | Output is correct |
13 | Correct | 7 ms | 13660 KB | Output is correct |
14 | Correct | 6 ms | 13660 KB | Output is correct |
15 | Correct | 6 ms | 13660 KB | Output is correct |
16 | Correct | 7 ms | 13816 KB | Output is correct |
17 | Correct | 8 ms | 13656 KB | Output is correct |
18 | Correct | 7 ms | 13660 KB | Output is correct |
19 | Correct | 8 ms | 13660 KB | Output is correct |
20 | Correct | 7 ms | 13736 KB | Output is correct |
21 | Correct | 6 ms | 13656 KB | Output is correct |
22 | Correct | 6 ms | 13660 KB | Output is correct |
23 | Correct | 6 ms | 13704 KB | Output is correct |
24 | Correct | 14 ms | 13916 KB | Output is correct |
25 | Correct | 9 ms | 13660 KB | Output is correct |
26 | Correct | 7 ms | 13660 KB | Output is correct |
27 | Correct | 6 ms | 13704 KB | Output is correct |
28 | Correct | 6 ms | 13660 KB | Output is correct |
29 | Correct | 10 ms | 14028 KB | Output is correct |
30 | Correct | 6 ms | 13660 KB | Output is correct |
31 | Correct | 6 ms | 13660 KB | Output is correct |
32 | Correct | 7 ms | 13660 KB | Output is correct |
33 | Correct | 7 ms | 13716 KB | Output is correct |
34 | Correct | 7 ms | 13660 KB | Output is correct |
35 | Correct | 7 ms | 13660 KB | Output is correct |
36 | Correct | 8 ms | 13656 KB | Output is correct |
37 | Correct | 6 ms | 13660 KB | Output is correct |
38 | Correct | 5 ms | 13660 KB | Output is correct |
39 | Correct | 6 ms | 13632 KB | Output is correct |
40 | Correct | 6 ms | 13912 KB | Output is correct |
41 | Correct | 158 ms | 21548 KB | Output is correct |
42 | Correct | 16 ms | 14168 KB | Output is correct |
43 | Correct | 15 ms | 14172 KB | Output is correct |
44 | Correct | 18 ms | 14216 KB | Output is correct |
45 | Correct | 16 ms | 14172 KB | Output is correct |
46 | Correct | 13 ms | 14172 KB | Output is correct |
47 | Correct | 100 ms | 19540 KB | Output is correct |
48 | Correct | 14 ms | 14172 KB | Output is correct |
49 | Correct | 95 ms | 21156 KB | Output is correct |