Submission #00148
ソースコード
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 | #include<iostream> #include<string> #include<stdio.h> #include<queue> #define INF 100000 typedef struct { int x,y; }B; typedef struct { int x,y; }Poi; using namespace std; int main(){ int dx[]={0,1,0,-1}; int dy[]={-1,0,1,0}; int h,w,i,v,q=0,t,be; scanf ( "%d %d" ,&h,&w); char mp[h][w]; int d[h][w]; B b[1000000]; for (i=0;i<h;i++){ for (v=0;v<w;v++){ scanf ( " %c" ,&mp[i][v]); d[i][v]=INF; if (mp[i][v]!= '#' ){ b[q].x=v; b[q].y=i; q++; } } } for (t=0;t<q;t++){ be=( int )mp[b[t].y][b[t].x]-48; for (i=b[t].y-be;i<=b[t].y+be;i++){ for (v=b[t].x-be;v<=b[t].x+be;v++){ if (i>=0 && i<h && v>=0 && v<w && ((b[t].y==i && b[t].x==v) || mp[i][v]== '#' )){ mp[i][v]= '.' ; } } } } int n,sx,sy,gx,gy; cin >> n; int ans[n]; memset (ans,0, sizeof (ans)); for ( int a=0;a<n;a++){ int ka,ja,ha,fa; cin >> ka >> ja >> ha >> fa; sx=ka; sy=ja; gx=ha; gy=fa; queue<Poi>que; que.push((Poi){sx,sy}); d[sy][sx]=0; while (!que.empty()){ Poi P=que.front();que.pop(); int x=P.x; int y=P.y; if (x==gx&&y==gy)ans[a]=1; for ( int g=0;g<4;g++){ int nx=x+dx[g]; int ny=y+dy[g]; if (nx>=0&&nx<w&&ny>=0&&ny<h&&d[ny][nx]==INF&&mp[ny][nx]!= '#' ){ que.push((Poi){nx,ny}); d[ny][nx]=d[y][x]+1; } } } for ( int i=0;i<h;i++){ for ( int j=0;j<w;j++){ d[i][j]=INF; } } } for ( int r=0;r<n;r++){ if (ans[r]==1)cout << "yes" << endl; else cout << "no" << endl; } return 0; } |
ステータス
項目 | データ |
---|---|
問題 | 0004 - 韓流ハゲ |
ユーザー名 | 国崎せんせーしょん∴ |
投稿日時 | 2017-08-08 11:38:19 |
言語 | C++11 |
状態 | Compile Error |
得点 | 0 |
ソースコード長 | 1701 Byte |
最大実行時間 | - |
最大メモリ使用量 |
コンパイルメッセージ
./Main.cpp: 関数 ‘int main()’ 内: ./Main.cpp:45:7: エラー: ‘memset’ was not declared in this scope memset(ans,0,sizeof(ans)); ^~~~~~ ./Main.cpp:45:7: 備考: suggested alternative: ‘wmemset’ memset(ans,0,sizeof(ans)); ^~~~~~ wmemset
セット
セット | 得点 | Cases |
---|
テストケース
ファイル名 | 状態 | 実行時間 | メモリ使用量 | # |
---|