結果
| 問題 |
No.402 最も海から遠い場所
|
| コンテスト | |
| ユーザー |
Yut176
|
| 提出日時 | 2016-07-23 00:09:50 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,800 bytes |
| コンパイル時間 | 1,080 ms |
| コンパイル使用メモリ | 69,564 KB |
| 実行使用メモリ | 44,416 KB |
| 最終ジャッジ日時 | 2024-11-06 13:47:46 |
| 合計ジャッジ時間 | 6,580 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 5 WA * 6 RE * 4 TLE * 1 -- * 3 |
ソースコード
#include<iostream>
#include<algorithm>
#include<stdio.h>
#include<stdlib.h>
#include<vector>
#include<string>
#include<sstream>
using namespace std;
int main(){
int h,w;
cin >> h >> w;
vector<string> s(h);
for(int i=0;i<h;i++){
cin >> s[i];
}
vector< vector<int> > a(h+2,vector<int>(w+2));
vector< vector<int> > b(h+2,vector<int>(w+2));
for(int i=0;i<h;i++){
for(int j=0;j<w;j++){
if( s[i][j] == '#' ){
a[i+1][j+1] = 1;
}else{
a[i+1][j+1] = 0;
}
}
}
int ans = -1;
for(int i=1;i<h+1;i++){
for(int j=1;j<w+1;j++){
if( a[i][j] == 0 ) continue;
int dx[4] = {1,0, 0,-1};
int dy[4] = {0,1,-1, 0};
int tmp=10000;
for(int k=0;k<4;k++){
int mx = i + dx[k];
int my = i + dy[k];
int cnt = 0;
while( true ){
if( a[mx][my] == 0 ) break;
mx += dx[k];
my += dy[k];
cnt++;
}
if( tmp > cnt ) tmp = cnt;
}
if( ans < tmp ) ans = tmp;
}
}
cout << ans << endl;
// b=a;
//
// int dx[9] = {1,1, 1,0, 0,-1,-1,-1};
// int dy[9] = {1,0,-1,1,-1, 1, 0,-1};
// int cnt=1;
//
// while( cnt < max(h+2,w+2)/2 ){
//
// for(int x=0;x<h+2;x++){
// for(int y=0;y<w+2;y++){
//
// if( a[x][y] != 10000 ) continue;
//
// for(int i=0;i<8;i++){
// if( a[x+dx[i]][y+dy[i]] == cnt-1 ){
// b[x][y] = cnt;
// break;
// }
// }
//
// }
// }
// cnt++;
// a = b;
//
// }
//
// int ans=0;
// for(int i=1;i<h+1;i++){
// for(int j=1;j<w+1;j++){
// // printf("%d",a[i][j]);
// if(ans < a[i][j]) ans = a[i][j];
// }
// // printf("\n");
// }
// cout << ans << endl;
return 0;
}
Yut176