- 数独验证
- 2009-10-26 20:41:30 @
var a:array[1..9,1..9] of longint;
f:array[1..9] of x;
c:array[1..50] of string;
i,j,s,n,k:longint;
function ok(x1,x2,y1,y2:longint):boolean;
var i,j:longint;
begin
fillchar(f,sizeof(f),0); s:=0;
for i:=x1 to x2 do
for j:=y1 to y2 do
begin
if f[a]=1 then begin ok:=false; exit; end
else f[a]:=1;
end;
ok:=true;
end;
begin
readln(n);
for k:=1 to n do
begin
for i:=1 to 9 do
for j:=1 to 9 do
read(a);
for i:=1 to 9 do
if not(ok(1,9,i,i)) then begin break; s:=1; end;
if s=0 then for i:=1 to 9 do if not(ok(i,i,1,9)) then begin break; s:=1; end;
if s=0 then if (ok(1,3,1,3)) and (ok(1,3,4,6)) and (ok(1,3,7,9)) and
(ok(4,6,1,3)) and (ok(4,6,4,6)) and (ok(4,6,7,9)) and
(ok(7,9,1,3)) and (ok(7,9,4,6)) and (ok(7,9,7,9)) then s:=0 else s:=1;
if s=0 then c[k]:='Right' else if s=1 then c[k]:='Wrong';
fillchar(a,sizeof(a),0);
s:=0;
end;
for i:=1 to n do writeln(c[i]);
end.
编译通过...
├ 测试数据 01:答案正确... 0ms
├ 测试数据 02:答案正确... 0ms
├ 测试数据 03:答案正确... 0ms
├ 测试数据 04:答案正确... 0ms
├ 测试数据 05:答案错误...
├ 标准行输出 Wrong
├ 错误行输出 Right
├ 测试数据 06:答案正确... 0ms
├ 测试数据 07:答案正确... 0ms
├ 测试数据 08:答案正确... 0ms
├ 测试数据 09:答案正确... 0ms
├ 测试数据 10:答案正确... 0ms
---|---|---|---|---|---|---|---|-
Unaccepted 有效得分:90 有效耗时:0ms
1 条评论
-
wagnfzwxl LV 8 @ 2016-11-20 21:20:55
2 5 8 1 4 9 3 7 6 2 9 6 3 7 1 2 5 8 4 2 7 4 8 6 5 9 3 1 1 2 9 5 4 6 3 7 8 4 3 6 1 8 7 2 9 5 7 5 8 3 2 9 1 4 6 8 9 2 6 7 1 4 5 3 6 1 5 9 3 4 8 2 7 3 4 7 2 5 8 6 1 9 1 2 3 4 5 6 7 8 9 2 3 4 5 6 7 8 9 1 3 4 5 6 7 8 9 1 2 4 5 6 7 8 9 1 2 3 5 6 7 8 9 1 2 3 4 6 7 8 9 1 2 3 4 5 7 8 9 1 2 3 4 5 6 8 9 1 2 3 4 5 6 7 9 1 2 3 4 5 6 7 8
- 1