比赛 |
Asm.Def战记之圣地亚哥“杯2015 |
评测结果 |
AAAAAAAAAA |
题目名称 |
Asm.Def的游戏 |
最终得分 |
100 |
用户昵称 |
BYVoid |
运行时间 |
0.056 s |
代码语言 |
C++ |
内存使用 |
38.45 MiB |
提交时间 |
2019-10-23 19:13:34 |
显示代码纯文本
#include<cstdio>
#include<algorithm>
#include<queue>
#define maxn 1000005
#define re register
using namespace std;
inline int read(){
int s=0,f=1;
char ch=getchar();
while(ch<'0'||ch>'9'){
if(ch=='-')f=-1;
ch=getchar();
}
while(ch>='0'&&ch<='9'){
s=(s<<1)+(s<<3)+ch-'0';
ch=getchar();
}
return s*f;
}
int max(int x,int y){
return x>y?x:y;
}
int min(int x,int y){
return x<y?x:y;
}
int n,m,ans;
struct E{
int y,nxt;
}edge[maxn];
int head[maxn],tot;
void add(int x,int y){
edge[++tot].y=y;
edge[tot].nxt=head[x];
head[x]=tot;
}
int basea,baseb;
struct B{
int x,y;
friend bool operator < (B a,B b){
if(a.x==b.x)return a.y<b.y;
return a.x<b.x;
}
}e[maxn];
int inn[maxn];
bool check[maxn],vis[maxn];
void toposort(){
queue<int>q;
for(re int i=1;i<=n;++i){
if(inn[i]<3){
q.push(i);
check[i]=1;
}
}
while(!q.empty()){
int x=q.front();
q.pop();
for(re int i=head[x];i;i=edge[i].nxt){
int y=edge[i].y;
//if(inn[y]==0)continue;
if(check[y])continue;
--inn[y];
if(inn[y]<3){
q.push(y);
check[y]=1;
}
}
//inn[x]=0;
}
}
int main()
{
freopen("asm_game.in","r",stdin);
freopen("asm_game.out","w",stdout);
n=read();
m=read();
for(re int i=1;i<=m;++i){
int x=read();
int y=read();
add(x,y);
add(y,x);
inn[x]++;
inn[y]++;
}
/*sort(e+1,e+1+m);
for(re int i=1;i<=m;++i){
if(basea<e[i].x){
basea=e[i].x;
baseb=0;
}
if(baseb<e[i].y){
//printf("x=%d y=%d\n",e[i].x,e[i].y);
add(e[i].x,e[i].y);
add(e[i].y,e[i].x);
++inn[e[i].x];
++inn[e[i].y];
baseb=e[i].y;
}
}*/
toposort();
for(re int i=1;i<=n;++i){
if(!check[i]){
//printf("%d ",i);
ans=ans xor i;
}
}
printf("%d\n",ans);
return 0;
}
/*
6 15
1 2
2 1
1 3
3 1
1 4
2 3
3 2
2 4
4 2
3 4
3 4
5 2
5 3
5 6
6 2
*/
/*
5
18
1 2
1 3
2 5
5 4
5 3
3 4
2 4
2 3
3 5
1 3
4 3
2 4
5 2
1 2
3 1
4 3
5 2
4 5
*/