比赛 Asm.Def战记之圣地亚哥“杯2015 评测结果 AAAAWWWTTT
题目名称 Asm.Def的游戏 最终得分 40
用户昵称 typhon 运行时间 3.012 s
代码语言 Pascal 内存使用 76.84 MiB
提交时间 2015-10-31 09:24:36
显示代码纯文本
var p:array[1..100000,0..200] of longint;
i,j,m,n,a,b,s,t:longint;

function firstmax:longint;
var i:longint;
begin
 for i:=1 to n do
  if (p[i,0]>=3) and (p[i,0]<>maxlongint) then exit(s);
end;
function first:longint;
var i:longint;
begin
 for i:=1 to n do
  if p[i,0]<3 then exit(i);
 for i:=1 to n do
  if (p[i,0]>=3)and (p[i,0]<>maxlongint) then s:=s xor i;
 writeln(s);
 halt;
end;
procedure have;
var i:longint;
begin
 for i:=1 to n do
  if p[i,0]>=3 then exit;
 writeln(0);
 halt;
end;

begin
 assign(input,'asm_game.in');
 reset(input);
 assign(output,'asm_game.out');
 rewrite(output);
 readln(n,m);
 for i:=1 to m do
  begin
   readln(a,b);
   inc(p[a,0]);
   inc(p[b,0]);
   p[a,p[a,0]]:=b;
   p[b,p[b,0]]:=a;
  end;
  have;
 // t:=first;
 // s:=t;
  while true do
  begin
  t:=first;
  p[t,0]:=maxlongint;
  for i:=1 to n do
  begin
   if p[i,0]<>maxlongint then begin
   for j:=1 to p[i,0] do
    if p[i,j]=t then begin p[i,j]:=0;dec(p[i,0]);end;
   s:=firstmax;
  end;
  end;
  end;
  close(input);
  close(output);
end.