From a53f5205b87ec9db68643101fdca7347788c3421 Mon Sep 17 00:00:00 2001 From: Kirito <1362050620@qq.com> Date: Sun, 18 Sep 2016 09:08:51 +0800 Subject: [PATCH] Create 5883_yyecust.cpp From http://blog.csdn.net/yyecust/article/details/52565788 --- HDOJ/5883_yyecust.cpp | 59 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 HDOJ/5883_yyecust.cpp diff --git a/HDOJ/5883_yyecust.cpp b/HDOJ/5883_yyecust.cpp new file mode 100644 index 0000000..37bd631 --- /dev/null +++ b/HDOJ/5883_yyecust.cpp @@ -0,0 +1,59 @@ +#include +#include +using namespace std; +const int MAXN = 100000; +int g[MAXN]; //g[i]表示与i相连的边数 +int a[MAXN]; +void solve() +{ + int n, m; + scanf("%d%d", &n, &m); + for (int i = 0; i < n; i++) { + scanf("%d", &a[i]); + g[i] = 0; + } + for (int i = 0; i < m; i++) { + int u, v; + scanf("%d%d", &u, &v); + u--; + v--; + g[u]++; + g[v]++; + } + int ods = 0; //奇点数 + int xors = 0; + for (int i = 0; i < n; i++) { + if (g[i] % 2) { + ods++; + if (g[i] % 3) { + xors ^= a[i]; + } + } else { + if (g[i] % 4) { + xors ^= a[i]; + } + } + } + if (ods > 2) { + puts("Impossible"); + return; + } + if (ods == 2) { + printf("%d\n", xors); + return; + } + int ans = 0; + for (int i = 0; i < n; i++) { + ans = max(ans, xors ^ a[i]); + } + printf("%d\n", ans); +} +int main() +{ + //freopen("in.txt", "r", stdin); + int t; + scanf("%d", &t); + while (t--) { + solve(); + } +}