結果
問題 | No.179 塗り分け |
ユーザー |
|
提出日時 | 2017-09-27 03:47:49 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,614 bytes |
コンパイル時間 | 699 ms |
コンパイル使用メモリ | 78,980 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-15 16:58:38 |
合計ジャッジ時間 | 2,311 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 6 |
other | AC * 35 WA * 5 |
ソースコード
#define _CRT_SECURE_NO_WARNINGS #include <iostream> #include <cmath> #include <string> #include <vector> #include <algorithm> #include <queue> #include <map> #include <functional> #include <set> #include <numeric> #include <stack> #include <utility> #include <time.h> //#include "util.h" using namespace std; typedef unsigned uint; typedef long long ll; typedef unsigned long long ull; template <typename _KTy, typename _Ty> ostream& operator << (ostream& ostr, const pair<_KTy, _Ty>& m) { cout << "{" << m.first << ", " << m.second << "}"; return ostr; } template <typename _KTy, typename _Ty> ostream& operator << (ostream& ostr, const map<_KTy, _Ty>& m) { if (m.empty()) { cout << "{ }"; return ostr; } cout << "{" << *m.begin(); for (auto itr = ++m.begin(); itr != m.end(); itr++) { cout << ", " << *itr; } cout << "}"; return ostr; } template <typename _Ty> ostream& operator << (ostream& ostr, const vector<_Ty>& v) { if (v.empty()) { cout << "{ }"; return ostr; } cout << "{" << v.front(); for (auto itr = ++v.begin(); itr != v.end(); itr++) { cout << ", " << *itr; } cout << "}"; return ostr; } template <typename _Ty> ostream& operator << (ostream& ostr, const set<_Ty>& s) { if (s.empty()) { cout << "{ }"; return ostr; } cout << "{" << *(s.begin()); for (auto itr = ++s.begin(); itr != s.end(); itr++) { cout << ", " << *itr; } cout << "}"; return ostr; } #define PI 3.14159265358979323846 #define EPS 1e-6 #define MIN(a,b) ((a)<(b)?(a):(b)) #define MAX(a,b) ((a)>(b)?(a):(b)) #define all(x) (x).begin(), (x).end() bool tr(vector<string> S, int w, int h, int b) { int H = S.size(); int W = S[0].size(); for (int y = 0; y < H - h; y++) { for (int x = 0; x < W - w; x++) { if (S[y][x] == '.') continue; if (S[y + h][x + w] == '.') return false; S[y][x] = S[y + h][x + w] = '.'; b -= 2; if (b == 0) return true; } } return false; } int yuki0179() { int H, W, b; cin >> H >> W; vector<string> S(H); for (int i = 0; i < H; i++) cin >> S[i]; //黒マスの個数 b = 0; for (int y = 0; y < H; y++) { for (int x = 0; x < W; x++) { if (S[y][x] == '#') b++; } } //b 奇数なら false if (b % 2) { cout << "NO" << endl; return 0; } //右に w, 下に h 平行移動して一致するなら true for (int w = 0; w < W; w++) { for (int h = 0; h < H; h++) { if (w == 0 && h == 0) continue; if (tr(S, w, h, b)) { cout << "YES" << endl; return 0; } } } cout << "NO" << endl; return 0; } int main() { //clock_t start, end; //start = clock(); yuki0179(); //end = clock(); //printf("%d msec.\n", end - start); return 0; }