Untitled diff
2 removals
102 lines
4 additions
103 lines
#include <bits/stdc++.h>
#include <bits/stdc++.h>
using namespace std;
using namespace std;
#define mp make_pair
#define mp make_pair
#define pb push_back
#define pb push_back
#define len(a) (int)a.size()
#define len(a) (int)a.size()
#define fi first
#define fi first
#define sc second
#define sc second
#define d1(x) cerr<<#x<<":"<<x<<endl;
#define d1(x) cerr<<#x<<":"<<x<<endl;
#define d2(x,y) cerr<<#x<<":"<<x<<" "<<#y<<":"<<y<<endl;
#define d2(x,y) cerr<<#x<<":"<<x<<" "<<#y<<":"<<y<<endl;
#define d3(x,y,z) cerr<<#x<<":"<<x<<" "<<#y<<":"<<y<<" "<<#z<<":"<<z<<endl;
#define d3(x,y,z) cerr<<#x<<":"<<x<<" "<<#y<<":"<<y<<" "<<#z<<":"<<z<<endl;
#define left ind+ind
#define left ind+ind
#define right ind+ind+1
#define right ind+ind+1
#define mid (l+r)/2
#define mid (l+r)/2
const long long LINF = 1e18+5;
const long long LINF = 1e18+5;
const int MOD = (int) 1e9 + 7;
const int MOD = (int) 1e9 + 7;
const int LOG = 18;
const int LOG = 18;
const int INF = 1e9;
const int INF = 1e9;
const int N = 1e5+5;
const int N = 1e5+5;
const int M = 350;
const int M = 350;
const int SQ = 350;
const int SQ = 350;
typedef long long int lli;
typedef long long int lli;
typedef pair<int,int> pii;
typedef pair<int,int> pii;
typedef pair<pii,int> piii;
typedef pair<pii,int> piii;
vector <int> ed[N];
vector <int> ed[N];
int n,m,dp[N][2],s;
int n,m,dp[N][2],s;
int dfs(int cur,int turn) {
int dfs(int cur,int turn) {
if(dp[cur][turn] != -1) return dp[cur][turn];
if(dp[cur][turn] != -1) return dp[cur][turn];
if (!len(ed[cur])) {
if (!len(ed[cur])) {
if(turn == 1) return dp[cur][turn] = 0;
if(turn == 1) return dp[cur][turn] = 0;
else return dp[cur][turn] = 2;
else return dp[cur][turn] = 2;
}
}
bool flag = true;
bool flag = true;
for (auto i : ed[cur]) {
for (auto i : ed[cur]) {
if(dp[i][!turn] == -1)
if(dp[i][!turn] == -1)
flag = false;
flag = false;
}
}
if(flag == true) return dp[cur][turn] = 1;
if(flag == true) return dp[cur][turn] = 1;
int mx = 0;
int mx = 0;
dp[cur][turn] = 1;
dp[cur][turn] = 1;
for (auto i : ed[cur])
for (auto i : ed[cur])
if(dp[i][!turn] == -1)
mx = max(mx,dfs(i,!turn));
mx = max(mx,dfs(i,!turn));
return dp[cur][turn] = mx;
return dp[cur][turn] = mx;
}
}
void write(int cur,int turn) {
void write(int cur,int turn) {
printf("%d ",cur);
printf("%d ",cur);
for (auto i : ed[cur]) {
for (auto i : ed[cur]) {
if(dp[i][!turn] == 2) {
if(dp[i][!turn] == 2) {
write(i,!turn);
write(i,!turn);
break;
break;
}
}
}
}
}
}
int main() {
int main() {
memset(dp,-1,sizeof dp);
memset(dp,-1,sizeof dp);
scanf("%d %d",&n,&m);
scanf("%d %d",&n,&m);
for (int i = 1 ; i <= n ; i++) {
for (int i = 1 ; i <= n ; i++) {
int m;
int m;
scanf("%d",&m);
scanf("%d",&m);
while(m--) {
while(m--) {
int v;
int v;
scanf("%d",&v);
scanf("%d",&v);
ed[i].pb(v);
ed[i].pb(v);
}
}
}
}
scanf("%d",&s);
scanf("%d",&s);
int get = dfs(s,1);
int get = dfs(s,1);
if (get == 0) {
if (get == 0) {
printf("Lose");
printf("Lose");
}
}
else if (get == 1) {
else if (get == 1) {
printf("Draw");
printf("Draw");
}
}
else {
else {
printf("Win\n");
printf("Win\n");
write(s,1);
write(s,1);
}
}
return 0 ;
return 0 ;
}
}