結果
問題 | No.2674 k-Walk on Bipartite |
ユーザー |
![]() |
提出日時 | 2024-03-15 23:26:11 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 883 bytes |
コンパイル時間 | 1,863 ms |
コンパイル使用メモリ | 174,840 KB |
実行使用メモリ | 14,004 KB |
最終ジャッジ日時 | 2024-09-30 03:00:37 |
合計ジャッジ時間 | 5,926 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 WA * 1 RE * 1 |
other | AC * 14 WA * 12 RE * 10 |
ソースコード
/** * author: t9unkubj * created: 2024-03-15 */ #include<bits/stdc++.h> #ifdef t9unkubj #define _GLIBCXX_DEBUG #define dbg(x) cout<<__LINE__<<" "<<#x<<":="<<x<<endl; #else #define dbg(x) 58 #endif using namespace std; //#include<atcoder/all> //using namespace atcoder; int main(){ ios::sync_with_stdio(false); std::cin.tie(nullptr); int n,m; cin>>n>>m; int s,t,k; cin>>s>>t>>k; s--,t--; vector<vector<int>>g(n); for(int i=0;i<m;i++){ int a,b; cin>>a>>b; a--,b--; g[a].push_back(b); g[b].push_back(a); } int INF=2e9; vector<int>md(n,INF); queue<int>que; md[s]=0; que.push(s); while(que.size()){ auto p=que.front();que.pop(); for(auto x:g[p]){ if(md[x]>md[p]+1)md[x]=md[p]+1,que.push(x); } } if(md[t]!=INF){ if(md[t]%2!=k%2){ cout<<"No"<<endl; } else if(md[t]<=k){ cout<<"No"<<endl; } else assert(0); } else assert(0); }