#include <bits/stdc++.h>
#define int long long
using namespace std;
char a[4][4];
bool xf,of;
int xsl,osl,ksl,oysl,xysl;
signed main(){
for(int i=1;i<=3;i++){
for(int j=1;j<=3;j++){
cin>>a[i][j];
if(a[i][j]=='0') osl++;
if(a[i][j]=='X') xsl++;
}
}
ksl=9-osl-xsl;
if(a[1][1]=='0' && a[1][2]=='0' && a[1][3]=='0') of=true,oysl++;
if(a[2][1]=='0' && a[2][2]=='0' && a[2][3]=='0') of=true,oysl++;
if(a[3][1]=='0' && a[3][2]=='0' && a[3][3]=='0') of=true,oysl++;
if(a[1][1]=='0' && a[2][1]=='0' && a[3][1]=='0') of=true,oysl++;
if(a[1][2]=='0' && a[2][2]=='0' && a[3][2]=='0') of=true,oysl++;
if(a[1][3]=='0' && a[2][3]=='0' && a[3][3]=='0') of=true,oysl++;
if(a[1][1]=='0' && a[2][2]=='0' && a[3][3]=='0') of=true,oysl++;
if(a[1][3]=='0' && a[2][2]=='0' && a[3][1]=='0') of=true,oysl++;
if(a[1][1]=='X' && a[1][2]=='X' && a[1][3]=='X') xf=true,xysl++;
if(a[2][1]=='X' && a[2][2]=='X' && a[2][3]=='X') xf=true,xysl++;
if(a[3][1]=='X' && a[3][2]=='X' && a[3][3]=='X') xf=true,xysl++;
if(a[1][1]=='X' && a[2][1]=='X' && a[3][1]=='X') xf=true,xysl++;
if(a[1][2]=='X' && a[2][2]=='X' && a[3][2]=='X') xf=true,xysl++;
if(a[1][3]=='X' && a[2][3]=='X' && a[3][3]=='X') xf=true,xysl++;
if(a[1][1]=='X' && a[2][2]=='X' && a[3][3]=='X') xf=true,xysl++;
if(a[1][3]=='X' && a[2][2]=='X' && a[3][1]=='X') xf=true,xysl++;
if((xsl!=osl && xsl!=(osl+1)) || (of==true && xf==true) || (of==true && xsl>=osl) || (xf==true && osl>=xsl) || xysl>4 || oysl>4){
cout<<"illegal";
}else if(of==true && xf==false){
cout<<"the second player won";
}else if(of==false && xf==true){
cout<<"the first player won";
}else if(ksl==0){
cout<<"draw";
}else if(xsl==osl){
cout<<"first";
}else{
cout<<"second";
}
return 0;
}
找不出错了,求助!!!