結果
問題 | No.402 最も海から遠い場所 |
ユーザー |
![]() |
提出日時 | 2016-07-22 23:52:20 |
言語 | C++11 (gcc 11.4.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,149 bytes |
コンパイル時間 | 907 ms |
コンパイル使用メモリ | 72,176 KB |
実行使用メモリ | 51,360 KB |
最終ジャッジ日時 | 2024-04-24 06:22:12 |
合計ジャッジ時間 | 6,388 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
13,888 KB |
testcase_01 | AC | 1 ms
6,940 KB |
testcase_02 | AC | 2 ms
6,940 KB |
testcase_03 | WA | - |
testcase_04 | AC | 1 ms
6,940 KB |
testcase_05 | AC | 2 ms
6,944 KB |
testcase_06 | AC | 2 ms
6,940 KB |
testcase_07 | AC | 1 ms
6,944 KB |
testcase_08 | AC | 2 ms
6,940 KB |
testcase_09 | AC | 2 ms
6,944 KB |
testcase_10 | AC | 1 ms
6,940 KB |
testcase_11 | AC | 2 ms
6,944 KB |
testcase_12 | AC | 2 ms
6,940 KB |
testcase_13 | AC | 20 ms
6,940 KB |
testcase_14 | AC | 8 ms
6,940 KB |
testcase_15 | AC | 181 ms
6,944 KB |
testcase_16 | AC | 321 ms
6,940 KB |
testcase_17 | TLE | - |
testcase_18 | -- | - |
testcase_19 | -- | - |
testcase_20 | -- | - |
testcase_21 | -- | - |
ソースコード
#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] = 10000; }else{ a[i+1][j+1] = 0; } } } b=a; int dx[9] = {1,1, 1,0,0, 0,-1,-1,-1}; int dy[9] = {1,0,-1,1,0,-1, 1, 0,-1}; int cnt=1; while( cnt < max(h,w) ){ 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<9;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; }