結果

問題 No.179 塗り分け
ユーザー kaffelunkaffelun
提出日時 2017-09-30 22:46:22
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,014 bytes
コンパイル時間 1,641 ms
コンパイル使用メモリ 145,572 KB
実行使用メモリ 4,516 KB
最終ジャッジ日時 2023-08-09 22:41:37
合計ジャッジ時間 4,588 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 4 ms
4,376 KB
testcase_09 WA -
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 4 ms
4,380 KB
testcase_13 AC 1 ms
4,384 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 1 ms
4,376 KB
testcase_17 AC 1 ms
4,380 KB
testcase_18 AC 2 ms
4,380 KB
testcase_19 AC 2 ms
4,376 KB
testcase_20 AC 4 ms
4,376 KB
testcase_21 AC 4 ms
4,376 KB
testcase_22 AC 5 ms
4,380 KB
testcase_23 AC 2 ms
4,380 KB
testcase_24 AC 4 ms
4,380 KB
testcase_25 AC 2 ms
4,380 KB
testcase_26 WA -
testcase_27 AC 4 ms
4,380 KB
testcase_28 WA -
testcase_29 AC 5 ms
4,380 KB
testcase_30 WA -
testcase_31 AC 4 ms
4,380 KB
testcase_32 AC 2 ms
4,380 KB
testcase_33 AC 4 ms
4,376 KB
testcase_34 WA -
testcase_35 AC 5 ms
4,376 KB
testcase_36 AC 2 ms
4,384 KB
testcase_37 AC 1 ms
4,380 KB
testcase_38 WA -
testcase_39 AC 1 ms
4,376 KB
testcase_40 AC 2 ms
4,380 KB
testcase_41 AC 2 ms
4,380 KB
testcase_42 AC 1 ms
4,376 KB
testcase_43 AC 1 ms
4,376 KB
testcase_44 AC 2 ms
4,380 KB
testcase_45 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:10:6: warning: ‘sx’ may be used uninitialized in this function [-Wmaybe-uninitialized]
  int sx, sy;
      ^~

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
int S[50][50];
int f[50][50];
int main() {
	int H, W;
	cin >> H >> W;
	string s;
	bool flag = true;
	int sx, sy;
	for(int i = 0; i < H; i++) {
		cin >> s;
		for(int j = 0; j < s.length(); j++) {
			S[i][j] = s[j] == '.' ? 0 : 1;
			if(S[i][j] && flag) {
				sx = j, sy = i;
				flag = false;
			}
		}
	}
	if(flag) {
		cout << "NO" << endl;
		return 0;
	}
	for(int dy = 0; dy < H; dy++) {
		for(int dx = 0; dx < W; dx++) {
			if(dx == 0 && dy == 0) continue;
			flag = true;
			for(int py = sy; py < H; py++) {
				for(int px = sx; px < W; px++) {
					if(S[py][px] && !f[py][px]) {
						if(px + dx >= W || py + dy >= H || !S[py + dy][px + dx]) {
							flag = false;
							break;
						}
						f[py + dy][px + dx] = true;
					}
				}
				if(!flag) break;
			}
			for(int i = 0; i < H; i++) {
				for(int j = 0; j < W; j++) {
					f[i][j] = false;
				}
			}
			if(flag) {
				break;
			}
		}
		if(flag) break;
	}
	cout << (flag ? "YES" : "NO") << endl;
	return 0;
}
0