結果
| 問題 | No.3482 Quod Erat Demonstrandum |
| コンテスト | |
| ユーザー |
joijoy
|
| 提出日時 | 2026-03-27 21:30:06 |
| 言語 | C++23 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 2,300 bytes |
| 記録 | |
| コンパイル時間 | 2,825 ms |
| コンパイル使用メモリ | 349,204 KB |
| 実行使用メモリ | 18,352 KB |
| 最終ジャッジ日時 | 2026-03-27 21:30:29 |
| 合計ジャッジ時間 | 17,246 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge1_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | WA * 1 |
| other | AC * 26 WA * 19 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
# pragma GCC target("avx2")
# pragma GCC optimize("O3")
# pragma GCC optimize("unroll-loops")
using ll=long long;
using current=pair<int, pair<int, int>>;
int nibutan(int n, vector<int> A, int key){
int ok=n;
int ng=-1;
while(ok-ng>1){
int mid=(ok+ng)/2;
if(A[mid]>key){
ok=mid;
}else{
ng=mid;
}
}
return ok;
}
void update(int i, int n, int x, vector<int> &data){
i+=n-1;
data[i]= x;
while(i>1){
i/=2;
data[i]=max(data[i*2], data[i*2+1]);
}
}
int get(int n, int l, int r, vector<int> &data){
int res=0;
l+=n-1;
r+=n-1;
while(r>l){
if(l&1){
res=max(data[l], res);
l++;
}
l>>=1;
if(r&1){
r--;
res=max(res, data[r]);
}
r>>=1;
}
return res;
}
int main(){
int T;
cin >> T;
for(int o=0;o<T;o++){
int N, M;
cin >> N >> M;
vector<vector<pair<int, int>>> G(N+1);
for(int i=0;i<M;i++){
int a, b, c;
cin >> a >> b >> c;
G[a].push_back({b, c});
G[b].push_back({a, c});
}
vector<int> res(N+1, 0), dist(N+1, -1);
vector<bool> seen(N+1, false);
queue<int> q;
res[1]=1;
dist[1]=0;
seen[1]=true;
q.push(1);
while(!q.empty()){
int p=q.front();
for(pair<int, int> r:G[p]){
int nex=r.first;
int c=r.second;
if(seen[nex]){
continue;
}
seen[nex]=true;
if(c==1){
res[nex]=res[p];
}else{
res[nex]=3-res[p];
}
dist[nex]=dist[p]+1;
q.push(nex);
}
q.pop();
}
if(res[N]==0){
cout << "Unknown" << endl;
continue;
}
if(res[N]==1){
cout << "Same";
}else{
cout << "Opposite";
}
cout << endl;
cout << dist[N] << endl;
}
}
joijoy