結果

問題 No.351 市松スライドパズル
ユーザー simansiman
提出日時 2016-03-27 22:56:22
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 784 ms / 2,000 ms
コード長 1,318 bytes
コンパイル時間 848 ms
コンパイル使用メモリ 78,572 KB
実行使用メモリ 402,184 KB
最終ジャッジ日時 2023-10-25 07:42:40
合計ジャッジ時間 7,783 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 225 ms
11,544 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 1 ms
4,348 KB
testcase_08 AC 1 ms
4,348 KB
testcase_09 AC 1 ms
4,348 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 AC 2 ms
4,348 KB
testcase_12 AC 2 ms
4,348 KB
testcase_13 AC 784 ms
402,068 KB
testcase_14 AC 637 ms
402,184 KB
testcase_15 AC 641 ms
402,184 KB
testcase_16 AC 643 ms
402,184 KB
testcase_17 AC 639 ms
402,184 KB
testcase_18 AC 641 ms
402,184 KB
testcase_19 AC 642 ms
402,184 KB
testcase_20 AC 638 ms
402,184 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <limits.h>
#include <time.h>
#include <string>
#include <string.h>
#include <sstream>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <stack>
#include <queue>

using namespace std;

typedef long long ll;

const int WHITE = 0;
const int BLACK = 1;

int main(){
  int h, w;
  cin >> h >> w;
  int n;
  cin >> n;
  int field[h][w];

  int val = WHITE;

  for(int y = 0; y < h; y++){
    int num = val;
    for(int x = 0; x < w; x++){
      field[y][x] = num;
      num ^= 1;
    }
    val ^= 1;
  }

  char s;
  int k;
  vector<pair<char, int> > query;

  for(int i = 0; i < n; i++){
    cin >> s >> k;

    query.push_back(pair<char,int>(s,k));
  }

  reverse(query.begin(), query.end());

  int curY = 0;
  int curX = 0;

  for(int i = 0; i < n; i++){
    pair<char, int> q = query[i];

    if (q.first == 'R'){
      if (q.second == curY){
        if (curX == 0){
          curX = w-1;
        }else{
          curX--;
        }
      }
    }else{
      if (q.second == curX){
        if (curY == 0){
          curY = h-1;
        }else{
          curY--;
        }
      }
    }
  }


  if(field[curY][curX] == WHITE){
    cout << "white" << endl;
  }else{
    cout << "black" << endl;
  }

  return 0;
}
0