結果
問題 | No.179 塗り分け |
ユーザー |
👑 |
提出日時 | 2022-09-21 13:34:03 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,696 bytes |
コンパイル時間 | 1,017 ms |
コンパイル使用メモリ | 90,592 KB |
最終ジャッジ日時 | 2025-02-07 13:19:11 |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 6 |
other | AC * 35 WA * 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[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; }