Submission #62059425
Source Code Expand
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll = long long;
#define rep(i, n) for(int i = 0; (i) < (int)(n); ++(i))
#define rep_r(i, n) for(int i = (int)(n) - 1; (i) >= 0; --(i))
#define all(x) begin(x), end(x)
int main() {
// input
int H, W;
cin >> H >> W;
vector<string> S(H);
rep(i, H) cin >> S[i];
// calc
// 黒マスのx,yそれぞれの最小値と最大値を求める
int min_x = W;
int min_y = H;
int max_x = 0;
int max_y = 0;
rep(y, H) {
rep(x, W) {
if(S[y][x] == '#') {
min_x = min(x, min_x);
min_y = min(y, min_y);
max_x = max(x, max_x);
max_y = max(y, max_y);
}
}
}
// (min_x, min_y)から(max_x, max_y)の長方形内に、.が無いことを確認する
bool result = true;
rep(y, H) {
rep(x, W) {
if(S[y][x] == '.') {
if(min_x <= x && x <= max_x && min_y <= y && y <= max_y)
result = false;
}
}
}
// output
if(result) {
cout << "Yes" << endl;
} else {
cout << "No" << endl;
}
}
Submission Info
| Submission Time | |
|---|---|
| Task | C - Paint to make a rectangle |
| User | Koreander |
| Language | C++ 23 (gcc 12.2) |
| Score | 300 |
| Code Size | 1238 Byte |
| Status | AC |
| Exec Time | 17 ms |
| Memory | 5540 KiB |
Judge Result
| Set Name | Sample | All | ||||
|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 300 / 300 | ||||
| Status |
|
|
| Set Name | Test Cases |
|---|---|
| Sample | example_00.txt, example_01.txt, example_02.txt |
| All | example_00.txt, example_01.txt, example_02.txt, hand_00.txt, hand_01.txt, hand_02.txt, hand_03.txt, hand_04.txt, hand_05.txt, hand_06.txt, hand_07.txt, hand_08.txt, hand_09.txt, hand_10.txt, hand_11.txt, hand_12.txt, random_00.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, random_18.txt, random_19.txt, random_20.txt, random_21.txt, random_22.txt, random_23.txt, random_24.txt |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| example_00.txt | AC | 1 ms | 3696 KiB |
| example_01.txt | AC | 1 ms | 3424 KiB |
| example_02.txt | AC | 1 ms | 3544 KiB |
| hand_00.txt | AC | 15 ms | 5460 KiB |
| hand_01.txt | AC | 14 ms | 5436 KiB |
| hand_02.txt | AC | 14 ms | 5472 KiB |
| hand_03.txt | AC | 14 ms | 5504 KiB |
| hand_04.txt | AC | 14 ms | 5336 KiB |
| hand_05.txt | AC | 1 ms | 3412 KiB |
| hand_06.txt | AC | 1 ms | 3528 KiB |
| hand_07.txt | AC | 1 ms | 3524 KiB |
| hand_08.txt | AC | 1 ms | 3576 KiB |
| hand_09.txt | AC | 14 ms | 5336 KiB |
| hand_10.txt | AC | 14 ms | 5332 KiB |
| hand_11.txt | AC | 14 ms | 5540 KiB |
| hand_12.txt | AC | 14 ms | 5532 KiB |
| random_00.txt | AC | 16 ms | 4592 KiB |
| random_01.txt | AC | 16 ms | 5284 KiB |
| random_02.txt | AC | 15 ms | 4516 KiB |
| random_03.txt | AC | 16 ms | 4492 KiB |
| random_04.txt | AC | 17 ms | 5424 KiB |
| random_05.txt | AC | 12 ms | 4448 KiB |
| random_06.txt | AC | 13 ms | 5456 KiB |
| random_07.txt | AC | 13 ms | 5452 KiB |
| random_08.txt | AC | 13 ms | 4576 KiB |
| random_09.txt | AC | 11 ms | 4380 KiB |
| random_10.txt | AC | 12 ms | 4384 KiB |
| random_11.txt | AC | 13 ms | 5408 KiB |
| random_12.txt | AC | 13 ms | 5284 KiB |
| random_13.txt | AC | 14 ms | 5336 KiB |
| random_14.txt | AC | 12 ms | 4508 KiB |
| random_15.txt | AC | 14 ms | 5372 KiB |
| random_16.txt | AC | 14 ms | 4396 KiB |
| random_17.txt | AC | 14 ms | 5336 KiB |
| random_18.txt | AC | 13 ms | 4608 KiB |
| random_19.txt | AC | 13 ms | 4484 KiB |
| random_20.txt | AC | 12 ms | 4540 KiB |
| random_21.txt | AC | 12 ms | 4448 KiB |
| random_22.txt | AC | 13 ms | 4540 KiB |
| random_23.txt | AC | 13 ms | 4580 KiB |
| random_24.txt | AC | 13 ms | 4508 KiB |