Submission #68130808
Source Code Expand
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#define ALL(v) v.begin(),v.end()
#define For(i,_) for(int i=0,i##end=_;i<i##end;++i) // [0,_)
#define FOR(i,_,__) for(int i=_,i##end=__;i<i##end;++i) // [_,__)
#define Rep(i,_) for(int i=(_)-1;i>=0;--i) // [0,_)
#define REP(i,_,__) for(int i=(__)-1,i##end=_;i>=i##end;--i) // [_,__)
typedef long long ll;
typedef unsigned long long ull;
#define V vector
#define pb push_back
#define pf push_front
#define qb pop_back
#define qf pop_front
#define eb emplace_back
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
#define fi first
#define se second
const int dir[4][2]={{-1,0},{0,1},{1,0},{0,-1}},inf=0x3f3f3f3f,mod=1e9+7;
const ll infl=0x3f3f3f3f3f3f3f3fll;
template<class T>inline bool ckmin(T &x,const T &y){return x>y?x=y,1:0;}
template<class T>inline bool ckmax(T &x,const T &y){return x<y?x=y,1:0;}
int init=[](){return cin.tie(nullptr)->sync_with_stdio(false),0;}();
int main(){
int t_case=1;
scanf("%d",&t_case);
while(t_case--){
int m,n,s,t;
scanf("%d%d%d%d",&n,&m,&s,&t),--s,--t;
V<V<int>>to(n);
while(m--){
int x,y;
scanf("%d%d",&x,&y),--x,--y;
to[x].pb(y),to[y].pb(x);
}
V<int>st;
V<bool>vis(n);
auto dfs=[&](auto &&self,int p)->bool{
if(p==t){
for(int i:st)printf("%d ",i+1);
printf("%d\n",t+1);
return true;
}
st.pb(p),vis[p]=true;
sort(ALL(to[p]));
for(int i:to[p])if(!vis[i]&&self(self,i))return true;
st.qb();
return false;
};
dfs(dfs,s);
}
return 0;
}
Submission Info
| Submission Time |
|
| Task |
E - A Path in A Dictionary |
| User |
zzr |
| Language |
C++ 20 (gcc 12.2) |
| Score |
475 |
| Code Size |
1799 Byte |
| Status |
AC |
| Exec Time |
10 ms |
| Memory |
4688 KiB |
Compile Error
Main.cpp: In function ‘int main()’:
Main.cpp:28:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
28 | scanf("%d",&t_case);
| ~~~~~^~~~~~~~~~~~~~
Main.cpp:31:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
31 | scanf("%d%d%d%d",&n,&m,&s,&t),--s,--t;
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:35:18: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
35 | scanf("%d%d",&x,&y),--x,--y;
| ~~~~~^~~~~~~~~~~~~~
Judge Result
| Set Name |
Sample |
All |
| Score / Max Score |
0 / 0 |
475 / 475 |
| Status |
|
|
| Set Name |
Test Cases |
| 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 |
| Case Name |
Status |
Exec Time |
Memory |
| example_00.txt |
AC |
1 ms |
3708 KiB |
| hand_00.txt |
AC |
9 ms |
4556 KiB |
| hand_01.txt |
AC |
1 ms |
3788 KiB |
| hand_02.txt |
AC |
10 ms |
4420 KiB |
| hand_03.txt |
AC |
1 ms |
3920 KiB |
| hand_04.txt |
AC |
7 ms |
3864 KiB |
| hand_05.txt |
AC |
10 ms |
4520 KiB |
| hand_06.txt |
AC |
10 ms |
4668 KiB |
| hand_07.txt |
AC |
1 ms |
3848 KiB |
| hand_08.txt |
AC |
9 ms |
4436 KiB |
| hand_09.txt |
AC |
9 ms |
4404 KiB |
| hand_10.txt |
AC |
1 ms |
4080 KiB |
| hand_11.txt |
AC |
1 ms |
3712 KiB |
| random_00.txt |
AC |
1 ms |
3712 KiB |
| random_01.txt |
AC |
1 ms |
3800 KiB |
| random_02.txt |
AC |
1 ms |
3852 KiB |
| random_03.txt |
AC |
1 ms |
3916 KiB |
| random_04.txt |
AC |
1 ms |
3720 KiB |
| random_05.txt |
AC |
2 ms |
3660 KiB |
| random_06.txt |
AC |
1 ms |
3716 KiB |
| random_07.txt |
AC |
1 ms |
3784 KiB |
| random_08.txt |
AC |
1 ms |
3720 KiB |
| random_09.txt |
AC |
2 ms |
3812 KiB |
| random_10.txt |
AC |
3 ms |
3816 KiB |
| random_11.txt |
AC |
4 ms |
3816 KiB |
| random_12.txt |
AC |
1 ms |
3732 KiB |
| random_13.txt |
AC |
1 ms |
3712 KiB |
| random_14.txt |
AC |
2 ms |
3872 KiB |
| random_15.txt |
AC |
4 ms |
3720 KiB |
| random_16.txt |
AC |
6 ms |
4008 KiB |
| random_17.txt |
AC |
8 ms |
3952 KiB |
| random_18.txt |
AC |
1 ms |
3680 KiB |
| random_19.txt |
AC |
1 ms |
3788 KiB |
| random_20.txt |
AC |
8 ms |
4240 KiB |
| random_21.txt |
AC |
2 ms |
3828 KiB |
| random_22.txt |
AC |
9 ms |
4164 KiB |
| random_23.txt |
AC |
9 ms |
4580 KiB |
| random_24.txt |
AC |
1 ms |
3760 KiB |
| random_25.txt |
AC |
1 ms |
3800 KiB |
| random_26.txt |
AC |
10 ms |
4388 KiB |
| random_27.txt |
AC |
9 ms |
4292 KiB |
| random_28.txt |
AC |
7 ms |
4688 KiB |
| random_29.txt |
AC |
9 ms |
4468 KiB |