結果
| 問題 | No.3482 Quod Erat Demonstrandum |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-03-28 13:48:27 |
| 言語 | C++23 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,495 bytes |
| 記録 | |
| コンパイル時間 | 2,483 ms |
| コンパイル使用メモリ | 345,028 KB |
| 実行使用メモリ | 25,416 KB |
| 最終ジャッジ日時 | 2026-03-28 13:48:47 |
| 合計ジャッジ時間 | 7,907 ms |
|
ジャッジサーバーID (参考情報) |
judge1_1 / judge2_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<pair<int,int>> dis;
vector<vector<pair<int,int>>> g;
void bfs(int st,int en)
{
queue<pair<int,int>> qu;
qu.push({st,0});
dis[st] = {0,0};
while (!qu.empty())
{
pair<int,int> curr = qu.front();qu.pop();
if (vis[curr.first]) continue;
vis[curr.first] = 1;
for (auto v : g[curr.first])
{
if (dis[v.first].second>dis[curr.first].second+v.second)
{
dis[v.first].first = dis[curr.first].first+1;
dis[v.first].second = dis[curr.first].second+v.second;
qu.push({v.first,v.second+curr.second});
}
}
}
}
void solve()
{
g.clear();
dis.clear();
vis.clear();
int n,m;cin>>n>>m;
g.resize(n+1);
dis.assign(n+1,{INF,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});
}
bfs(1,n);
if (dis[n].second>1) cout << "Unknown" << endl;
else if (dis[n].second==1)
{
cout << "Different" << endl;
cout << dis[n].first << endl;
}
else if (dis[n].second==0)
{
cout << "Same" << endl;
cout << dis[n].first << endl;
}
}
signed main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
int t;cin>>t;while(t--)
solve();
}