結果
問題 | No.402 最も海から遠い場所 |
ユーザー |
![]() |
提出日時 | 2016-07-23 01:11:55 |
言語 | C++11 (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 905 ms / 3,000 ms |
コード長 | 1,885 bytes |
コンパイル時間 | 1,705 ms |
コンパイル使用メモリ | 165,156 KB |
実行使用メモリ | 131,984 KB |
最終ジャッジ日時 | 2024-11-06 14:12:03 |
合計ジャッジ時間 | 5,668 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 19 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:44:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 44 | scanf("%d%d",&h,&w); | ~~~~~^~~~~~~~~~~~~~ main.cpp:47:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 47 | scanf("%s",s); | ~~~~~^~~~~~~~
ソースコード
#include <bits/stdc++.h>using namespace std;typedef long long ll;typedef vector<int> vi;typedef vector<ll> vl;typedef pair<int,int> pii;typedef pair<ll,ll> pll;typedef int _loop_int;#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)#define DEBUG(x) cout<<#x<<": "<<x<<endl#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl#define ALL(a) (a).begin(),(a).end()#define CHMIN(a,b) a=min((a),(b))#define CHMAX(a,b) a=max((a),(b))// modconst ll MOD = 1000000007ll;#define FIX(a) ((a)%MOD+MOD)%MOD// floatingtypedef double Real;const Real EPS = 1e-11;#define EQ0(x) (abs(x)<EPS)#define EQ(a,b) (abs(a-b)<EPS)typedef complex<Real> P;int h,w;int mp[3535][3535];int mn[3535][3535];int dx[] = {1,0,-1,0,1,1,-1,-1};int dy[] = {0,1,0,-1,1,-1,-1,1};const int NICO = 830252521;int main(){REP(i,3535)REP(j,3535)mn[i][j] = NICO;scanf("%d%d",&h,&w);REP(i,h){char s[3531];scanf("%s",s);REP(j,w){mp[i][j] = s[j]=='.';}}queue<pii> Q;REP(i,h)REP(j,w){if(mp[i][j])continue;if(i==0 || j==0 || i==h-1 || j==w-1){mn[i][j] = 1;Q.push(pii(i,j));}else{REP(d,8){if(mp[i+dy[d]][j+dx[d]]){mn[i][j] = 1;Q.push(pii(i,j));break;}}}}int ans = 0;while(!Q.empty()){pii P = Q.front(); Q.pop();int y = P.first;int x = P.second;CHMAX(ans,mn[y][x]);REP(d,8){int ny = y+dy[d];int nx = x+dx[d];if(ny<0 || nx<0 || ny>=h || nx>=w)continue;if(mp[ny][nx])continue;if(mn[ny][nx] != NICO)continue;mn[ny][nx] = mn[y][x] + 1;Q.push(pii(ny,nx));}}printf("%d\n",ans);return 0;}