比赛 |
Asm.Def战记之圣地亚哥“杯2015 |
评测结果 |
AAAAAAAAAA |
题目名称 |
Asm.Def的游戏 |
最终得分 |
100 |
用户昵称 |
CoolBoy小逴 |
运行时间 |
0.063 s |
代码语言 |
C++ |
内存使用 |
29.39 MiB |
提交时间 |
2019-10-23 18:02:29 |
显示代码纯文本
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <queue>
#define Re register
using namespace std;
const int maxn = 500010;
queue<int>Q;
int n, m, u, v;
int cnt, top, ans;
int head[maxn], in[maxn];
bool vis[maxn];
struct Edge{
int u, v, next;
}e[maxn << 1];
int f_;
char ch_;
template <class T>
inline T read (T &x_){
x_ = 0, f_ = 1, ch_ = getchar();
while (ch_ > '9' || ch_ < '0'){if (ch_ == '-') f_ = -1; ch_ = getchar();}
while (ch_ >= '0' && ch_ <= '9') x_ = (x_ << 3) + (x_ << 1) + ch_ - 48, ch_ = getchar();
return x_ *= f_;
}
void add (int u, int v){
e[++cnt].u = u;
e[cnt].v = v;
e[cnt].next = head[u];
head[u] = cnt;
return;
}
void Tuopu_sort (){
for (Re int i = 1;i <= n; ++i){
if (in[i] < 3) {
Q.push(i);
vis[i] = 1;
}
}
while (!Q.empty()){
top = Q.front();
Q.pop();
for (Re int i = head[top]; i;i = e[i].next){
if (vis[e[i].v]) continue;
in[e[i].v]--;
if (in[e[i].v] < 3){
Q.push(e[i].v);
vis[e[i].v] = 1;
}
}
// for (register int i = 1;i <= n; ++i) cout << i <<' '<<in[i] << '\n';
// cout << '\n';
}
}
int main(){
freopen ("asm_game.in", "r", stdin);
freopen ("asm_game.out", "w", stdout);
read(n);
read(m);
for (Re int i = 1;i <= m; ++i){
read(u); read(v);
add (u, v);
add (v, u);
in[u]++;
in[v]++;
}
// for (register int i = 1;i <= n; ++i) cout << i <<' '<<in[i] << '\n';
Tuopu_sort();
for (Re int i = 1;i <= n; ++i){
if (vis[i]) continue;
ans ^= i;
}
printf ("%d\n", ans);
return 0;
}