結果

問題 No.179 塗り分け
ユーザー CleyLCleyL
提出日時 2022-09-21 13:34:03
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,696 bytes
コンパイル時間 1,467 ms
コンパイル使用メモリ 95,264 KB
実行使用メモリ 147,528 KB
最終ジャッジ日時 2023-08-23 19:56:22
合計ジャッジ時間 13,776 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 14 ms
6,428 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 24 ms
28,444 KB
testcase_09 WA -
testcase_10 AC 1,888 ms
147,528 KB
testcase_11 AC 1,453 ms
127,112 KB
testcase_12 AC 1,543 ms
124,784 KB
testcase_13 AC 1 ms
4,376 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 2 ms
4,380 KB
testcase_18 AC 327 ms
55,192 KB
testcase_19 AC 301 ms
50,808 KB
testcase_20 AC 1 ms
4,376 KB
testcase_21 AC 2 ms
4,376 KB
testcase_22 AC 29 ms
28,528 KB
testcase_23 AC 97 ms
37,772 KB
testcase_24 AC 28 ms
29,632 KB
testcase_25 AC 27 ms
28,628 KB
testcase_26 WA -
testcase_27 AC 167 ms
40,752 KB
testcase_28 WA -
testcase_29 AC 363 ms
56,392 KB
testcase_30 WA -
testcase_31 AC 498 ms
65,224 KB
testcase_32 AC 636 ms
75,600 KB
testcase_33 AC 606 ms
72,412 KB
testcase_34 WA -
testcase_35 AC 742 ms
83,632 KB
testcase_36 AC 1 ms
4,376 KB
testcase_37 AC 2 ms
4,376 KB
testcase_38 AC 2 ms
4,376 KB
testcase_39 AC 2 ms
4,376 KB
testcase_40 AC 2 ms
4,376 KB
testcase_41 AC 2 ms
4,384 KB
testcase_42 AC 1 ms
4,376 KB
testcase_43 AC 5 ms
4,376 KB
testcase_44 AC 25 ms
10,360 KB
testcase_45 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
using namespace std;
struct d{
  int a,b,c;
  bool operator<(d x){
    if(a == x.a){
      if(b == x.b){
        return c < x.c;
      }
      return b < x.b;
    }
    return a < x.a;
  }
  bool operator==(d x){
    return a==x.a && b==x.b && c==x.c;
  }
  bool operator>(d x){
    return !((*this) < x || (*this) == x);
  }
};
int main(){
  int h,w;cin>>h>>w;
  vector<vector<char>> A(h,vector<char>(w));
  int c = 0;
  for(int i = 0; h > i; i++){
    for(int j = 0; w > j; j++){
      cin>>A[i][j];
      if(A[i][j] == '#')c++;
    }
  }
  if(c%2 || c==0){
    cout << "NO" << endl;
    return 0;
  }
  int C = 0;
  set<pair<int,int>> X[h*w];
  vector<d> ZZ;
  for(int i = 0; h > i; i++){
    for(int j = 0; w > j; j++){
      for(int k = i; h > k; k++){
        for(int l = j; w > l; l++){
          //cout << (i-k)*w+(j-l)+h*w << endl;
          int tmp = (i-k)*w+(j-l)+h*w;
          ZZ.push_back({tmp,(i-k),(j-l)});
          if(i==k && j==l)continue;
          if(A[i][j] == '#' && A[k][l] == '#'){
            //cout << i-k << " " << j-l << endl;
            if(!X[tmp].count({i,j}) && !X[tmp].count({i,j})){
              X[(i-k)*w+(j-l)+h*w].insert({i,j});
              X[(i-k)*w+(j-l)+h*w].insert({k,l});
            }
          }
        }
      }
    }
  }
  //sort(ZZ.begin(),ZZ.end());
  //ZZ.erase(unique(ZZ.begin(),ZZ.end()),ZZ.end());
  //for(int i = 0; ZZ.size() > i; i++){
  //  cout << ZZ[i].a << " " << ZZ[i].b << " " << ZZ[i].c << endl;
  //}
  for(int i = 0; h*w > i; i++){
    if(X[i].size() == c){
      cout << "YES" << endl;
      return 0;
    }
  }
  cout << "NO" << endl;
}
0