# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1102999 |
2024-10-19T10:36:42 Z |
THXuan |
Drivers (BOI24_drivers) |
C++14 |
|
2000 ms |
19024 KB |
#include <iostream>
#include <vector>
#include <algorithm>
#include <array>
#include <queue>
#include <set>
#include <map>
#define INF 1e9
using namespace std;
typedef long long ll;
vector<array<ll, 4>>q(200005);
ll link[200005];
ll sz[200005];
ll find(ll x) {
while (x != link[x]) x = link[x];
return x;
}
void unite(ll a, ll b) {
a = find(a);
b = find(b);
if (sz[a] < sz[b]) swap(a, b);
sz[a] += sz[b];
link[b] = a;
}
void solve()
{
int n, m, u; cin >> n >> m >> u;
for (int i = 1; i <= n; i++) {
link[i] = i; sz[i] = 1;
}
vector<pair<ll, pair<int, int>>>edges(m);
vector<string>ans(u);
for (int i = 0; i < m; i++) {
cin >> edges[i].second.first >> edges[i].second.second >> edges[i].first;
}
for (int i = 0; i < u; i++) {
cin >> q[i][1] >> q[i][2] >> q[i][0];
q[i][3] = i;
}
sort(edges.begin(), edges.end());
sort(q.begin(), q.begin() + u);
int j = 0;
for (int i = 0; i < u; i++) {
while (j < m && edges[j].first <= q[i][0]) {
unite(edges[j].second.first, edges[j].second.second);
++j;
}
if (find(q[i][1]) == find(q[i][2])) {
ans[q[i][3]] = "TAIP";
}
else ans[q[i][3]] = "NE";
}
for (int i = 0; i < u; i++) {
cout << ans[i] << "\n";
}
}
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
int t = 1;// cin>>t;
while (t--) solve();
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
8528 KB |
Output is correct |
2 |
Correct |
3 ms |
8784 KB |
Output is correct |
3 |
Correct |
3 ms |
8784 KB |
Output is correct |
4 |
Correct |
2 ms |
8528 KB |
Output is correct |
5 |
Correct |
438 ms |
15788 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
8528 KB |
Output is correct |
2 |
Correct |
1 ms |
8528 KB |
Output is correct |
3 |
Correct |
3 ms |
8784 KB |
Output is correct |
4 |
Correct |
3 ms |
8788 KB |
Output is correct |
5 |
Correct |
2 ms |
8952 KB |
Output is correct |
6 |
Correct |
2 ms |
8784 KB |
Output is correct |
7 |
Correct |
3 ms |
9040 KB |
Output is correct |
8 |
Correct |
3 ms |
8792 KB |
Output is correct |
9 |
Correct |
3 ms |
8784 KB |
Output is correct |
10 |
Correct |
4 ms |
8784 KB |
Output is correct |
11 |
Correct |
4 ms |
8784 KB |
Output is correct |
12 |
Correct |
6 ms |
8784 KB |
Output is correct |
13 |
Correct |
3 ms |
8952 KB |
Output is correct |
14 |
Correct |
4 ms |
9040 KB |
Output is correct |
15 |
Correct |
2 ms |
8528 KB |
Output is correct |
16 |
Correct |
2 ms |
8528 KB |
Output is correct |
17 |
Correct |
2 ms |
8536 KB |
Output is correct |
18 |
Correct |
3 ms |
8784 KB |
Output is correct |
19 |
Correct |
7 ms |
9304 KB |
Output is correct |
20 |
Correct |
2 ms |
8528 KB |
Output is correct |
21 |
Correct |
2 ms |
8528 KB |
Output is correct |
22 |
Correct |
2 ms |
8784 KB |
Output is correct |
23 |
Correct |
2 ms |
8952 KB |
Output is correct |
24 |
Correct |
5 ms |
9296 KB |
Output is correct |
25 |
Correct |
2 ms |
8528 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
8528 KB |
Output is correct |
2 |
Correct |
3 ms |
8784 KB |
Output is correct |
3 |
Correct |
3 ms |
8784 KB |
Output is correct |
4 |
Correct |
2 ms |
8528 KB |
Output is correct |
5 |
Correct |
438 ms |
15788 KB |
Output is correct |
6 |
Correct |
2 ms |
8528 KB |
Output is correct |
7 |
Correct |
3 ms |
8784 KB |
Output is correct |
8 |
Correct |
3 ms |
8784 KB |
Output is correct |
9 |
Correct |
4 ms |
8784 KB |
Output is correct |
10 |
Correct |
5 ms |
9048 KB |
Output is correct |
11 |
Correct |
4 ms |
9040 KB |
Output is correct |
12 |
Correct |
2 ms |
8784 KB |
Output is correct |
13 |
Correct |
2 ms |
8528 KB |
Output is correct |
14 |
Correct |
2 ms |
8528 KB |
Output is correct |
15 |
Correct |
1 ms |
8528 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
8528 KB |
Output is correct |
2 |
Correct |
3 ms |
8784 KB |
Output is correct |
3 |
Correct |
3 ms |
8784 KB |
Output is correct |
4 |
Correct |
2 ms |
8528 KB |
Output is correct |
5 |
Correct |
438 ms |
15788 KB |
Output is correct |
6 |
Correct |
2 ms |
8528 KB |
Output is correct |
7 |
Correct |
1 ms |
8528 KB |
Output is correct |
8 |
Correct |
3 ms |
8784 KB |
Output is correct |
9 |
Correct |
3 ms |
8788 KB |
Output is correct |
10 |
Correct |
2 ms |
8952 KB |
Output is correct |
11 |
Correct |
2 ms |
8784 KB |
Output is correct |
12 |
Correct |
3 ms |
9040 KB |
Output is correct |
13 |
Correct |
3 ms |
8792 KB |
Output is correct |
14 |
Correct |
3 ms |
8784 KB |
Output is correct |
15 |
Correct |
4 ms |
8784 KB |
Output is correct |
16 |
Correct |
4 ms |
8784 KB |
Output is correct |
17 |
Correct |
6 ms |
8784 KB |
Output is correct |
18 |
Correct |
3 ms |
8952 KB |
Output is correct |
19 |
Correct |
4 ms |
9040 KB |
Output is correct |
20 |
Correct |
2 ms |
8528 KB |
Output is correct |
21 |
Correct |
2 ms |
8528 KB |
Output is correct |
22 |
Correct |
2 ms |
8536 KB |
Output is correct |
23 |
Correct |
3 ms |
8784 KB |
Output is correct |
24 |
Correct |
7 ms |
9304 KB |
Output is correct |
25 |
Correct |
2 ms |
8528 KB |
Output is correct |
26 |
Correct |
2 ms |
8528 KB |
Output is correct |
27 |
Correct |
2 ms |
8784 KB |
Output is correct |
28 |
Correct |
2 ms |
8952 KB |
Output is correct |
29 |
Correct |
5 ms |
9296 KB |
Output is correct |
30 |
Correct |
2 ms |
8528 KB |
Output is correct |
31 |
Correct |
2 ms |
8528 KB |
Output is correct |
32 |
Correct |
3 ms |
8784 KB |
Output is correct |
33 |
Correct |
3 ms |
8784 KB |
Output is correct |
34 |
Correct |
4 ms |
8784 KB |
Output is correct |
35 |
Correct |
5 ms |
9048 KB |
Output is correct |
36 |
Correct |
4 ms |
9040 KB |
Output is correct |
37 |
Correct |
2 ms |
8784 KB |
Output is correct |
38 |
Correct |
2 ms |
8528 KB |
Output is correct |
39 |
Correct |
2 ms |
8528 KB |
Output is correct |
40 |
Correct |
1 ms |
8528 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
8528 KB |
Output is correct |
2 |
Correct |
3 ms |
8784 KB |
Output is correct |
3 |
Correct |
3 ms |
8784 KB |
Output is correct |
4 |
Correct |
2 ms |
8528 KB |
Output is correct |
5 |
Correct |
438 ms |
15788 KB |
Output is correct |
6 |
Correct |
2 ms |
8528 KB |
Output is correct |
7 |
Correct |
1 ms |
8528 KB |
Output is correct |
8 |
Correct |
3 ms |
8784 KB |
Output is correct |
9 |
Correct |
3 ms |
8788 KB |
Output is correct |
10 |
Correct |
2 ms |
8952 KB |
Output is correct |
11 |
Correct |
2 ms |
8784 KB |
Output is correct |
12 |
Correct |
3 ms |
9040 KB |
Output is correct |
13 |
Correct |
3 ms |
8792 KB |
Output is correct |
14 |
Correct |
3 ms |
8784 KB |
Output is correct |
15 |
Correct |
4 ms |
8784 KB |
Output is correct |
16 |
Correct |
4 ms |
8784 KB |
Output is correct |
17 |
Correct |
6 ms |
8784 KB |
Output is correct |
18 |
Correct |
3 ms |
8952 KB |
Output is correct |
19 |
Correct |
4 ms |
9040 KB |
Output is correct |
20 |
Correct |
2 ms |
8528 KB |
Output is correct |
21 |
Correct |
2 ms |
8528 KB |
Output is correct |
22 |
Correct |
2 ms |
8536 KB |
Output is correct |
23 |
Correct |
3 ms |
8784 KB |
Output is correct |
24 |
Correct |
7 ms |
9304 KB |
Output is correct |
25 |
Correct |
2 ms |
8528 KB |
Output is correct |
26 |
Correct |
2 ms |
8528 KB |
Output is correct |
27 |
Correct |
2 ms |
8784 KB |
Output is correct |
28 |
Correct |
2 ms |
8952 KB |
Output is correct |
29 |
Correct |
5 ms |
9296 KB |
Output is correct |
30 |
Correct |
2 ms |
8528 KB |
Output is correct |
31 |
Correct |
2 ms |
8528 KB |
Output is correct |
32 |
Correct |
3 ms |
8784 KB |
Output is correct |
33 |
Correct |
3 ms |
8784 KB |
Output is correct |
34 |
Correct |
4 ms |
8784 KB |
Output is correct |
35 |
Correct |
5 ms |
9048 KB |
Output is correct |
36 |
Correct |
4 ms |
9040 KB |
Output is correct |
37 |
Correct |
2 ms |
8784 KB |
Output is correct |
38 |
Correct |
2 ms |
8528 KB |
Output is correct |
39 |
Correct |
2 ms |
8528 KB |
Output is correct |
40 |
Correct |
1 ms |
8528 KB |
Output is correct |
41 |
Execution timed out |
2057 ms |
19024 KB |
Time limit exceeded |
42 |
Halted |
0 ms |
0 KB |
- |