比赛 |
20131130 |
评测结果 |
AAAAAAAAAA |
题目名称 |
石子游戏 |
最终得分 |
100 |
用户昵称 |
GDFRWMY |
运行时间 |
0.088 s |
代码语言 |
Pascal |
内存使用 |
0.83 MiB |
提交时间 |
2013-12-01 12:54:41 |
显示代码纯文本
var
a,b,c,d,f,i,j,m,n,ans,outp:longint;
k,yy:array[0..100000]of longint;
function find(g,h:longint):longint;
var
v,o:longint;
begin
o:=g;
for v:=1 to h-1 do
o:=o div 2;
find:=o mod 2;
end;
function ff(x:longint):longint;
var
r,rr:longint;
begin
r:=1;
for rr:=1 to x-1 do
r:=r*2;
ff:=r;
end;
function outout(x:longint):longint;
var
t,tt:longint;
begin
tt:=x;
for t:=1 to n do
begin
if tt mod 2=1 then
write('X')
else
write('O');
tt:=tt div 2;
end;
end;
procedure dfs(x,step:longint);
var
y,z,q,w,e:longint;
begin
if outp=1 then exit;
if step>0 then if step<ans then if x=0 then exit;
if step=ans then
if x=0 then
begin
for y:=1 to ans do
begin
outout(yy[y]);
writeln;
end;
outp:=1;
end;
for y:=1 to n do
if find(x,y)=0 then
begin
if k[x+ff(y)]=0 then
begin
k[x+ff(y)]:=1; yy[step+1]:=x+ff(y);
dfs(x+ff(y),step+1);
k[x+ff(y)]:=0;
end;
end
else
begin
if k[x-ff(y)]=0 then
begin
k[x-ff(y)]:=1; yy[step+1]:=x-ff(y);
dfs(x-ff(y),step+1);
k[x-ff(y)]:=0;
end;
end;
end;
begin
assign(input,'rocksa.in');
assign(output,'rocksa.out');
reset(input);
rewrite(output);
read(n);
ans:=1;
for a:=1 to n do
begin
ans:=ans*2;
write('O');
end;
writeln;
dfs(0,0);
close(input);
close(output);
end.