結果

問題 No.179 塗り分け
ユーザー CleyLCleyL
提出日時 2022-09-21 14:00:03
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,423 bytes
コンパイル時間 866 ms
コンパイル使用メモリ 93,240 KB
実行使用メモリ 10,960 KB
最終ジャッジ日時 2023-08-23 19:56:42
合計ジャッジ時間 5,934 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

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 = 0; h > k; k++){
        for(int l = 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].count({k,l})){

              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