結果
| 問題 | No.3482 Quod Erat Demonstrandum |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-04-10 11:39:49 |
| 言語 | C++23 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,112 bytes |
| 記録 | |
| コンパイル時間 | 2,885 ms |
| コンパイル使用メモリ | 341,412 KB |
| 実行使用メモリ | 18,992 KB |
| 最終ジャッジ日時 | 2026-04-10 11:40:05 |
| 合計ジャッジ時間 | 11,231 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge1_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 42 WA * 3 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
int main(void){
int t;
cin>>t;
while(t--){
int n,m;
cin>>n>>m;
vector<pair<int,int>>v[n];
for(int i=0;i<m;i++){
int a,b,c;
cin>>a>>b>>c;
v[a-1].push_back({b-1,2-c});
v[b-1].push_back({a-1,2-c});
}
vector<pair<int,pair<int,int>>>vis(n,{-1,{-1,0}});
vis[0]={0,{0,0}};
queue<int>q;
q.push(0);
while(!q.empty()){
int now=q.front();
q.pop();
for(int i=0;i<v[now].size();i++){
if(vis[v[now][i].first].first==-1&&(!(v[now][i].second==0&&vis[now].second.second==1))){
vis[v[now][i].first]={vis[now].first+1,{!(vis[now].second.first^v[now][i].second),!v[now][i].second}};
q.push(v[now][i].first);
}
}
}
if(vis[n-1].first==-1){
cout<<"Unknown"<<endl;
}else{
cout<<(vis[n-1].second.first?"Different":"Same")<<endl<<vis[n-1].first<<endl;
}
}
return 0;
}