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