結果
問題 | No.2674 k-Walk on Bipartite |
ユーザー |
![]() |
提出日時 | 2024-03-15 22:35:36 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,732 bytes |
コンパイル時間 | 954 ms |
コンパイル使用メモリ | 105,832 KB |
実行使用メモリ | 17,856 KB |
最終ジャッジ日時 | 2024-09-30 02:01:38 |
合計ジャッジ時間 | 4,396 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 30 WA * 6 |
コンパイルメッセージ
main.cpp: In function 'int main()': main.cpp:57:22: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17' [-Wc++17-extensions] 57 | auto [idx, len] = idx_len.front(); | ^ main.cpp:69:13: warning: 'dst' may be used uninitialized [-Wmaybe-uninitialized] 69 | if(dst<=k) | ^~ main.cpp:51:17: note: 'dst' was declared here 51 | int dst; | ^~~
ソースコード
#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]; pair<int,int> color[200000]; bool visited[200000]; bool length[200000]; void dfs(int now, int sta, int col) { if(visited[now]) return; visited[now] = true; color[now] = {sta,col}; for(int nxt:e[now]) { dfs(nxt, sta, col^1); } } int main() { cin >> n >> m >> s >> t >> k; for(int i=0;i<m;i++) { cin >> a >> b; a--;b--; e[a].push_back(b); e[b].push_back(a); } for(int i=0;i<n;i++) { dfs(i, i, 0); } s--;t--; if(color[s].first==color[t].first) { int bi1 = color[s].second; int bi2 = color[t].second; if(k%2 == bi1^bi2) { int dst; //到達できるか? queue<pair<int,int>>idx_len; idx_len.push({s,0}); while(!idx_len.empty()) { auto [idx, len] = idx_len.front(); idx_len.pop(); if(length[idx]) continue; length[idx] = true; if(idx==t) dst = len; for(int nxt:e[idx]) { idx_len.push({nxt, len+1}); } } if(dst<=k) { cout << "Yes" << endl; } else { cout << "Unknown" << endl; } } else { cout << "No" << endl; } } else { cout << "Unknown" << endl; } }