結果

問題 No.3482 Quod Erat Demonstrandum
コンテスト
ユーザー yuunegi
提出日時 2026-04-10 11:29:57
言語 C++23
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=c++23 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
WA  
実行時間 -
コード長 1,010 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 5,514 ms
コンパイル使用メモリ 339,100 KB
実行使用メモリ 18,224 KB
最終ジャッジ日時 2026-04-10 11:30:18
合計ジャッジ時間 13,451 ms
ジャッジサーバーID
(参考情報)
judge2_1 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 35 WA * 10
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#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,int>>vis(n,{-1,-1});
        vis[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){
                    vis[v[now][i].first]={vis[now].first+1,!(vis[now].second^v[now][i].second)};
                    q.push(v[now][i].first);
                }
            }
        }
        if(vis[n-1].second==-1){
            cout<<"Unknown"<<endl;
        }else{
            cout<<(vis[n-1].second?"Different":"Same")<<endl<<vis[n-1].first<<endl;
        }
    }
    return 0;
}
0