結果
問題 |
No.2674 k-Walk on Bipartite
|
ユーザー |
![]() |
提出日時 | 2024-03-15 23:27:22 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,307 bytes |
コンパイル時間 | 949 ms |
コンパイル使用メモリ | 98,520 KB |
実行使用メモリ | 16,256 KB |
最終ジャッジ日時 | 2024-09-30 03:01:18 |
合計ジャッジ時間 | 4,415 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 32 WA * 4 |
ソースコード
#include <iostream> #include <vector> #include <algorithm> #include <stack> #include <queue> #include <set> #include <map> #include <random> #include <time.h> #include <map> using namespace std; int n,m,s,t,k,a,b; vector<int>e[200000]; int length[200000]; bool visited[200000]; void dfs(int now, int len=0) { if(visited[now]) return; visited[now]=true; length[now]=len; for(int nxt:e[now]) dfs(nxt, len+1); } int main() { cin >> n >> m >> s >> t >> k; if(s==t) { if(n==1) cout << "No" << endl; else if(k%2==0) { if(e[s].size()) cout << "Yes" << endl; else cout << "Unknown" << endl; } else { cout << "No" << endl; } return 0; } for(int i=0;i<m;i++) { cin >> a >> b; a--;b--; e[a].push_back(b); e[b].push_back(a); } s--;t--; dfs(s); if(visited[t]) { if(length[t]%2!=k%2) { cout << "No" << endl; } else { if(length[t]<=k) { cout << "Yes" << endl; } else { cout << "Unknown" << endl; } } } else { cout << "Unknown" << endl; } }