Submission #66732193
Source Code Expand
#include<bits/stdc++.h>
namespace {
#pragma GCC diagnostic ignored "-Wunused-function"
#include<atcoder/all>
#pragma GCC diagnostic warning "-Wunused-function"
using namespace std;
using namespace atcoder;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(i,n) for(int i = (int)(n) - 1; i >= 0; i--)
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
template<class T> bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }
template<class T> bool chmin(T& a, const T& b) { if (b < a) { a = b; return true; } else return false; }
using ll = long long;
using P = pair<int,int>;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<ll>;
using VVL = vector<VL>;
bool visited[1000][1 << 10];
} int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int n, m;
cin >> n >> m;
vector<vector<P>> to(n);
rep(_, m) {
int a, b, w;
cin >> a >> b >> w;
a--, b--;
to[a].emplace_back(b, w);
}
vector<P> todo;
visited[0][0] = true;
todo.emplace_back(0, 0);
while (todo.size()) {
auto [u, b] = todo.back(); todo.pop_back();
for (auto [v, w] : to[u]) {
int nb = b ^ w;
if (!visited[v][nb]) {
visited[v][nb] = true;
todo.emplace_back(v, nb);
}
}
}
int ans = -1;
rep(b, 1 << 10) if (visited[n-1][b]) {
ans = b;
break;
}
cout << ans << '\n';
}
Submission Info
| Submission Time | |
|---|---|
| Task | D - XOR Shortest Walk |
| User | Kude |
| Language | C++ 20 (gcc 12.2) |
| Score | 400 |
| Code Size | 1452 Byte |
| Status | AC |
| Exec Time | 8 ms |
| Memory | 4620 KiB |
Judge Result
| Set Name | Sample | All | ||||
|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 400 / 400 | ||||
| Status |
|
|
| Set Name | Test Cases |
|---|---|
| Sample | sample_01.txt, sample_02.txt, sample_03.txt |
| All | hand_01.txt, hand_02.txt, hand_03.txt, hand_04.txt, hand_05.txt, hand_06.txt, hand_07.txt, hand_08.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, random_18.txt, random_19.txt, random_20.txt, random_21.txt, random_22.txt, sample_01.txt, sample_02.txt, sample_03.txt |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| hand_01.txt | AC | 1 ms | 3496 KiB |
| hand_02.txt | AC | 1 ms | 3632 KiB |
| hand_03.txt | AC | 1 ms | 3492 KiB |
| hand_04.txt | AC | 1 ms | 3496 KiB |
| hand_05.txt | AC | 1 ms | 3412 KiB |
| hand_06.txt | AC | 1 ms | 3428 KiB |
| hand_07.txt | AC | 1 ms | 3416 KiB |
| hand_08.txt | AC | 1 ms | 3504 KiB |
| random_01.txt | AC | 1 ms | 3440 KiB |
| random_02.txt | AC | 2 ms | 4192 KiB |
| random_03.txt | AC | 1 ms | 3556 KiB |
| random_04.txt | AC | 1 ms | 3916 KiB |
| random_05.txt | AC | 1 ms | 3516 KiB |
| random_06.txt | AC | 1 ms | 3644 KiB |
| random_07.txt | AC | 1 ms | 3480 KiB |
| random_08.txt | AC | 1 ms | 4004 KiB |
| random_09.txt | AC | 1 ms | 3516 KiB |
| random_10.txt | AC | 2 ms | 4312 KiB |
| random_11.txt | AC | 1 ms | 3500 KiB |
| random_12.txt | AC | 2 ms | 4072 KiB |
| random_13.txt | AC | 2 ms | 3808 KiB |
| random_14.txt | AC | 4 ms | 3956 KiB |
| random_15.txt | AC | 2 ms | 3648 KiB |
| random_16.txt | AC | 1 ms | 3568 KiB |
| random_17.txt | AC | 2 ms | 4616 KiB |
| random_18.txt | AC | 2 ms | 4620 KiB |
| random_19.txt | AC | 8 ms | 4548 KiB |
| random_20.txt | AC | 4 ms | 4116 KiB |
| random_21.txt | AC | 5 ms | 4104 KiB |
| random_22.txt | AC | 4 ms | 4144 KiB |
| sample_01.txt | AC | 1 ms | 3492 KiB |
| sample_02.txt | AC | 1 ms | 3556 KiB |
| sample_03.txt | AC | 1 ms | 3376 KiB |