結果

問題 No.2674 k-Walk on Bipartite
ユーザー じなぺじなぺ
提出日時 2024-03-15 23:49:30
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,279 bytes
コンパイル時間 5,482 ms
コンパイル使用メモリ 313,912 KB
実行使用メモリ 16,936 KB
最終ジャッジ日時 2024-03-15 23:50:54
合計ジャッジ時間 8,187 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
8,104 KB
testcase_01 AC 5 ms
8,104 KB
testcase_02 WA -
testcase_03 AC 5 ms
8,104 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 5 ms
8,104 KB
testcase_07 AC 64 ms
13,480 KB
testcase_08 AC 77 ms
12,712 KB
testcase_09 AC 53 ms
13,224 KB
testcase_10 AC 92 ms
13,608 KB
testcase_11 AC 71 ms
13,224 KB
testcase_12 AC 95 ms
13,096 KB
testcase_13 AC 50 ms
12,584 KB
testcase_14 AC 14 ms
10,280 KB
testcase_15 AC 133 ms
16,680 KB
testcase_16 AC 74 ms
13,736 KB
testcase_17 AC 90 ms
14,376 KB
testcase_18 AC 31 ms
11,176 KB
testcase_19 AC 63 ms
13,096 KB
testcase_20 AC 55 ms
13,096 KB
testcase_21 AC 104 ms
14,760 KB
testcase_22 AC 147 ms
16,936 KB
testcase_23 AC 5 ms
8,104 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 5 ms
8,104 KB
testcase_27 AC 5 ms
8,104 KB
testcase_28 WA -
testcase_29 WA -
testcase_30 AC 5 ms
8,104 KB
testcase_31 AC 5 ms
8,104 KB
testcase_32 AC 5 ms
8,104 KB
testcase_33 AC 4 ms
8,104 KB
testcase_34 AC 5 ms
8,104 KB
testcase_35 AC 5 ms
8,104 KB
testcase_36 AC 5 ms
8,104 KB
testcase_37 AC 4 ms
8,104 KB
testcase_38 AC 5 ms
8,104 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#include <atcoder/all>
using namespace atcoder;
//using mint = modint998244353;

//多倍長整数//
//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;
//using Bint = mp::cpp_int;

const int INF = 1e9;
const int MOD = 998244353;
const long long LINF = 4e18;

using ll = long long;
using vi = vector<int>;
using vl = vector<long long>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using vvvvi = vector<vector<vector<vector<int>>>>;
using vvl = vector<vector<long long>>;
using vvvl = vector<vector<vector<long long>>>;
using vvvvl = vector<vector<vector<vector<long long>>>>;
using vvc = vector<vector<char>>;
using vvb = vector<vector<bool>>;
using vvvb = vector<vector<vector<bool>>>;
using vvvvb = vector<vector<vector<vector<bool>>>>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define dump(x)  cout << #x << " = " << (x) << endl;
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define ALL(obj) (obj).begin(),(obj).end()
vvi g(2e5);
int n,m;
int s,t,k;
vb color(2e5,false);
vb vis(2e5,false);

void dfs(int cur,bool c){
	vis[cur] = true;
	color[cur] = c;
	for(int next : g[cur]){
		if(vis[next] == false){
			dfs(next,!c);
		}
	}
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	
	cin >> n >> m;
	
	cin >> s >> t >> k;
	s--;t--;
	dsu uf(n);
	rep(i,m){
		int a,b;
		cin >> a >> b;
		a--;b--;
		uf.merge(a,b);
		g[a].push_back(b);
		g[b].push_back(a);
	}
	vi dist(n,INF);
	dist[s] = 0;
	queue<int> que;
	que.push(s);
	while(!que.empty()){
		int cur = que.front();
		que.pop();
		for(int next : g[cur]){
			if(dist[next] != INF) continue;
			dist[next] = dist[cur] + 1;
			que.push(next);
		}
	}
	if(dist[t] <= k && dist[t]%2 == k%2){
		cout << "Yes" << endl;
		return 0;
	}
	dfs(s,true);
	if(vis[t] == false){
		cout << "Unknown" << endl;
		return 0;
	}
	//assert(false);
	cout << "No" << endl;
	return 0;
	if(color[t]){
		if(k%2 == 0 && k >= 2){
			cout << "Unknown" << endl;
		}else{
			cout << "No" << endl;
		}
		return 0;
	}else{
		if(k%2 == 1 && k >= 1){
			cout << "Unknown" << endl;
		}else{
			cout << "No" << endl;
		}
		return 0;
	}
	return 0;
}
0