Gym
来源:互联网 发布:ubuntu怎样设置中文 编辑:程序博客网 时间:2024/06/03 13:16
原题:
http://codeforces.com/gym/101158/attachments
注意:表中并不是每行每列数字不重复出现
#include <iostream>#include <iomanip>#include <algorithm>#include <cstdio>#include <cstring>#include <queue>#include <deque>#include <stack>#include <string>#include <cmath>#include <vector>#include <utility>#include <set>#include <map>#include <sstream>#include <climits>//#pragma comment(linker, "/STACK:1024000000,1024000000")#define pi acos(-1.0)#define INF 2147483647using namespace std;typedef long long ll;typedef pair <int,int > P;int table[12][12];int num[10005];int main (){ memset(table,0,sizeof(table)); memset(num,0,sizeof(num)); for(int i=0; i<10; i++) for(int j=0; j<10; j++) { scanf("%d",&table[i][j]); } for(int text=0; text<=9999; text++) { int a,b,c,d,flag=text; d=flag%10; flag/=10; c=flag%10; flag/=10; b=flag%10; flag/=10; a=flag; flag=table[0][a]; flag=table[flag][b]; flag=table[flag][c]; flag=table[flag][d]; num[text]=flag; } int res=0; for(int text=0; text<=9999; text++) { int a,b,c,d,dist,flag=text; d=flag%10; flag/=10; c=flag%10; flag/=10; b=flag%10; flag/=10; a=flag; dist=num[text]; bool ok=true; for(int j=0; j<10; j++) { if(j==a) continue; flag=j*1000+b*100+c*10+d; int cnt=num[flag]; if(table[cnt][dist]==0) { ok=false; break; } } if(ok) for(int j=0; j<10; j++) { if(j==b) continue; flag=a*1000+j*100+c*10+d; int cnt=num[flag]; if(table[cnt][dist]==0) { ok=false; break; } } if(ok) for(int j=0; j<10; j++) { if(j==c) continue; flag=a*1000+b*100+j*10+d; int cnt=num[flag]; if(table[cnt][dist]==0) { ok=false; break; } } if(ok) for(int j=0; j<10; j++) { if(j==d) continue; flag=a*1000+b*100+c*10+j; int cnt=num[flag]; if(table[cnt][dist]==0) { ok=false; break; } } if(ok) for(int j=0; j<10; j++) { if(j==dist) continue; if(table[dist][j]==0) { ok=false; break; } } if(ok&&a!=b) { flag=b*1000+a*100+c*10+d; int cnt=num[flag]; if(table[cnt][dist]==0) { ok=false; } } if(ok&&b!=c) { flag=a*1000+c*100+b*10+d; int cnt=num[flag]; if(table[cnt][dist]==0) { ok=false; } } if(ok&&c!=d) { flag=a*1000+b*100+d*10+c; int cnt=num[flag]; if(table[cnt][dist]==0) { ok=false; } } if(ok&&d!=dist) { flag=a*1000+b*100+c*10+dist; int cnt=num[flag]; if(table[cnt][d]==0) { ok=false; } } if(!ok) { res++; } } printf("%d\n",res); return 0;}
阅读全文
1 0
- Gym
- Gym
- Gym
- Gym
- Gym
- Gym
- Gym
- Gym
- Gym
- Gym
- Gym
- Gym
- Gym
- Gym
- Gym
- Gym
- Gym
- Gym
- ArrayList
- 树的基本概念
- 数据仓库-模型
- SDUT_2080最长公共子序列问题
- 物联网笔记-----------Django之Json&list转str(二)
- Gym
- Zookeeper+ActiveMQ集群
- UI控件之UITableView的storyboard写法
- CentOS 7.3 中安装 JDK 及环境变量配置
- Sunscreen POJ
- JQ简单介绍
- C#堆内存分配和栈内存分配
- callable,Executor,Future
- css+html两点说明