Language: C++

#include<bits/stdc++.h>
using namespace std;

/*繧ェ繧サ繝ュ繝輔ぅ繝シ繝ォ繝?/
string field[8];

/*隧穂セ。髢「謨ー*/
/*player=0 Mami / player=1 Majo*/
int Evaluation(int x,int y,int player){
  int n=0;
  int temp;
  if(player == 0){
    
    /*蜿ウ*/
    temp=0;
    for(int i=x+1 ; i < 8 ; i++){
      if(field[y][i] == 'x'){
	temp++;
      }else if(field[y][i] == 'o'){
	n+=temp;
	break;
      }else{
	break;
      }
    }
    /*蟾ヲ*/
    temp=0;
    for(int i=x-1 ; i >= 0 ; i--){
      if(field[y][i] == 'x'){
	temp++;
      }else if(field[y][i] == 'o'){
	n+=temp;
	break;
      }else{
	break;
      }
    }
    /*荳?/
    temp=0;
    for(int i=y-1 ; i >=0 ; i--){
      if(field[i][x] == 'x'){
	temp++;
      }else if(field[i][x] == 'o'){
	n+=temp;
	break;
      }else{
	break;
      }
    }
    /*荳?/
    temp=0;
    for(int i=y+1 ; i < 8 ; i++){
      if(field[i][x] == 'x'){
	temp++;
      }else if(field[i][x] == 'o'){
	n+=temp;
	break;
      }else{
	break;
      }
    }
    /*蜿ウ荳?/
    temp=0;
    for(int i=1 ; x+i < 8 && y-i >=0 ;i++){
      if(field[y-i][x+i] == 'x'){
	temp++;
      }else if(field[y-i][x+i] == 'o'){
	n+=temp;
	break;
      }else{
	break;
      }
    }
    /*蜿ウ荳?/
    temp=0;
    for(int i=1 ; x+i < 8 && y+i < 8 ; i++){
      if(field[y+i][x+i] == 'x'){
	temp++;
      }else if(field[y+i][x+i] == 'o'){
	n+=temp;
	break;
      }else{
	break;
      }
    }
    /*蟾ヲ荳?/
    temp=0;
    for(int i=1 ; x-i >= 0 && y-i >=0 ;i++){
      if(field[y-i][x-i] == 'x'){
	temp++;
      }else if(field[y-i][x-i] == 'o'){
	n+=temp;
	break;
      }else{
	break;
      }
    }
    /*蟾ヲ荳?/
    temp=0;
    for(int i=1 ; x-i >= 0 && y+i < 8 ;i++){
      if(field[y+i][x-i] == 'x'){
	temp++;
      }else if(field[y+i][x-i] == 'o'){
	n+=temp;
	break;
      }else{
	break;
      }
    }
    
  }else{
    
    /*蜿ウ*/
    temp=0;
    for(int i=x+1 ; i < 8 ; i++){
      if(field[y][i] == 'o'){
	temp++;
      }else if(field[y][i] == 'x'){
	n+=temp;
	break;
      }else{
	break;
      }
    }
    /*蟾ヲ*/
    temp=0;
    for(int i=x-1 ; i >= 0 ; i--){
      if(field[y][i] == 'o'){
	temp++;
      }else if(field[y][i] == 'x'){
	n+=temp;
	break;
      }else{
	break;
      }
    }
    /*荳?/
    temp=0;
    for(int i=y-1 ; i >=0 ; i--){
      if(field[i][x] == 'o'){
	temp++;
      }else if(field[i][x] == 'x'){
	n+=temp;
	break;
      }else{
	break;
      }
    }
    /*荳?/
    temp=0;
    for(int i=y+1 ; i < 8 ; i++){
      if(field[i][x] == 'o'){
	temp++;
      }else if(field[i][x] == 'x'){
	n+=temp;
	break;
      }else{
	break;
      }
    }
    /*蜿ウ荳?/
    temp=0;
    for(int i=1 ; x+i < 8 && y-i >=0 ;i++){
      if(field[y-i][x+i] == 'o'){
	temp++;
      }else if(field[y-i][x+i] == 'x'){
	n+=temp;
	break;
      }else{
	break;
      }
    }
    /*蜿ウ荳?/
    temp=0;
    for(int i=1 ; x+i < 8 && y+i < 8 ; i++){
      if(field[y+i][x+i] == 'o'){
	temp++;
      }else if(field[y+i][x+i] == 'x'){
	n+=temp;
	break;
      }else{
	break;
      }
    }
    /*蟾ヲ荳?/
    temp=0;
    for(int i=1 ; x-i >= 0 && y-i >=0 ;i++){
      if(field[y-i][x-i] == 'o'){
	temp++;
      }else if(field[y-i][x-i] == 'x'){
	n+=temp;
	break;
      }else{
	break;
      }
    }
    /*蟾ヲ荳?/
    temp=0;
    for(int i=1 ; x-i >= 0 && y+i < 8 ;i++){
      if(field[y+i][x-i] == 'o'){
	temp++;
      }else if(field[y+i][x-i] == 'x'){
	n+=temp;
	break;
      }else{
	break;
      }
    }
    
  }
  
  return n;
}

/*逶、髱「蜿肴丐*/
/*player=0 Mami / player=1 Majo*/
void Reflection(int x,int y,int player){
  int temp;
  if(player == 0){
    
    /*蜿ウ*/
    temp=0;
    for(int i=x+1 ; i < 8 ; i++){
      if(field[y][i] == 'x'){
	temp++;
      }else if(field[y][i] == 'o'){
	for(int j=1 ; j <= temp ; j++){
	  field[y][x+j] = 'o';
	}
	break;
      }else{
	break;
      }
    }
    /*蟾ヲ*/
    temp=0;
    for(int i=x-1 ; i >= 0 ; i--){
      if(field[y][i] == 'x'){
	temp++;
      }else if(field[y][i] == 'o'){
	for(int j=1 ; j <= temp ; j++){
	  field[y][x-j] = 'o';
	}
	break;
      }else{
	break;
      }
    }
    /*荳?/
    temp=0;
    for(int i=y-1 ; i >=0 ; i--){
      if(field[i][x] == 'x'){
	temp++;
      }else if(field[i][x] == 'o'){
	for(int j=1 ; j <= temp ; j++){
	  field[y-j][x] = 'o';
	}
	break;
      }else{
	break;
      }
    }
    /*荳?/
    temp=0;
    for(int i=y+1 ; i < 8 ; i++){
      if(field[i][x] == 'x'){
	temp++;
      }else if(field[i][x] == 'o'){
	for(int j=1 ; j <= temp ; j++){
	  field[y+j][x] = 'o';
	}
	break;
      }else{
	break;
      }
    }
    /*蜿ウ荳?/
    temp=0;
    for(int i=1 ; x+i < 8 && y-i >=0 ;i++){
      if(field[y-i][x+i] == 'x'){
	temp++;
      }else if(field[y-i][x+i] == 'o'){
	for(int j=1 ; j <= temp ; j++){
	  field[y-j][x+j] = 'o';
	}
	break;
      }else{
	break;
      }
    }
    /*蜿ウ荳?/
    temp=0;
    for(int i=1 ; x+i < 8 && y+i < 8 ; i++){
      if(field[y+i][x+i] == 'x'){
	temp++;
      }else if(field[y+i][x+i] == 'o'){
	for(int j=1 ; j <= temp ; j++){
	  field[y+j][x+j] = 'o';
	}
	break;
      }else{
	break;
      }
    }
    /*蟾ヲ荳?/
    temp=0;
    for(int i=1 ; x-i >= 0 && y-i >=0 ;i++){
      if(field[y-i][x-i] == 'x'){
	temp++;
      }else if(field[y-i][x-i] == 'o'){
	for(int j=1 ; j <= temp ; j++){
	  field[y-j][x-j] = 'o';
	}
	break;
      }else{
	break;
      }
    }
    /*蟾ヲ荳?/
    temp=0;
    for(int i=1 ; x-i >= 0 && y+i < 8 ;i++){
      if(field[y+i][x-i] == 'x'){
	temp++;
      }else if(field[y+i][x-i] == 'o'){
	for(int j=1 ; j <= temp ; j++){
	  field[y+j][x-j] = 'o';
	}
	break;
      }else{
	break;
      }
    }
    
  }else{
    
    /*蜿ウ*/
    temp=0;
    for(int i=x+1 ; i < 8 ; i++){
      if(field[y][i] == 'o'){
	temp++;
      }else if(field[y][i] == 'x'){
	for(int j=1 ; j <= temp ; j++){
	  field[y][x+j] = 'x';
	}
	break;
      }else{
	break;
      }
    }
    /*蟾ヲ*/
    temp=0;
    for(int i=x-1 ; i >= 0 ; i--){
      if(field[y][i] == 'o'){
	temp++;
      }else if(field[y][i] == 'x'){
	for(int j=1 ; j <= temp ; j++){
	  field[y][x-j] = 'x';
	}
	break;
      }else{
	break;
      }
    }
    /*荳?/
    temp=0;
    for(int i=y-1 ; i >=0 ; i--){
      if(field[i][x] == 'o'){
	temp++;
      }else if(field[i][x] == 'x'){
	for(int j=1 ; j <= temp ; j++){
	  field[y-j][x] = 'x';
	}
	break;
      }else{
	break;
      }
    }
    /*荳?/
    temp=0;
    for(int i=y+1 ; i < 8 ; i++){
      if(field[i][x] == 'o'){
	temp++;
      }else if(field[i][x] == 'x'){
	for(int j=1 ; j <= temp ; j++){
	  field[y+j][x] = 'x';
	}
	break;
      }else{
	break;
      }
    }
    /*蜿ウ荳?/
    temp=0;
    for(int i=1 ; x+i < 8 && y-i >=0 ;i++){
      if(field[y-i][x+i] == 'o'){
	temp++;
      }else if(field[y-i][x+i] == 'x'){
	for(int j=1 ; j <= temp ; j++){
	  field[y-j][x+j] = 'x';
	}
	break;
      }else{
	break;
      }
    }
    /*蜿ウ荳?/
    temp=0;
    for(int i=1 ; x+i < 8 && y+i < 8 ; i++){
      if(field[y+i][x+i] == 'o'){
	temp++;
      }else if(field[y+i][x+i] == 'x'){
	for(int j=1 ; j <= temp ; j++){
	  field[y+j][x+j] = 'x';
	}
	break;
      }else{
	break;
      }
    }
    /*蟾ヲ荳?/
    temp=0;
    for(int i=1 ; x-i >= 0 && y-i >=0 ;i++){
      if(field[y-i][x-i] == 'o'){
	temp++;
      }else if(field[y-i][x-i] == 'x'){
	for(int j=1 ; j <= temp ; j++){
	  field[y-j][x-j] = 'x';
	}
	break;
      }else{
	break;
      }
    }
    /*蟾ヲ荳?/
    temp=0;
    for(int i=1 ; x-i >= 0 && y+i < 8 ;i++){
      if(field[y+i][x-i] == 'o'){
	temp++;
      }else if(field[y+i][x-i] == 'x'){
	for(int j=1 ; j <= temp ; j++){
	  field[y+j][x-j] = 'x';
	}
	break;
      }else{
	break;
      }
    }
    
  }
}
/*逶、髱「縺悟?縺ヲ蝓九∪縺」縺ヲ縺?◆繧液rue*/

bool flag1,flag2;

bool Mami(){
  bool flag = true;
  int n=0,x,y;
  for(int i=0 ; i < 8 ; i++){
    for(int j=0 ; j < 8 ; j++){
      if(field[i][j] == '.'){
	int temp = Evaluation(j,i,0);
	if(temp > n){
	  n = temp;
	  x = j;
	  y = i;
 	}
	flag = false;
      }
    }
  }
  if(n > 0){
    field[y][x]='o';
    Reflection(x,y,0);
    flag1 = false;
  }
  return flag;
}

bool Majo(){
  bool flag = true;
  int n=0,x,y;
  for(int i=7 ; i >= 0 ; i--){
    for(int j=7 ; j >= 0 ; j--){
      if(field[i][j] == '.'){
	int temp = Evaluation(j,i,1);
	if(temp > n){
	  n = temp;
	  x = j;
	  y = i;
 	}
	flag = false;
      }
    }
  }
  if(n > 0){
    field[y][x]='x';
    Reflection(x,y,1);
    flag2 = false;
  }
  return flag;
}

int main(){ 
  
  for(int i=0 ; i < 8 ; i++)cin >>field[i];
  
  /*o縺九ｉ繧ケ繧ソ繝シ繝?/
  int player = 0; // 0:o 1:x
  int cnt=0;
  /*鄂ョ縺?※縺ェ縺??謇?′縺ェ縺上↑繧?縺セ縺溘?縺ゥ縺。繧峨ｂ鄂ョ縺代↑縺上↑繧九∪縺ァ*/
  while(1){
    flag1=true;
    flag2=true;
    if(player%2 == 0){
      if(Mami())break;
    }else{
      if(Majo())break;
    }
    if(flag1 == true && flag2 == true)cnt++;
    if(flag1 == false || flag2 == false)cnt=0;
    if(cnt > 1)break;
    // if(player==17)break;
    player++;
  }
  
  /*逶、髱「蜃コ蜉?/
  for(int i=0 ; i < 8 ; i++)cout <<field[i]<<endl;
  
  return 0;
}

Compiler output:
a.cc:526:3: error: unterminated comment
  526 |   /*逶、髱「蜃コ蜉?/
      |   ^
a.cc: In function 'int Evaluation(int, int, int)':
a.cc:17:10: error: 'field' was not declared in this scope
   17 |       if(field[y][i] == 'x'){
      |          ^~~~~
a.cc:29:10: error: 'field' was not declared in this scope
   29 |       if(field[y][i] == 'x'){
      |          ^~~~~
a.cc:116:10: error: 'field' was not declared in this scope
  116 |       if(field[y][i] == 'o'){
      |          ^~~~~
a.cc:128:10: error: 'field' was not declared in this scope
  128 |       if(field[y][i] == 'o'){
      |          ^~~~~
a.cc:217:40: error: a function-definition is not allowed here before '{' token
  217 | void Reflection(int x,int y,int player){
      |                                        ^
a.cc:524:4: error: expected '}' at end of input
  524 |   }
      |    ^
a.cc:12:18: note: to match this '{'
   12 |   if(player == 0){
      |                  ^
a.cc:524:4: error: expected '}' at end of input
  524 |   }
      |    ^
a.cc:9:39: note: to match this '{'
    9 | int Evaluation(int x,int y,int player){
      |                                       ^
a.cc:524:4: warning: no return statement in function returning non-void [-Wreturn-type]
  524 |   }
      |    ^