結果

問題 No.340 雪の足跡
ユーザー 184184
提出日時 2016-01-30 11:19:16
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,242 bytes
コンパイル時間 532 ms
コンパイル使用メモリ 59,492 KB
実行使用メモリ 11,204 KB
最終ジャッジ日時 2023-10-21 17:53:48
合計ジャッジ時間 14,372 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,380 KB
testcase_01 AC 2 ms
5,384 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,380 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 2 ms
5,376 KB
testcase_10 WA -
testcase_11 AC 3 ms
5,528 KB
testcase_12 AC 3 ms
5,524 KB
testcase_13 AC 3 ms
5,656 KB
testcase_14 AC 19 ms
6,472 KB
testcase_15 AC 23 ms
6,824 KB
testcase_16 AC 16 ms
6,096 KB
testcase_17 AC 30 ms
6,884 KB
testcase_18 AC 25 ms
6,884 KB
testcase_19 AC 30 ms
6,884 KB
testcase_20 TLE -
testcase_21 TLE -
testcase_22 WA -
testcase_23 WA -
testcase_24 TLE -
testcase_25 WA -
testcase_26 AC 38 ms
6,300 KB
testcase_27 AC 7 ms
5,388 KB
testcase_28 AC 36 ms
6,404 KB
testcase_29 AC 460 ms
10,744 KB
testcase_30 AC 277 ms
8,656 KB
testcase_31 AC 529 ms
10,604 KB
testcase_32 AC 646 ms
11,204 KB
testcase_33 AC 492 ms
11,204 KB
testcase_34 AC 658 ms
11,204 KB
testcase_35 TLE -
testcase_36 TLE -
権限があれば一括ダウンロードができます
コンパイルメッセージ
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;
      |                         ~~~~~^~~~~~~~~

ソースコード

diff #

#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;
}
0