結果
| 問題 | No.3482 Quod Erat Demonstrandum |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-03-28 13:39:23 |
| 言語 | C++23 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,431 bytes |
| 記録 | |
| コンパイル時間 | 2,418 ms |
| コンパイル使用メモリ | 344,380 KB |
| 実行使用メモリ | 24,160 KB |
| 最終ジャッジ日時 | 2026-03-28 13:39:30 |
| 合計ジャッジ時間 | 6,566 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge3_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 42 WA * 3 |
ソースコード
#include <bits/stdc++.h>
#define int long long
#define endl "\n"
using namespace std;
#define INF 1e9
vector<int> vis;
vector<int> dis;
vector<vector<pair<int,int>>> g;
int bfs(int st,int en)
{
queue<pair<int,int>> qu;
qu.push({st,0});
dis[st] = 0;
while (!qu.empty())
{
pair<int,int> curr = qu.front();qu.pop();
if (vis[curr.first]) continue;
vis[curr.first] = 1;
if (curr.first == en) return curr.second;
for (auto v : g[curr.first])
{
if (!vis[v.first] && dis[v.first]>dis[curr.first]+1)
{
dis[v.first] = dis[curr.first]+1;
qu.push({v.first,v.second+curr.second});
}
}
}
return -1;
}
void solve()
{
g.clear();
dis.clear();
vis.clear();
int n,m;cin>>n>>m;
g.resize(n+1);
dis.assign(n+1,INF);
vis.assign(n+1,0);
for (int i = 0; i < m; i++)
{
int x,y,z;cin>>x>>y>>z;
g[x].push_back({y,z-1});
g[y].push_back({x,z-1});
}
int dif = bfs(1,n);
if (dif==-1 || dif>1) cout << "Unknown" << endl;
else if (dif==1)
{
cout << "Different" << endl;
cout << dis[n] << endl;
}
else if (dif==0)
{
cout << "Same" << endl;
cout << dis[n] << endl;
}
}
signed main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
int t;cin>>t;while(t--)
solve();
}