#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define int long long
#define endl '\n'
using namespace std;
using namespace __gnu_pbds;
using ordered_set = tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>;
vector<int>vct[100001];
vector<int>tcv[100001];
pair<int,int>vis[100001][2];
signed main(){
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
for(int i=0;i<100001;i++){
vis[i][0]={-1,-1};
vis[i][1]={-1,-1};
}
int n,m;
cin>>n>>m;
for(int i=1;i<=n;i++){
int k;
cin>>k;
while(k--){
int x;
cin>>x;
tcv[x].push_back(i);
vct[i].push_back(x);
}
}
int in;
cin>>in;
deque<pair<int,int>>dq;
for(int i=1;i<=n;i++){
if(vct[i].empty())dq.push_back({i,0});
}
if(dq.empty()){
cout<<"Draw";
return 0;
}
bool bl=0;
while(dq.size()){
int a=dq.front().first,b=dq.front().second;
dq.pop_front();
for(auto &i:tcv[a]){
if(vis[i][b^1].first==-1){
vis[i][b^1]={a,b};
dq.push_back({i,b^1});
}else bl=1;
}
}
if(vis[in][1].first==-1){
if(bl)cout<<"Draw";
else cout<<"Lose";
return 0;
}
cout<<"Win\n";
int a=in,b=1;
while(vis[a][b].first!=-1){
cout<<a<<' ';
int A=a,B=b;
a=vis[A][B].first;
b=vis[A][B].second;
}
cout<<a;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
8020 KB |
Correct solution. |
2 |
Incorrect |
7 ms |
8020 KB |
Participant's answer is Lose, but jury's is Draw. |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
8020 KB |
Correct solution. |
2 |
Correct |
7 ms |
8148 KB |
Correct solution. |
3 |
Correct |
5 ms |
8148 KB |
Correct solution. |
4 |
Correct |
80 ms |
15524 KB |
Correct solution. |
5 |
Correct |
5 ms |
8148 KB |
Correct solution. |
6 |
Correct |
11 ms |
8932 KB |
Correct solution. |
7 |
Correct |
132 ms |
15976 KB |
Correct solution. |
8 |
Correct |
78 ms |
16268 KB |
Correct solution. |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
8020 KB |
Correct solution. |
2 |
Correct |
5 ms |
8148 KB |
Correct solution. |
3 |
Correct |
5 ms |
8148 KB |
Correct solution. |
4 |
Correct |
5 ms |
8148 KB |
Correct solution. |
5 |
Correct |
6 ms |
8136 KB |
Correct solution. |
6 |
Correct |
6 ms |
8148 KB |
Correct solution. |
7 |
Correct |
6 ms |
8148 KB |
Correct solution. |
8 |
Correct |
7 ms |
8132 KB |
Correct solution. |
9 |
Correct |
5 ms |
8236 KB |
Correct solution. |
10 |
Correct |
8 ms |
8120 KB |
Correct solution. |
11 |
Incorrect |
6 ms |
8148 KB |
Participant's answer is Draw, but jury's is Lose. |
12 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
8020 KB |
Correct solution. |
2 |
Correct |
5 ms |
8148 KB |
Correct solution. |
3 |
Correct |
5 ms |
8148 KB |
Correct solution. |
4 |
Correct |
5 ms |
8148 KB |
Correct solution. |
5 |
Correct |
6 ms |
8136 KB |
Correct solution. |
6 |
Correct |
6 ms |
8148 KB |
Correct solution. |
7 |
Correct |
6 ms |
8148 KB |
Correct solution. |
8 |
Correct |
7 ms |
8132 KB |
Correct solution. |
9 |
Correct |
5 ms |
8236 KB |
Correct solution. |
10 |
Correct |
8 ms |
8120 KB |
Correct solution. |
11 |
Incorrect |
6 ms |
8148 KB |
Participant's answer is Draw, but jury's is Lose. |
12 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
8020 KB |
Correct solution. |
2 |
Incorrect |
7 ms |
8020 KB |
Participant's answer is Lose, but jury's is Draw. |
3 |
Halted |
0 ms |
0 KB |
- |