AcWing 1725. 组队井字游戏判断全家桶
原题链接
简单
作者:
佩奇吹风机
,
2022-04-02 10:25:04
,
所有人可见
,
阅读 135
#include<bits/stdc++.h>
using namespace std;
int main()
{
char x[3][3] ;
for( int i = 0 ; i < 3 ; i ++ )
{
for( int j = 0 ; j < 3 ; j ++ )
{
cin >> x[i][j] ;
}
}
set < char > res ;
set < pair < char , char > > ress ;
// 直接判断全家桶
if( x[0][0] == x[0][1] && x[0][1] == x[0][2] ) res.insert( x[0][2] ) ;
if( x[0][0] == x[1][1] && x[1][1] == x[2][2] ) res.insert( x[2][2] ) ;
if( x[0][0] == x[1][0] && x[1][0] == x[2][0] ) res.insert( x[2][0] ) ;
if( x[0][1] == x[1][1] && x[1][1] == x[2][1] ) res.insert( x[2][1] ) ;
if( x[0][2] == x[1][2] && x[1][2] == x[2][2] ) res.insert( x[2][2] ) ;
if( x[1][0] == x[1][1] && x[1][1] == x[1][2] ) res.insert( x[1][2] ) ;
if( x[2][0] == x[2][1] && x[2][1] == x[2][2] ) res.insert( x[2][2] ) ;
if( x[0][2] == x[1][1] && x[1][1] == x[2][0] ) res.insert( x[2][0] ) ;
for( int i = 0 ; i < 8 ; i ++ )
{
set < char > xy ;
if( i == 0 )
{
xy.insert( x[0][0] ) ;
xy.insert( x[0][1] ) ;
xy.insert( x[0][2] ) ;
}
else if( i == 1 )
{
xy.insert( x[1][1] ) ;
xy.insert( x[0][0] ) ;
xy.insert( x[2][2] ) ;
}
else if( i == 2 )
{
xy.insert( x[0][0] ) ;
xy.insert( x[1][0] ) ;
xy.insert( x[2][0] ) ;
}
else if( i == 3 )
{
xy.insert( x[0][1] ) ;
xy.insert( x[1][1] ) ;
xy.insert( x[2][1] ) ;
}
else if( i == 4 )
{
xy.insert( x[0][2] ) ;
xy.insert( x[1][2] ) ;
xy.insert( x[2][2] ) ;
}
else if( i == 5 )
{
xy.insert( x[1][0] ) ;
xy.insert( x[1][1] ) ;
xy.insert( x[1][2] ) ;
}
else if( i == 6 )
{
xy.insert( x[2][0] ) ;
xy.insert( x[2][1] ) ;
xy.insert( x[2][2] ) ;
}
else if( i == 7 )
{
xy.insert( x[0][2] ) ;
xy.insert( x[1][1] ) ;
xy.insert( x[2][0] ) ;
}
if( xy.size() == 2 )
{
vector < char > p ;
for( auto j : xy )
{
p.push_back( j ) ;
}
ress.insert( { p[0] , p[1] }) ;
}
}
cout << res.size() << endl << ress.size() ;
return 0 ;
}