結果

問題 No.179 塗り分け
ユーザー CleyLCleyL
提出日時 2022-09-21 14:01:53
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 1,410 bytes
コンパイル時間 1,117 ms
コンパイル使用メモリ 93,144 KB
実行使用メモリ 208,780 KB
最終ジャッジ日時 2023-08-23 19:59:38
合計ジャッジ時間 6,142 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 19 ms
7,088 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 6 ms
4,376 KB
testcase_09 AC 6 ms
4,376 KB
testcase_10 TLE -
testcase_11 AC 2,935 ms
208,780 KB
testcase_12 AC 2,799 ms
208,360 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 2 ms
4,504 KB
testcase_16 AC 1 ms
4,376 KB
testcase_17 AC 1 ms
4,384 KB
testcase_18 AC 674 ms
64,148 KB
testcase_19 AC 591 ms
59,400 KB
testcase_20 AC 2 ms
4,380 KB
testcase_21 AC 2 ms
4,376 KB
testcase_22 AC 16 ms
6,168 KB
testcase_23 AC 153 ms
24,700 KB
testcase_24 AC 11 ms
5,208 KB
testcase_25 AC 13 ms
5,696 KB
testcase_26 AC 55 ms
12,204 KB
testcase_27 AC 206 ms
28,248 KB
testcase_28 AC 522 ms
51,976 KB
testcase_29 AC 661 ms
59,424 KB
testcase_30 AC 843 ms
73,304 KB
testcase_31 AC 1,096 ms
86,988 KB
testcase_32 AC 1,100 ms
88,256 KB
testcase_33 AC 1,063 ms
88,232 KB
testcase_34 AC 1,466 ms
114,888 KB
testcase_35 AC 1,486 ms
117,212 KB
testcase_36 AC 1 ms
4,380 KB
testcase_37 AC 1 ms
4,380 KB
testcase_38 AC 1 ms
4,384 KB
testcase_39 AC 2 ms
4,380 KB
testcase_40 AC 2 ms
4,380 KB
testcase_41 AC 2 ms
4,380 KB
testcase_42 AC 2 ms
4,380 KB
testcase_43 AC 7 ms
4,576 KB
testcase_44 AC 39 ms
10,368 KB
testcase_45 AC 2 ms
4,504 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[4*h*w];
  for(int i = 0; h > i; i++){
    for(int j = 0; w > j; j++){
      for(int k = i; h > k; k++){
        for(int l = (i==k?j+1:0); w > l; l++){
          //cout << (i-k)*w+(j-l)+h*w << endl;
          int tmp = (i-k)*2*w+(j-l)+2*h*w;
          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].insert({i,j});
              X[tmp].insert({k,l});
            }
          }
        }
      }
    }
  }

  for(int i = 0; 4*h*w > i; i++){
    if(X[i].size() == c){
      cout << "YES" << endl;
      return 0;
    }
  }
  cout << "NO" << endl;
}
0