You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
|
#include <bits/stdc++.h>
|
|
|
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
|
const int N = 2010, M = 6010;
|
|
|
|
|
|
|
|
|
|
// SG函数模板题
|
|
|
|
|
int n, m, k;
|
|
|
|
|
int f[N];
|
|
|
|
|
|
|
|
|
|
int h[N], e[M], ne[M], idx;
|
|
|
|
|
void add(int a, int b) {
|
|
|
|
|
e[idx] = b, ne[idx] = h[a], h[a] = idx++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int sg(int u) {
|
|
|
|
|
//记忆化搜索
|
|
|
|
|
if (~f[u]) return f[u];
|
|
|
|
|
|
|
|
|
|
//找出当前结点u的所有出边,看看哪个sg值没有使用过
|
|
|
|
|
set<int> S;
|
|
|
|
|
for (int i = h[u]; ~i; i = ne[i])
|
|
|
|
|
S.insert(sg(e[i]));
|
|
|
|
|
|
|
|
|
|
//找到第一个没有出现的过的自然数, 0,1,2,3,4,...
|
|
|
|
|
for (int i = 0;; i++)
|
|
|
|
|
if (S.count(i) == 0) {
|
|
|
|
|
f[u] = i;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
return f[u];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int main() {
|
|
|
|
|
memset(h, -1, sizeof h);
|
|
|
|
|
cin >> n >> m >> k;
|
|
|
|
|
while (m--) {
|
|
|
|
|
int a, b;
|
|
|
|
|
cin >> a >> b;
|
|
|
|
|
add(a, b);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
memset(f, -1, sizeof f); //初始化sg函数的结果表
|
|
|
|
|
int res = 0;
|
|
|
|
|
while (k--) {
|
|
|
|
|
int u;
|
|
|
|
|
cin >> u;
|
|
|
|
|
res ^= sg(u); //计算每个出发点的sg(u),然后异或在一起
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (res) //所有出发点的异或和不等于0,先手必胜
|
|
|
|
|
puts("win");
|
|
|
|
|
else //所有出发点的异或和等于0,先手必败
|
|
|
|
|
puts("lose");
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|