ソースコード
#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;
}