This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
#include <iostream>
#include <fstream>
#include <algorithm>
#include <vector>
#include <set>
#include <stack>
#include <map>
#include <unordered_map>
#include <iomanip>
#include <cmath>
#include <queue>
#include <bitset>
#include <numeric>
#include <array>
#include <cstring>
#include <random>
#include <chrono>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define make_unique(x) sort(all((x))); (x).resize(unique(all((x))) - (x).begin())
typedef long long ll;
typedef long double ld;
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// template<class T>
// using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
const int N = 1e5 + 42;
vector<int> g[N];
int dp[N][2] = {0};
int n, m;
int s;
bool draw = false;
vector<int> ans;
void dfs(int v, int move) {
dp[v][move] = 1;
ans.pb(v);
if(!g[v].size() && move) {
cout << "Win\n";
for(auto& x : ans) cout << x << ' ';
exit(0);
}
for(auto& x : g[v]) {
if(dp[x][(move ^ 1)] == 1) draw = true;
if(!dp[x][(move ^ 1)]) dfs(x, (move ^ 1));
}
dp[v][move] = 2;
ans.pop_back();
}
int main() {
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cin >> n >> m;
for(int i = 1; i <= n; i++) {
int c; cin >> c;
for(int j = 0; j < c; j++) {
int to; cin >> to;
g[i].pb(to);
}
}
cin >> s;
dfs(s, 0);
cout << (draw ? "Draw\n" : "Lose\n");
return 0;
}
/*
5 5
1 2
1 3
2 1 4
1 5
0
1
*/
Compilation message (stderr)
D.cpp:3: warning: ignoring #pragma GCC optimization [-Wunknown-pragmas]
3 | #pragma GCC optimization ("unroll-loops")
|
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |