結果
| 問題 |
No.640 76本のトロンボーン
|
| コンテスト | |
| ユーザー |
newlife171128
|
| 提出日時 | 2018-02-04 21:30:46 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 3,049 bytes |
| コンパイル時間 | 2,195 ms |
| コンパイル使用メモリ | 195,136 KB |
| 最終ジャッジ日時 | 2025-01-05 08:08:47 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 5 WA * 2 RE * 8 |
ソースコード
#include <bits/stdc++.h>
#include "bits/stdc++.h"
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <string>
#include <sstream>
#include <cmath>
#include <stack>
#include <queue>
#include <cctype>
#include <stdio.h>
#include <map>
#include <unordered_map>
#include <string.h>
#include <utility>
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
using namespace std;
typedef pair<int, int> P;
int n;
int ans = 0;
char souko[80][80];
char hatena[80][80];
void tate_nurinuri(int y, int x, char a) {
for (int i = y; i <= y + n - 2; i++) {
if (souko[i][x] == '.' && i < n) {
souko[i][x] = a;
}
}
}
void yoko_nurinuri(int y, int x, char a) {
for (int i = x; i <= x + n - 2; i++) {
if (souko[y][i] == '.' && i < n) {
souko[y][i] = a;
}
}
}
bool yoko_check(int y, int x, char a) {
int cp = 0;
for (int i = x; i <= x + n - 2; i++) {
if (souko[y][i] == '.' && i < n) {
cp++;
}
}
if (cp == n - 1) {
yoko_nurinuri(y, x, a);
return true;
} else {
return false;
}
}
bool tate_check(int y, int x, char a) {
int cp = 0;
for (int i = y; i <= y + n - 2; i++) {
if (souko[i][x] == '.' && i < n) {
cp++;
}
}
if (cp == n - 1) {
tate_nurinuri(y, x, a);
return true;
} else {
return false;
}
}
void yoko_dfs(int y, int x, char a, int ct) {
/* for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
cout << souko[i][j];
}
cout << endl;
}
cout << endl;
cout << ct << endl;*/
ans = max(ans, ct);
for (int i = y; i < n; i++) {
for (int j = x; j < n; j++) {
if (souko[i][j] == '.') {
/*cout << "i" << i << " " << "j" << j << endl;*/
if (yoko_check(i, j, a)) {
/*cout << "横" << endl;*/
yoko_dfs(0, 0, a, ++ct);
}
}
}
}
}
void tate_dfs(int y, int x, char a, int ct) {
/* for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
cout << souko[i][j];
}
cout << endl;
}
cout << endl;
cout << ct << endl;*/
ans = max(ans, ct);
for (int i = y; i < n; i++) {
for (int j = x; j < n; j++) {
if (souko[i][j] == '.') {
/*cout << "i" << i << " " << "j" << j << endl;*/
if (tate_check(i, j, a)) {
/* cout << "縦" << endl;*/
tate_dfs(0, 0, a, ++ct);
}
}
}
}
}
void inite() {
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
souko[i][j] = hatena[i][j];
}
}
}
int main() {
cin >> n;
char tmp;
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
cin >> tmp;
souko[i][j] = tmp;
hatena[i][j] = tmp;
}
}
tate_dfs(0, 0, 'T', 0);
inite();
yoko_dfs(0, 0, 'T', 0);
inite();
if (tate_check(0, 0, 'T')) {
yoko_dfs(0, 0, 'T', 1);
inite();
}
if (tate_check(0, n - 1, 'T')) {
yoko_dfs(0, 0, 'T', 1);
inite();
}
if (yoko_check(0, 0, 'T') ) {
tate_dfs(0, 0, 'T', 1);
inite();
}
if ( yoko_check(n - 1, 0, 'T')) {
tate_dfs(0, 0, 'T', 1);
inite();
}
if(tate_check(0, 0, 'T') && tate_check(1, n - 1, 'T')){
yoko_dfs(0,0,'T',2);
inite();
}
cout << ans << endl;
return 0;
}
newlife171128