提出 #68150321


ソースコード 拡げる

#include<iostream>
#include<algorithm>
#include<climits>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<vector>
#include<queue>
#include<map>
#include<set>
#define int long long
using namespace std;
const int N=5e5+10;
int n,m,X,Y,ans;
vector<int> e[N],v;
bool vis[N],tg[N],sol;
void dfs(int u){
	if(sol) return;
	if(u==Y){
		sol=1;
		return;
	}
	v.push_back(0);
	for(int t:e[u]){
		if(vis[t]||tg[t]) continue;
		v.back()=t;
		vis[t]=1;
		dfs(t);
		if(sol) return; 
		vis[t]=0;
	}
	tg[u]=1;
	v.pop_back();
	return;
}
signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	int T;
	cin>>T;
	while(T--){
		for(int i=1;i<=n;++i) e[i].clear(),vis[i]=tg[i]=0;
		cin>>n>>m>>X>>Y;
		for(int i=1;i<=m;++i){
			int x,y;
			cin>>x>>y;
			e[x].push_back(y);
			e[y].push_back(x);
		}
		for(int i=1;i<=n;++i) sort(e[i].begin(),e[i].end());
		v.clear();sol=0;vis[X]=1;
		dfs(X);
		cout<<X<<' ';
		for(int t:v) cout<<t<<' ';
		cout<<'\n';
	}
	return 0;
}

提出情報

提出日時
問題 E - A Path in A Dictionary
ユーザ fanzs
言語 C++ 20 (gcc 12.2)
得点 475
コード長 1025 Byte
結果 AC
実行時間 11 ms
メモリ 4972 KiB

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 475 / 475
結果
AC × 1
AC × 43
セット名 テストケース
Sample example_00.txt
All example_00.txt, hand_00.txt, hand_01.txt, hand_02.txt, hand_03.txt, hand_04.txt, hand_05.txt, hand_06.txt, hand_07.txt, hand_08.txt, hand_09.txt, hand_10.txt, hand_11.txt, random_00.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, random_18.txt, random_19.txt, random_20.txt, random_21.txt, random_22.txt, random_23.txt, random_24.txt, random_25.txt, random_26.txt, random_27.txt, random_28.txt, random_29.txt
ケース名 結果 実行時間 メモリ
example_00.txt AC 3 ms 3480 KiB
hand_00.txt AC 10 ms 4804 KiB
hand_01.txt AC 3 ms 3648 KiB
hand_02.txt AC 10 ms 4668 KiB
hand_03.txt AC 3 ms 3656 KiB
hand_04.txt AC 8 ms 3584 KiB
hand_05.txt AC 11 ms 4868 KiB
hand_06.txt AC 10 ms 4944 KiB
hand_07.txt AC 3 ms 3648 KiB
hand_08.txt AC 9 ms 4596 KiB
hand_09.txt AC 9 ms 4880 KiB
hand_10.txt AC 3 ms 3792 KiB
hand_11.txt AC 3 ms 3576 KiB
random_00.txt AC 3 ms 3424 KiB
random_01.txt AC 3 ms 3420 KiB
random_02.txt AC 3 ms 3420 KiB
random_03.txt AC 3 ms 3428 KiB
random_04.txt AC 3 ms 3588 KiB
random_05.txt AC 3 ms 3512 KiB
random_06.txt AC 3 ms 3420 KiB
random_07.txt AC 3 ms 3520 KiB
random_08.txt AC 3 ms 3532 KiB
random_09.txt AC 4 ms 3616 KiB
random_10.txt AC 5 ms 3428 KiB
random_11.txt AC 5 ms 3684 KiB
random_12.txt AC 3 ms 3520 KiB
random_13.txt AC 3 ms 3532 KiB
random_14.txt AC 3 ms 3536 KiB
random_15.txt AC 5 ms 3548 KiB
random_16.txt AC 7 ms 3804 KiB
random_17.txt AC 9 ms 3620 KiB
random_18.txt AC 3 ms 3544 KiB
random_19.txt AC 3 ms 3516 KiB
random_20.txt AC 9 ms 4692 KiB
random_21.txt AC 4 ms 3628 KiB
random_22.txt AC 10 ms 4116 KiB
random_23.txt AC 10 ms 4792 KiB
random_24.txt AC 3 ms 3440 KiB
random_25.txt AC 3 ms 3536 KiB
random_26.txt AC 10 ms 4756 KiB
random_27.txt AC 10 ms 4396 KiB
random_28.txt AC 11 ms 4972 KiB
random_29.txt AC 10 ms 4852 KiB