比赛 |
近期练习题回顾 |
评测结果 |
AAAAAAAAAA |
题目名称 |
组队井字棋 |
最终得分 |
100 |
用户昵称 |
梦那边的美好ET |
运行时间 |
0.005 s |
代码语言 |
C++ |
内存使用 |
13.66 MiB |
提交时间 |
2018-10-31 07:38:21 |
显示代码纯文本
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
char s[4][4];int ans1=0,ans2=0,bk[30],mp[30][30];
inline int ju(int a1,int a2,int a3,int a4,int a5,int a6){
if(s[a1][a2]==s[a3][a4]&&s[a1][a2]!=s[a5][a6]){
if(!mp[s[a1][a2]-'A'][s[a5][a6]-'A']){
mp[s[a1][a2]-'A'][s[a5][a6]-'A']=mp[s[a5][a6]-'A'][s[a1][a2]-'A']=1;
return 1;
}
else return 0;
}
if(s[a1][a2]==s[a5][a6]&&s[a1][a2]!=s[a3][a4]){
if(!mp[s[a1][a2]-'A'][s[a3][a4]-'A']){
mp[s[a1][a2]-'A'][s[a3][a4]-'A']=mp[s[a3][a4]-'A'][s[a1][a2]-'A']=1;
return 1;
}
else return 0;
}
if(s[a5][a6]==s[a3][a4]&&s[a1][a2]!=s[a5][a6]){
if(!mp[s[a1][a2]-'A'][s[a5][a6]-'A']){
mp[s[a1][a2]-'A'][s[a5][a6]-'A']=mp[s[a5][a6]-'A'][s[a1][a2]-'A']=1;
return 1;
}
else return 0;
}
return 0;
}
int main(){
freopen("tttt_bronze_18open.in","r",stdin);
freopen("tttt_bronze_18open.out","w",stdout);
for(int i=1;i<=3;i++)scanf("%s",s[i]+1);
if(s[1][1]==s[1][2]&&s[1][2]==s[1][3]&&!bk[s[1][1]-'A'])ans1++,bk[s[1][1]-'A']=1;
if(s[2][1]==s[2][2]&&s[2][2]==s[2][3]&&!bk[s[2][1]-'A'])ans1++,bk[s[2][1]-'A']=1;
if(s[3][3]==s[3][2]&&s[3][2]==s[3][1]&&!bk[s[3][3]-'A'])ans1++,bk[s[3][3]-'A']=1;
if(s[1][1]==s[2][1]&&s[2][1]==s[3][1]&&!bk[s[1][1]-'A'])ans1++,bk[s[1][1]-'A']=1;
if(s[1][2]==s[2][2]&&s[2][2]==s[3][2]&&!bk[s[1][2]-'A'])ans1++,bk[s[1][2]-'A']=1;
if(s[1][3]==s[2][3]&&s[2][3]==s[3][3]&&!bk[s[1][3]-'A'])ans1++,bk[s[1][3]-'A']=1;
if(s[1][1]==s[2][2]&&s[2][2]==s[3][3]&&!bk[s[1][1]-'A'])ans1++,bk[s[1][1]-'A']=1;
if(s[1][3]==s[2][2]&&s[2][2]==s[3][1]&&!bk[s[1][3]-'A'])ans1++,bk[s[1][3]-'A']=1;
if(ju(1,1,1,2,1,3))ans2++;
if(ju(2,1,2,2,2,3))ans2++;
if(ju(3,1,3,2,3,3))ans2++;
if(ju(1,1,2,1,3,1))ans2++;
if(ju(1,2,2,2,3,2))ans2++;
if(ju(1,3,2,3,3,3))ans2++;
if(ju(1,1,2,2,3,3))ans2++;
if(ju(1,3,2,2,3,1))ans2++;
printf("%d\n",ans1);printf("%d",ans2);
return 0;
}