結果

提出番号 1430
提出者 ok
言語 C++
提出日時 2018-08-03 21:36:02
問題名 (42)オセロ
結果 AC
点数 100%

テストケース

テストケース 結果 得点 実行時間 メモリ使用量
1 AC 100% 2ms 8688KB
2 AC 100% 2ms 7984KB
3 AC 100% 2ms 8544KB
4 AC 100% 1ms 8080KB
5 AC 100% 2ms 8416KB

ソースコード

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

int main(){
	int wb, coordinate[2];
	string str[10], temp;
	char ch[2] = {'b', 'w'};
	for(int i = 0; i < 8; i++)cin>>str[i];
	cin>>wb>>temp;
	coordinate[0] =temp[1]-'1'; coordinate[1] = temp[0] - 'A';
	str[coordinate[0]][coordinate[1]]=ch[wb];
	for(int i = -1; i <= 1; i++){
		for(int j =-1; j <= 1; j++){
			if(!i&&!j)continue;
			int x = coordinate[1]+j, y = coordinate[0]+i, count = 0;
			while(1){//cout<<y<<" "<<x<<" "<<str[y][x]<<endl;
				if(y<0||y>=8||x<0||x>=8)break;
				count++;
				if(str[y][x] == ch[wb]){
					for(int k=1; k< count; k++)
						str[coordinate[0]+i*k][coordinate[1]+j*k] = ch[wb];
					break;
				}else if(str[y][x]=='-')break;
				y+=i;x+=j;
			}//cout<<endl;
		}
	}
	for(int i = 0; i < 8; i++)cout<<str[i]<<endl;
  return 0;
}