124 lines
3.5 KiB
C++
124 lines
3.5 KiB
C++
#include <cstdio>
|
|
#include <iostream>
|
|
using namespace std;
|
|
int main()
|
|
{
|
|
int a[3][3] = { 0 };
|
|
string s[3];
|
|
bool cunzai[27] = { 0 }, win[27][27] = { 0 };
|
|
int dui[10] = { 0 };
|
|
int chang = 0;
|
|
|
|
for (int i = 0; i < 3; i++) {
|
|
cin >> s[i];
|
|
for (int j = 0; j < 3; j++) {
|
|
int now = s[i][j] - 'A' + 1;
|
|
a[i][j] = now;
|
|
if (cunzai[now] != 1) {
|
|
cunzai[now] = 1;
|
|
dui[++chang] = now;
|
|
}
|
|
}
|
|
}
|
|
|
|
// for(int i=0;i<3;i++){
|
|
// for(int j=0;j<3;j++){
|
|
// cout<<a[i][j]<<" ";
|
|
// }
|
|
// cout<<endl;
|
|
// }
|
|
|
|
int ans = 0, dan = 0;
|
|
for (int i = 0; i < 3; i++) {
|
|
if (a[i][0] == a[i][1] && a[i][1] == a[i][2]) {
|
|
// cout<<i<<endl;
|
|
if (win[a[i][0]][a[i][0]] == 0) {
|
|
win[a[i][0]][a[i][0]] = 1;
|
|
dan++;
|
|
}
|
|
} else {
|
|
if (a[i][0] == a[i][1] || a[i][1] == a[i][2]) {
|
|
if (win[a[i][0]][a[i][2]] == 0 && win[a[i][2]][a[i][0]] == 0) {
|
|
ans++;
|
|
win[a[i][0]][a[i][2]] = 1;
|
|
}
|
|
} else {
|
|
if (a[i][0] == a[i][2]) {
|
|
if (win[a[i][0]][a[i][1]] == 0 && win[a[i][1]][a[i][0]] == 0) {
|
|
ans++;
|
|
win[a[i][0]][a[i][1]] = 1;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
for (int i = 0; i < 3; i++) {
|
|
if (a[0][i] == a[1][i] && a[1][i] == a[2][i]) {
|
|
if (win[a[0][i]][a[0][i]] == 0) {
|
|
win[a[0][i]][a[0][i]] = 1;
|
|
dan++;
|
|
}
|
|
} else {
|
|
if (a[0][i] == a[1][i] || a[1][i] == a[2][i]) {
|
|
if (win[a[0][i]][a[2][i]] == 0 && win[a[2][i]][a[0][i]] == 0) {
|
|
ans++;
|
|
win[a[0][i]][a[2][i]] = 1;
|
|
}
|
|
} else {
|
|
if (a[0][i] == a[2][i]) {
|
|
if (win[a[0][i]][a[1][i]] == 0 && win[a[1][i]][a[0][i]] == 0) {
|
|
ans++;
|
|
win[a[0][i]][a[1][i]] = 1;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
int tou = a[0][0], zhong = a[1][1], wei = a[2][2];
|
|
if (tou == zhong && tou == wei) {
|
|
if (win[tou][tou] == 0) {
|
|
win[tou][tou] = 1;
|
|
dan++;
|
|
}
|
|
} else {
|
|
if (tou == zhong || zhong == wei) {
|
|
if (win[tou][wei] == 0 && win[wei][tou] == 0) {
|
|
win[tou][wei] = 1;
|
|
ans++;
|
|
}
|
|
} else {
|
|
if (tou == wei) {
|
|
if (win[tou][zhong] == 0 && win[zhong][wei] == 0) {
|
|
win[tou][zhong] == 1;
|
|
ans++;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
tou = a[2][0], wei = a[0][2];
|
|
if (tou == zhong && tou == wei) {
|
|
if (win[tou][tou] == 0) {
|
|
win[tou][tou] = 1;
|
|
dan++;
|
|
}
|
|
} else {
|
|
if (tou == zhong || zhong == wei) {
|
|
if (win[tou][wei] == 0 && win[wei][tou] == 0) {
|
|
win[tou][wei] = 1;
|
|
ans++;
|
|
}
|
|
} else {
|
|
if (tou == wei) {
|
|
if (win[tou][zhong] == 0 && win[zhong][wei] == 0) {
|
|
win[tou][zhong] == 1;
|
|
ans++;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
cout << dan << endl;
|
|
cout << ans;
|
|
}
|