結果

問題 No.179 塗り分け
ユーザー nonnon
提出日時 2019-04-20 19:35:38
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,539 bytes
コンパイル時間 1,555 ms
コンパイル使用メモリ 168,964 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-09 20:43:39
合計ジャッジ時間 2,959 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 2 ms
6,944 KB
testcase_04 WA -
testcase_05 AC 1 ms
6,944 KB
testcase_06 AC 2 ms
6,940 KB
testcase_07 WA -
testcase_08 AC 2 ms
6,944 KB
testcase_09 AC 2 ms
6,944 KB
testcase_10 AC 2 ms
6,940 KB
testcase_11 AC 1 ms
6,940 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 2 ms
6,940 KB
testcase_15 AC 1 ms
6,940 KB
testcase_16 AC 2 ms
6,944 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 2 ms
6,940 KB
testcase_20 AC 1 ms
6,944 KB
testcase_21 AC 2 ms
6,940 KB
testcase_22 WA -
testcase_23 AC 2 ms
6,940 KB
testcase_24 WA -
testcase_25 AC 2 ms
6,940 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 2 ms
6,940 KB
testcase_29 AC 2 ms
6,944 KB
testcase_30 AC 2 ms
6,940 KB
testcase_31 WA -
testcase_32 WA -
testcase_33 AC 2 ms
6,940 KB
testcase_34 AC 2 ms
6,944 KB
testcase_35 WA -
testcase_36 AC 2 ms
6,944 KB
testcase_37 AC 2 ms
6,940 KB
testcase_38 WA -
testcase_39 WA -
testcase_40 AC 1 ms
6,944 KB
testcase_41 AC 1 ms
6,940 KB
testcase_42 AC 1 ms
6,940 KB
testcase_43 AC 1 ms
6,944 KB
testcase_44 AC 1 ms
6,940 KB
testcase_45 AC 2 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

#define rep(i, n, s) for(int (i) = 0; (i) < (n); (i) += (s))

using namespace std;

int main()
{
  int h, w;
  int start = -1;
  int shap = 0;
  int blue_point = -1;
  int point_length = 0;

  cin >> h >> w;

  vector<char> s(h * w, 0);
  vector<char> check_s(h * w, 0);
  vector<int> shap_index;


  for (int i = 0; i < h * w; ++i)
  {
    cin >> s[i];

    if (s[i] == '#')
    {
      shap++;
      shap_index.push_back(i);
    }

    if (s[i] == '#' && start == -1)
    {
      start = i;
      s[i] = '.';
    }
    // else (s[i] == '#' && blue_point == -1)
    //   blue_point = i;
  }

  if (shap % 2 == 1)
  {
    cout << "NO" << endl;
    exit(0);
  }

  int count = 0;
  while(1)
  {
    check_s = s;
    count++;

    for (int i = 0; i < h * w; ++i)
    {
      if (check_s[i] == '#' && blue_point == -1)
      {
        blue_point = i;
        check_s[i] = '.';
      }

      if (check_s[i] == '#')
      {
        // 赤
        point_length = i - start;
        check_s[i] = '.';

        // 青
        if (blue_point + point_length >= h * w)
        {
          cout << "NO" << endl;
          exit(0);
        }

        if (check_s[blue_point + point_length] == '#')
          check_s[blue_point + point_length] = '.';
        else
        {
          if (i == h * w - 1)
            break;
          else
          {
            blue_point = shap_index[1 + count];
            continue;
          }
        }
      }
    }
    cout << "YES" << endl;
    exit(0);
  }
  cout << "NO" << endl;
}
0