結果
| 問題 | No.3482 Quod Erat Demonstrandum |
| コンテスト | |
| ユーザー |
hiromi_ayase
|
| 提出日時 | 2026-03-27 21:36:52 |
| 言語 | C++23 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,408 bytes |
| 記録 | |
| コンパイル時間 | 4,452 ms |
| コンパイル使用メモリ | 380,884 KB |
| 実行使用メモリ | 21,368 KB |
| 最終ジャッジ日時 | 2026-03-27 21:37:59 |
| 合計ジャッジ時間 | 10,761 ms |
|
ジャッジサーバーID (参考情報) |
judge2_1 / judge3_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 35 WA * 10 |
ソースコード
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using i32 = int;
using u32 = unsigned int;
using i64 = long long;
using u64 = unsigned long long;
#define FAST_IO \
ios::sync_with_stdio(false); \
cin.tie(0);
const i64 INF = 1001001001001001001;
using Modint = atcoder::static_modint<998244353>;
int main() {
FAST_IO
int T;
cin >> T;
while (T--) {
int N, M;
cin >> N >> M;
vector<int> A(M), B(M), C(M);
for (int i = 0; i < M; i++) {
cin >> A[i] >> B[i] >> C[i];
A[i]--;
B[i]--;
}
vector<vector<pair<int, int>>> G(N);
for (int i = 0; i < M; i ++) {
G[A[i]].push_back({B[i], C[i]});
G[B[i]].push_back({A[i], C[i]});
}
vector<int> ved(N, 0);
vector<i64> d(N, INF);
deque<int> q;
q.push_back(0);
ved[0] = 1;
d[0] = 0;
while (q.size() > 0) {
auto cur = q.front();
q.pop_front();
for (auto [nex, c] : G[cur]) {
if (ved[nex] != 0) continue;
if (d[nex] < d[cur] + 1) continue;
d[nex] = d[cur] + 1;
ved[nex] = c == 1 ? ved[cur] : -ved[cur];
q.push_back(nex);
}
}
if (ved[N-1] == 0) {
cout << "Unknown" << endl;
} else if (ved[N-1] == 1) {
cout << "Same" << endl;
cout << d[N-1] << endl;
} else {
cout << "Different" << endl;
cout << d[N-1] << endl;
}
}
}
hiromi_ayase