Submission #66318835
Source Code Expand
Copy
#include <bits/stdc++.h>using namespace std;int main() {ios::sync_with_stdio(false);cin.tie(nullptr);int N, M;cin >> N >> M;vector<vector<pair<int,int>>> adj(N + 1);for (int i = 0; i < M; i++) {int u, v, w;cin >> u >> v >> w;adj[u].emplace_back(v, w);adj[v].emplace_back(u, w);}int ban = 0;vector<char> visited(N + 1);for (int k = 29; k >= 0; k--) {int temp_ban = ban | (1 << k);fill(visited.begin(), visited.end(), 0);vector<int> stk;
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int N, M;
cin >> N >> M;
vector<vector<pair<int,int>>> adj(N + 1);
for (int i = 0; i < M; i++) {
int u, v, w;
cin >> u >> v >> w;
adj[u].emplace_back(v, w);
adj[v].emplace_back(u, w);
}
int ban = 0;
vector<char> visited(N + 1);
for (int k = 29; k >= 0; k--) {
int temp_ban = ban | (1 << k);
fill(visited.begin(), visited.end(), 0);
vector<int> stk;
stk.reserve(N);
visited[1] = 1;
stk.push_back(1);
while (!stk.empty()) {
int v = stk.back();
stk.pop_back();
for (auto &p : adj[v]) {
int u = p.first;
int w = p.second;
if (!visited[u] && ((w & temp_ban) == 0)) {
visited[u] = 1;
stk.push_back(u);
}
}
}
if (visited[N]) {
ban = temp_ban;
}
}
int ans = 0;
for (int k = 0; k < 30; k++) {
if ((ban & (1 << k)) == 0) {
ans |= (1 << k);
}
}
cout << ans << "\n";
return 0;
}
Submission Info
| Submission Time | |
|---|---|
| Task | E - Minimum OR Path |
| User | OYU__0YU |
| Language | C++ 20 (gcc 12.2) |
| Score | 450 |
| Code Size | 1289 Byte |
| Status | AC |
| Exec Time | 1299 ms |
| Memory | 14432 KiB |
Judge Result
| Set Name | Sample | All | ||||
|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 450 / 450 | ||||
| Status |
|
|
| Set Name | Test Cases |
|---|---|
| Sample | 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt |
| All | 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 01_handmade_00.txt, 01_handmade_01.txt, 01_handmade_02.txt, 01_handmade_03.txt, 01_handmade_04.txt, 01_handmade_05.txt, 01_handmade_06.txt, 01_handmade_07.txt, 01_handmade_08.txt, 01_handmade_09.txt, 02_random_00.txt, 02_random_01.txt, 02_random_02.txt, 02_random_03.txt, 02_random_04.txt, 02_random_05.txt, 02_random_06.txt, 02_random_07.txt, 02_random_08.txt, 02_random_09.txt, 02_random_10.txt, 02_random_11.txt, 02_random_12.txt, 02_random_13.txt, 02_random_14.txt, 02_random_15.txt, 02_random_16.txt, 02_random_17.txt, 02_random_18.txt, 02_random_19.txt, 02_random_20.txt, 02_random_21.txt |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| 00_sample_00.txt | AC | 1 ms | 3540 KiB |
| 00_sample_01.txt | AC | 1 ms | 3464 KiB |
| 00_sample_02.txt | AC | 1 ms | 3352 KiB |
| 01_handmade_00.txt | AC | 1 ms | 3416 KiB |
| 01_handmade_01.txt | AC | 1 ms | 3412 KiB |
| 01_handmade_02.txt | AC | 32 ms | 6540 KiB |
| 01_handmade_03.txt | AC | 32 ms | 6500 KiB |
| 01_handmade_04.txt | AC | 1 ms | 3408 KiB |
| 01_handmade_05.txt | AC | 1 ms | 3608 KiB |
| 01_handmade_06.txt | AC | 1 ms | 3472 KiB |
| 01_handmade_07.txt | AC | 69 ms | 9860 KiB |
| 01_handmade_08.txt | AC | 71 ms | 9824 KiB |
| 01_handmade_09.txt | AC | 70 ms | 9776 KiB |
| 02_random_00.txt | AC | 45 ms | 10724 KiB |
| 02_random_01.txt | AC | 41 ms | 8932 KiB |
| 02_random_02.txt | AC | 27 ms | 6388 KiB |
| 02_random_03.txt | AC | 67 ms | 9960 KiB |
| 02_random_04.txt | AC | 69 ms | 10040 KiB |
| 02_random_05.txt | AC | 50 ms | 9292 KiB |
| 02_random_06.txt | AC | 58 ms | 9132 KiB |
| 02_random_07.txt | AC | 82 ms | 11788 KiB |
| 02_random_08.txt | AC | 79 ms | 13440 KiB |
| 02_random_09.txt | AC | 48 ms | 10264 KiB |
| 02_random_10.txt | AC | 86 ms | 12072 KiB |
| 02_random_11.txt | AC | 442 ms | 12536 KiB |
| 02_random_12.txt | AC | 92 ms | 11204 KiB |
| 02_random_13.txt | AC | 258 ms | 13912 KiB |
| 02_random_14.txt | AC | 391 ms | 13432 KiB |
| 02_random_15.txt | AC | 48 ms | 8124 KiB |
| 02_random_16.txt | AC | 44 ms | 9888 KiB |
| 02_random_17.txt | AC | 673 ms | 9984 KiB |
| 02_random_18.txt | AC | 333 ms | 9932 KiB |
| 02_random_19.txt | AC | 86 ms | 14272 KiB |
| 02_random_20.txt | AC | 1299 ms | 14264 KiB |
| 02_random_21.txt | AC | 610 ms | 14432 KiB |