結果

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

テストケース

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

ソースコード

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

long long C, X, Y, s[10][10], d[9] = {0, 1, 0, -1, -1, 1, 1, -1, 0};
char S[9];

bool se(int x, int y, int I){
    if(x < 0 || y < 0 || x > 9 || y > 9)return false;
    if(s[x][y]){
        if(s[x][y] == C + 1){
            return true;
        }
        if(se(x + d[I], y + d[I + 1], I)){
            s[x][y] = C + 1;
            return true;
        }
    }
    return false;
}

int main(){
    for(int i = 0; i < 8; ++i){
        scanf("%s", S);
        for(int j = 0; j < 8; ++j){
            s[i + 1][j + 1] = (S[j] != '-') + (S[j] == 'w');
        }
    }
    scanf("%lld %c%lld", &C, &S[0], &Y);
    X = S[0] - 64;
    s[Y][X] = C + 1;
    for(int i = 0; i < 8; ++i){
        se(Y + d[i], X + d[i + 1], i);
    }
    for(int i = 0; i < 8; ++i){
        for(int j = 0; j < 8; ++j){
            cout << (s[i + 1][j + 1] ? s[i + 1][j + 1] ^ 1 ? 'w' : 'b' : '-');
        }
        cout << endl;
    }
}