結果

問題 No.179 塗り分け
ユーザー antaanta
提出日時 2015-04-06 00:13:06
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 2,223 bytes
コンパイル時間 1,008 ms
コンパイル使用メモリ 95,896 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-10 11:25:05
合計ジャッジ時間 11,341 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,812 KB
testcase_01 AC 2 ms
6,812 KB
testcase_02 AC 2 ms
6,944 KB
testcase_03 AC 2 ms
6,940 KB
testcase_04 AC 2 ms
6,940 KB
testcase_05 AC 37 ms
6,944 KB
testcase_06 AC 18 ms
6,940 KB
testcase_07 AC 346 ms
6,944 KB
testcase_08 AC 345 ms
6,944 KB
testcase_09 WA -
testcase_10 AC 357 ms
6,940 KB
testcase_11 AC 302 ms
6,944 KB
testcase_12 AC 301 ms
6,940 KB
testcase_13 AC 2 ms
6,944 KB
testcase_14 AC 2 ms
6,940 KB
testcase_15 AC 2 ms
6,940 KB
testcase_16 AC 1 ms
6,944 KB
testcase_17 AC 2 ms
6,940 KB
testcase_18 AC 376 ms
6,944 KB
testcase_19 AC 346 ms
6,940 KB
testcase_20 AC 348 ms
6,940 KB
testcase_21 AC 359 ms
6,944 KB
testcase_22 AC 357 ms
6,944 KB
testcase_23 AC 373 ms
6,940 KB
testcase_24 AC 356 ms
6,940 KB
testcase_25 AC 361 ms
6,940 KB
testcase_26 WA -
testcase_27 AC 396 ms
6,940 KB
testcase_28 WA -
testcase_29 AC 402 ms
6,940 KB
testcase_30 WA -
testcase_31 AC 408 ms
6,944 KB
testcase_32 AC 392 ms
6,940 KB
testcase_33 AC 395 ms
6,940 KB
testcase_34 WA -
testcase_35 AC 395 ms
6,940 KB
testcase_36 AC 1 ms
6,940 KB
testcase_37 AC 1 ms
6,940 KB
testcase_38 AC 1 ms
6,944 KB
testcase_39 AC 1 ms
6,940 KB
testcase_40 AC 2 ms
6,944 KB
testcase_41 AC 2 ms
6,940 KB
testcase_42 AC 2 ms
6,940 KB
testcase_43 AC 8 ms
6,940 KB
testcase_44 AC 46 ms
6,940 KB
testcase_45 AC 3 ms
6,940 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:55:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   55 |         scanf("%d%d", &H, &W);
      |         ~~~~~^~~~~~~~~~~~~~~~
main.cpp:58:24: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   58 |         rep(i, H) scanf("%s", S[i]);
      |                   ~~~~~^~~~~~~~~~~~

ソースコード

diff #

#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
using namespace std;
typedef vector<int> vi; typedef pair<int,int> pii; typedef vector<pair<int,int> > vpii; typedef long long ll;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }

template<typename T>
vector<pair<T,int> > runLength(const T a[], int n) {
	vector<pair<T,int> > r;
	if(n <= 0) return r;
	int cnt = 0;
	for(int i = 0; i <= n; i ++) {
		if(i == n || (i != 0 && a[i] != a[i-1])) {
			r.push_back(make_pair(a[i-1], cnt));
			cnt = 0;
		}
		cnt ++;
	}
	return r;
}

int main() {
	int H, W;
	scanf("%d%d", &H, &W);
	vector<char*> S(H);
	rep(i, H) S[i] = new char[W+1];
	rep(i, H) scanf("%s", S[i]);
	bool ans = false;
	rer(dy, 0, H-1) rer(dx, 0, W-1) if(dy || dx) {
		bool ok = true;
		vector<vector<bool> > vis(H, vector<bool>(W, false));
		int cnt = 0;
		rep(i, H) rep(j, W) if(!vis[i][j]) {
			int yy = i, xx = j;
			vector<char> v;
			for(; yy < H && xx < W; yy += dy, xx += dx) {
				vis[yy][xx] = true;
				v.pb(S[yy][xx]);
				if(S[yy][xx] == '#')
					++ cnt;
			}
			vector<pair<char,int> > runs = runLength(&v[0], v.size());
			each(i, runs) if(i->first == '#')
				ok &= i->second % 2 == 0;
		}
		ok &= cnt > 0;
//		if(ok) cerr << dy << ", " << dx << endl;
		ans |= ok;
	}
	puts(ans ? "YES" : "NO");
	return 0;
}
0