結果

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

テストケース

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

ソースコード

#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "math.h"
#include "utility"
#include "string"
#include "map"
#include "unordered_map"
#include "iomanip"
#include "random"

using namespace std;
const long long int MOD = 1000000007;

long long int power(long long int x, long long int n, long long int M) {
	long long int tmp = 1;

	if (n > 0) {
		tmp = power(x, n / 2, M);
		if (n % 2 == 0) tmp = (tmp*tmp) % M;
		else tmp = (((tmp*tmp) % M)*x) % M;
	}
	return tmp;
}

long long int N, M, K, Q, W, H, L, R;
long long int ans;



int main() {
	ios::sync_with_stdio(false);
	string s[10];
	string t;
	for (int i = 1; i <= 8; i++)cin >> s[i];
	for (int i = 1; i <= 8; i++) {
		s[i] = '-' + s[i] + '-';
	}
	for (int i = 1; i < 10; i++) {
		s[0] += '-';
		s[9] += '-';
	}
	cin >> N;
	char p;
	if (N)p = 'w';
	else p = 'b';
	cin >> t;
	int x, y;
	x = t[0] - 'A' + 1;
	y = t[1] - '0';
	int dx[] = { 1,1,1,0,-1,-1,-1,0 };
	int dy[] = { 1,0,-1,-1,-1,0,1,1 };
	for (int i = 0; i < 8; i++) {
		int depth = 1;
		while (s[y + depth*dy[i]][x + depth*dx[i]]!=p&&s[y + depth*dy[i]][x + depth*dx[i]]!='-') {
			depth++;
		//	cout << i << " " << depth << endl;
		}
		if (s[y + depth*dy[i]][x + depth*dx[i]] == p) {
			while (depth>=0) {
				s[y + depth*dy[i]][x + depth*dx[i]] = p;
				depth--;
			}
		}
	}
	for (int i = 1; i <= 8; i++) {
		for (int j = 1; j <= 8; j++) {
			cout << s[i][j];
		}
		cout << endl;
	}
	return 0;
}