結果
問題 | No.179 塗り分け |
ユーザー |
👑 |
提出日時 | 2022-09-21 14:00:03 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,423 bytes |
コンパイル時間 | 1,146 ms |
コンパイル使用メモリ | 88,776 KB |
最終ジャッジ日時 | 2025-02-07 13:20:05 |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 6 |
other | AC * 35 TLE * 5 |
ソースコード
#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; }