比赛 |
Asm.Def战记之圣地亚哥“杯2015 |
评测结果 |
AAAAAAAEEE |
题目名称 |
Asm.Def的游戏 |
最终得分 |
70 |
用户昵称 |
Ten.X |
运行时间 |
0.309 s |
代码语言 |
Pascal |
内存使用 |
35.27 MiB |
提交时间 |
2015-10-31 11:41:47 |
显示代码纯文本
var a:array[1..100005]of longint;
sum:Array[1..100005]of longint;
map:array[1..6001,1..6001]of boolean;
head,x,n,m:longint;k,l,r,i,j:longint;
procedure qsort(s,t:longint);
var i,j,mid,temp:longint;
begin
i:=s;j:=t;mid:=a[(s+t) div 2];
while i<=j do
begin
while a[i]<mid do inc(i);
while a[j]>mid do dec(j);
if i<=j then
begin
temp:=a[i];a[i]:=a[j];a[j]:=temp;
temp:=sum[i];sum[i]:=sum[j];sum[j]:=temp;
inc(i);dec(j);
end;
end;
if i<t then qsort(i,t);
if j>s then qsort(s,j);
end;
begin
assign(input,'asm_game.in');
assign(output,'asm_game.out');
reset(input);
rewrite(output);
fillchar(map,sizeof(map),false);
read(n,m);
for i:=1 to n do sum[i]:=i;
for i:=1 to m do
begin
read(l,r);
inc(a[l]);
inc(a[r]);
map[l,r]:=true;
map[r,l]:=true;
end;
qsort(1,n);
head:=1;
while (a[head]<3) and(head<=n) do
begin
for k:=1 to n do
if map[sum[head],sum[k]]
then dec(a[k]);
inc(head);
qsort(head,n);
end;
if head>n then begin write(0);halt;end;
if head=n then begin write(sum[head]);halt;end;
x:=sum[head];
for i:=head+1 to n do
x:=x xor sum[i];
write(x);
close(input);
close(output);
end.