結果
| 問題 |
No.340 雪の足跡
|
| コンテスト | |
| ユーザー |
184
|
| 提出日時 | 2016-01-30 11:19:16 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,242 bytes |
| コンパイル時間 | 595 ms |
| コンパイル使用メモリ | 60,008 KB |
| 実行使用メモリ | 11,136 KB |
| 最終ジャッジ日時 | 2024-09-21 19:08:59 |
| 合計ジャッジ時間 | 14,168 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 WA * 3 |
| other | AC * 21 WA * 6 TLE * 5 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:11:24: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
11 | int w,h,n;scanf("%d%d%d",&w,&h,&n);
| ~~~~~^~~~~~~~~~~~~~~~~~~
main.cpp:13:44: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
13 | int m,sx,sy,x,y,a,b,d;scanf("%d%d",&m,&a);
| ~~~~~^~~~~~~~~~~~~~
main.cpp:16:30: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
16 | scanf("%d",&b);x=b%w;y=b/w;
| ~~~~~^~~~~~~~~
ソースコード
#include <cstdio>
#include <queue>
#include <map>
#include <vector>
#include <algorithm>
using namespace std;
int visit[1001][1001]={},mp[1001][1001]={};
int main(){
int w,h,n;scanf("%d%d%d",&w,&h,&n);
for(int i=0;i<n;i++){
int m,sx,sy,x,y,a,b,d;scanf("%d%d",&m,&a);
sx=a%w;sy=a/w;
for(int j=0;j<m;j++){
scanf("%d",&b);x=b%w;y=b/w;
if(sx==x){
if(sy<y)d=1;else d=-1;
for(;sy!=y;sy+=d){
if(mp[sy][x])continue;
mp[sy][x]=1;
/*v[a].push_back(a+d);
v[a+d].push_back(a);*/
}
}
else if(sy==y){
if(sx<x)d=1;else d=-1;
for(;sx!=x;sx+=d){
if(mp[y][sx])continue;
mp[y][sx]=1;
/*v[a].push_back(a+d);
v[a+d].push_back(a);*/
}
}
a=b;sx=x;sy=y;
}
}
queue< vector<int> > q;
q.push({0,0});
visit[0][0]=1;
vector<int> a,g{w-1,h-1};int cnt=0,num=1,ncnt=0;
int dx[4]={0,0,-1,1},dy[4]={-1,1,0,0},x,y;
while(q.size()){
a=q.front();q.pop();
if(a==g){num=0;break;}
num--;
for(int i=0;i<4;i++){
x=a[0]+dx[i];if(x<0||x>=w)continue;
y=a[1]+dy[i];if(y<0||y>=h)continue;
if(visit[y][x]==0){ncnt++;visit[y][x]=1;q.push({x,y});}
}
if(num==0){cnt++;num=ncnt;ncnt=0;}
}
if(num>0)printf("Odekakedekinai..\n");
else printf("%d\n",cnt);
return 0;
}
184