結果
| 問題 |
No.640 76本のトロンボーン
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2018-02-11 19:29:18 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 2,969 bytes |
| コンパイル時間 | 2,560 ms |
| コンパイル使用メモリ | 205,676 KB |
| 最終ジャッジ日時 | 2025-01-05 08:20:16 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 11 WA * 4 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
int N;
vector<vector<bool>> ok;
int yoko1(const int i)
{
auto copy = ok;
for (int j = 0; j < N - 1; j++) {
if (copy[i][j]) {
copy[i][j] = false;
} else {
return 0;
}
}
int ans = 1;
for (int j = 0; j < N; j++) {
bool f = true;
for (int i = 1; i < N - 1; i++) {
if (not copy[i][j]) {
f = false;
break;
}
}
if (f and (copy[0][j] or copy[N - 1][j])) {
ans++;
}
}
return ans;
}
int yoko2(const int i)
{
auto copy = ok;
for (int j = 1; j < N; j++) {
if (copy[i][j]) {
copy[i][j] = false;
} else {
return 0;
}
}
int ans = 1;
for (int j = 0; j < N; j++) {
bool f = true;
for (int i = 1; i < N - 1; i++) {
if (not copy[i][j]) {
f = false;
break;
}
}
if (f and (copy[0][j] or copy[N - 1][j])) {
ans++;
}
}
return ans;
}
int tate1(const int j)
{
auto copy = ok;
for (int i = 0; i < N - 1; i++) {
if (copy[i][j]) {
copy[i][j] = false;
} else {
return 0;
}
}
int ans = 1;
for (int i = 0; i < N; i++) {
bool f = true;
for (int j = 1; j < N - 1; j++) {
if (not copy[i][j]) {
f = false;
break;
}
}
if (f and (copy[i][0] or copy[i][N - 1])) {
ans++;
}
}
return ans;
}
int tate2(const int j)
{
auto copy = ok;
for (int i = 1; i < N; i++) {
if (copy[i][j]) {
copy[i][j] = false;
} else {
return 0;
}
}
int ans = 1;
for (int i = 0; i < N; i++) {
bool f = true;
for (int j = 1; j < N - 1; j++) {
if (not copy[i][j]) {
f = false;
break;
}
}
if (f and (copy[i][0] or copy[i][N - 1])) {
ans++;
}
}
return ans;
}
int main()
{
cin.tie(0);
ios::sync_with_stdio(false);
cin >> N;
ok.resize(N, vector<bool>(N));
for (int i = 0; i < N; i++) {
for (int j = 0; j < N; j++) {
char c;
cin >> c;
ok[i][j] = c == '.';
}
}
bool spe = true;
for (int i = 0; i < N; i++) {
if (not ok[i][0]) {
spe = false;
}
if (not ok[i][N - 1]) {
spe = false;
}
if (not ok[0][i]) {
spe = false;
}
if (not ok[N - 1][i]) {
spe = false;
}
}
int ans = 0;
if (spe) {
ans = 4;
}
for (int i = 0; i < N; i++) {
ans = max({ans, tate1(i), tate2(i), yoko1(i), yoko2(i)});
}
cout << ans << endl;
return 0;
}