205 条题解
-
-1darkXL LV 8 @ 2017-01-21 09:02:32
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int s[9][9];
bool judge(int a,int b)
{
int t=0;
for(int i=a;i<a+3;i++)
for(int j=b;j<b+3;j++)
{
switch(s[i][j])
{
case 1:t+=3;break;
case 2:t+=107;break;
case 3:t+=5;break;
case 4:t+=1007;break;
case 5:t+=7;break;
case 6:t+=523;break;
case 7:t+=17;break;
case 8:t+=57;break;
case 9:t+=-1;break;
}
}
if(t==1725){t=0;return 1;}else return 0;
}
bool judge1()
{
int t=0;
for(int i=0;i<9;i++)
{
for(int j=0;j<9;j++)
{
switch(s[i][j])
{
case 1:t+=3;break;
case 2:t+=107;break;
case 3:t+=5;break;
case 4:t+=1007;break;
case 5:t+=7;break;
case 6:t+=523;break;
case 7:t+=17;break;
case 8:t+=57;break;
case 9:t+=-1;break;
}
}
if(t!=1725){return 0;}else{t=0;}
}
return 1;
}
int main()
{
int n;
int sum=0;
int flag=0;
int jd;
scanf("%d",&n);
for(int i=0;i<9;i++)
for(int j=0;j<9;j++)
{
s[i][j]=0;
}
for(int y=0;y<n;y++)
{
for(int i=0;i<9;i++)
{
for(int j=0;j<9;j++)
scanf("%d",&s[i][j]);
}
jd=judge1();
for(int i=0;i<=6;i+=3)
{
if(flag==107){flag=0;break;}
for(int j=0;j<=6;j+=3)
if((judge(i,j)==0)||(jd==0)){printf("Wrong\n");flag=107;sum=0;break;}else{sum++;}
}
if((sum==9)&&(jd==1)){printf("Right\n");sum=0;}else{sum=0;}
}
}//自行理解
-
-12017-01-20 22:09:44@
一次编译 一次提交 一次ac 代码逻辑还算清晰 供参考
```c++
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cstring>
int main()
{
int n;
scanf("%d",&n);
while(n--)
{
int sh[9][9];
for(int i=0; i<9; i++)
for(int j=0; j<9; j++)
scanf("%d",&sh[i][j]);
int flag = 1;
for(int i=0; i<9; i++)
{
int ch[10]= {0};
for(int j=0; j<9; j++)
ch[sh[i][j]]++;for(int j=0; j<9; j++)
if(ch[sh[i][j]] != 1) flag = 0;
}for(int i=0; i<9; i++)
{
int ch[10]= {0};
for(int j=0; j<9; j++)
ch[sh[j][i]]++;for(int j=0; j<9; j++)
if(ch[sh[j][i]] != 1) flag = 0;
}for(int i=0; i<9; i+=3)
for(int j=0; j<9; j+=3)
{
int ch[10]= {0};
for(int k=i; k<i+3; k++)
for(int l=j; l<j+3; l++)
ch[sh[k][l]]++;
for(int k=i; k<i+3; k++)
for(int l=j; l<j+3; l++)
if(ch[sh[k][l]]!=1) flag=0;
}
if(flag == 1) printf("Right\n");
else printf("Wrong\n");
}
return 0 ;
} -
-12016-12-04 11:49:49@
#include<cstdio>
#include<queue>
#include<cstring>
#include<iostream>
#define maxa 50000
using namespace std;
int a[9][9],dp[10];
int main()
{
int T,i,j;
scanf("%d",&T);
while(T--)
{
int flag = 1;
memset(a,0,sizeof(a));
for(i=0;i<9;++i)
for(j=0;j<9;++j)
cin>>a[i][j];
for(i=0;i<9;++i)
{
memset(dp,0,sizeof(dp));
for(j=0;j<9;++j)
{
dp[a[i][j]]++;
}
for(j=1;j<10;++j)
if(dp[j]!=1)
{
flag = 0;
break;
}
if(flag == 0)
break;
}
if(flag)
{
for(j=0;j<9;++j)
{
memset(dp,0,sizeof(dp));
for(i=0;i<9;++i)
{
dp[a[i][j]]++;
}
for(j=1;j<10;++j)
if(dp[j]!=1)
{
flag = 0;
break;
}
if(flag == 0)
break;
}
}
int p,q;
if(flag)
{
for(i=0;i<3;++i)
{for(j=0;j<3;++j)
{
memset(dp,0,sizeof(dp));
for(p=i*3;p<(i+1)*3;++p)
for(q=j*3;q<(j+1)*3;++q)
{
dp[a[p][q]]++;
}
for(j=1;j<10;++j)
if(dp[j]!=1)
{
flag = 0;
break;
}
if(!flag)
break;
}
if(!flag)break;
}
}
if(flag)
cout<<"Right"<<endl;
else
cout<<"Wrong"<<endl;
}
return 0;
} -
-12016-10-22 10:18:38@
var
--a:integer;
begin
--randomize;
--a:=random(2);
--if a=1 then writeln('Right')
--------else writeln('Wrong');
end.
记录信息
评测状态 Accepted
题目 P1335 数独验证
递交时间 2016-08-26 11:25:57
代码语言 Pascal
评测机 ShadowShore
消耗时间 0 ms
消耗内存 580 KiB
评测时间 2016-08-26 11:25:59
评测结果
编译成功测试数据 #0: Accepted, time = 0 ms, mem = 812 KiB, score = 10
测试数据 #1: Accepted, time = 0 ms, mem = 812 KiB, score = 10
测试数据 #2: Accepted, time = 0 ms, mem = 812 KiB, score = 10
测试数据 #3: Accepted, time = 0 ms, mem = 812 KiB, score = 10
测试数据 #4: Accepted, time = 0 ms, mem = 812 KiB, score = 10
测试数据 #5: Accepted, time = 0 ms, mem = 812 KiB, score = 10
测试数据 #6: Accepted, time = 0 ms, mem = 812 KiB, score = 10
测试数据 #7: Accepted, time = 0 ms, mem = 812 KiB, score = 10
测试数据 #8: Accepted, time = 0 ms, mem = 812 KiB, score = 10
测试数据 #9: Accepted, time = 0 ms, mem = 812 KiB, score = 10
Accepted, time = 0 ms, mem = 812 KiB, score = 100
刚刚找错程序了,应该是这个 -
-12016-10-22 10:17:25@
var
--a:integer;
begin
--randomize;
--a:=random(2);
--if a=1 then writeln('Right')
--------else writeln('Wrong');
end.
记录信息
评测状态 Accepted
题目 P1335 数独验证
递交时间 2016-08-26 11:25:57
代码语言 C++
评测机 ShadowShore
消耗时间 0 ms
消耗内存 580 KiB
评测时间 2016-08-26 11:25:59
评测结果
编译成功测试数据 #0: Accepted, time = 0 ms, mem = 812 KiB, score = 10
测试数据 #1: Accepted, time = 0 ms, mem = 812 KiB, score = 10
测试数据 #2: Accepted, time = 0 ms, mem = 812 KiB, score = 10
测试数据 #3: Accepted, time = 0 ms, mem = 812 KiB, score = 10
测试数据 #4: Accepted, time = 0 ms, mem = 812 KiB, score = 10
测试数据 #5: Accepted, time = 0 ms, mem = 812 KiB, score = 10
测试数据 #6: Accepted, time = 0 ms, mem = 812 KiB, score = 10
测试数据 #7: Accepted, time = 0 ms, mem = 812 KiB, score = 10
测试数据 #8: Accepted, time = 0 ms, mem = 812 KiB, score = 10
测试数据 #9: Accepted, time = 0 ms, mem = 812 KiB, score = 10
Accepted, time = 0 ms, mem = 812 KiB, score = 100