結果

提出番号 825
提出者 kotatsugame
言語 C++
提出日時 2017-08-01 14:52:27
問題名 (42)オセロ
結果 AC
点数 100%

テストケース

テストケース 結果 得点 実行時間 メモリ使用量
1 AC 100% 2ms 8336KB
2 AC 100% 2ms 8304KB
3 AC 100% 2ms 7712KB
4 AC 100% 2ms 8304KB
5 AC 100% 2ms 8320KB

ソースコード

#include<iostream>
using namespace std;
string s[8];
int now;
char c;
int dx[]={0,1,0,-1,1,1,-1,-1},dy[]={1,0,-1,0,1,-1,1,-1};
bool dfs(int x,int y,int r)
{
	if(x<0||y<0||x>=8||y>=8)return false;
	else if(s[x][y]==c)
	{
		s[x][y]=c;
		return true;
	}
	else if(s[x][y]=='-')return false;
	else if(dfs(x+dx[r],y+dy[r],r))
	{
		s[x][y]=c;
		return true;
	}
	else return false;
}
main()
{
	for(int i=0;i<8;i++)cin>>s[i];
	string t;
	cin>>now>>t;
	c=now?'w':'b';
	int x=t[1]-'0'-1,y=t[0]-'A';
	s[x][y]=c;
	for(int r=0;r<8;r++)
	{
		dfs(x+dx[r],y+dy[r],r);
	}
	for(int i=0;i<8;i++)cout<<s[i]<<endl;
}