結果

問題 No.870 無敵囲い
ユーザー ut0sut0s
提出日時 2019-08-30 21:57:47
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 300 ms
コード長 1,419 bytes
コンパイル時間 2,048 ms
コンパイル使用メモリ 171,792 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-11 16:11:35
合計ジャッジ時間 2,905 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,384 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 1 ms
4,376 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 2 ms
4,376 KB
testcase_18 AC 1 ms
4,380 KB
testcase_19 AC 2 ms
4,376 KB
testcase_20 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

/**
  @file 870.cpp
  @title  No.870 無敵囲い - yukicoder
  @url https://yukicoder.me/problems/no/870
**/

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

typedef long long LL;
#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, N) for (int i = 0; i < (N); ++i)

int main() {
  int N;
  cin >> N;

  vector<string> xy(N, "");
  string tmp0, tmp1, tmp2, tmp3;
  REP(i, N) {
    cin >> tmp0 >> tmp1 >> tmp2 >> tmp3;
    xy[i] = tmp0 + tmp1 + tmp2 + tmp3;
  }

  // vector<vector<pair<bool, string>>> grid(9, vector<pair<bool, string>>(9));
  pair<bool, string> grid[10][10];

  REP(i, 10) {
    REP(j, 10) {
      grid[i][j].first  = false;
      grid[i][j].second = "";
    }
  }

  grid[2][8].first  = true;
  grid[2][8].second = "A";
  grid[3][9].first  = true;
  grid[3][9].second = "B";
  grid[7][9].first  = true;
  grid[7][9].second = "C";

  REP(i, N) {
    int x1 = stoi(xy[i].substr(0, 1));
    int y1 = stoi(xy[i].substr(1, 1));
    int x2 = stoi(xy[i].substr(2, 1));
    int y2 = stoi(xy[i].substr(3, 1));

    grid[x1][y1].first  = false;
    grid[x2][y2].first  = true;
    grid[x2][y2].second = grid[x1][y1].second;
    grid[x1][y1].second = "";
  }

  if (grid[5][8].first && grid[5][8].second == "A"
      && grid[4][8].first && grid[4][8].second == "B"
      && grid[6][8].first && grid[6][8].second == "C") {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }

  return 0;
}
0