結果
| 問題 |
No.2674 k-Walk on Bipartite
|
| コンテスト | |
| ユーザー |
tour2st
|
| 提出日時 | 2024-03-15 23:25:23 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,247 bytes |
| コンパイル時間 | 846 ms |
| コンパイル使用メモリ | 98,884 KB |
| 実行使用メモリ | 16,284 KB |
| 最終ジャッジ日時 | 2024-09-30 02:59:50 |
| 合計ジャッジ時間 | 3,432 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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)
{
cout << "Yes" << 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;
}
}
tour2st