結果
問題 | No.179 塗り分け |
ユーザー |
|
提出日時 | 2019-07-12 16:20:30 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,390 bytes |
コンパイル時間 | 634 ms |
コンパイル使用メモリ | 68,992 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-11-17 18:11:02 |
合計ジャッジ時間 | 2,048 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | WA * 6 |
other | WA * 40 |
ソースコード
#include <iostream> #include <vector> #include <queue> #include <algorithm> #include <cstring> #include <math.h> #include <string> using namespace std; #define MAX 10001 bool dp[MAX]; bool IsPrime(int num) { if (num < 2) return false; else if (num == 2) return true; else if (num % 2 == 0) return false; // 偶数はあらかじめ除く double sqrtNum = sqrt((double)num); for (int i = 3; i <= sqrtNum; i += 2) { if (num % i == 0) { // 素数ではない return false; } } // 素数である return true; } int main() { int H, W; cin >> H >> W; int table[51][51]; int cnt = 0; for(int i = 0 ; i < H ; ++i) { string s; cin >> s; for(int j = 0 ; j < W ; ++j) { table[i][j] = s.at(j) == '#' ? 1 : 0; if(table[i][j]) ++cnt; } } if((cnt%2) != 0 || cnt ==0) { cout << "No"; return 0; } for(int i = 0 ; i < W ; ++i)for(int j = 0 ; j < H ; ++j) { int m[51][51]; for(int k = 0 ; k < W ; ++k)for(int l = 0 ; l < H ; ++l) { m[k][l] = table[k][l]; } int x, y; for(x = 0 ; x < W ; ++x)for(y = 0 ; y < H ; ++y) { if(m[x][y] != 1) continue; if(x+i < W && y+j < H && m[x+i][y+j] == 1) { m[x][y] = 2;//red m[x+i][y+j] = 3;//blue } break; } if(x == W && y == H) { cout << "Yes"; return 0; } } cout << "No"; return 0; }