-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path欧拉路.cpp
More file actions
58 lines (56 loc) · 1.28 KB
/
欧拉路.cpp
File metadata and controls
58 lines (56 loc) · 1.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
const int MAXN = 1e5+5;
int val[MAXN];
int js[MAXN];
int n, m;
int ans;
int main()
{
int T;
scanf("%d", &T);
while(T--) {
ans = 0;
memset(val, 0, sizeof(val));
memset(js, 0, sizeof(js));
scanf("%d%d", &n, &m);
for(int i = 1; i <= n; i++) {
scanf("%d", &val[i]);
}
for(int i = 1; i <= m; i++) {
int u, v;
scanf("%d%d", &u, &v);
// if(u == v) {
// ans ^= val[u];
// continue;
// }
js[u]++;
js[v]++;
}
int num = 0;
for(int i = 1; i <= n; i++) {
int temp = js[i] >> 1;
if(js[i] & 1) temp++, num++;
if(temp & 1) {
ans ^= val[i];
}
if(num > 2) break;
}
if(num == 0 || num == 2) {
if(num == 0) {
int temp = ans;
for(int i = 1; i <= n; i++) {
temp = max(temp, ans ^ val[i]);
}
ans = temp;
}
printf("%d\n", ans);
} else {
printf("Impossible\n");
}
}
return 0;
}