結果

問題 No.340 雪の足跡
ユーザー TawaraTawara
提出日時 2016-01-09 19:41:41
言語 C++11
(gcc 11.4.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 1,189 bytes
コンパイル時間 647 ms
コンパイル使用メモリ 54,216 KB
実行使用メモリ 83,864 KB
最終ジャッジ日時 2023-10-19 16:57:53
合計ジャッジ時間 24,004 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 3 ms
7,364 KB
testcase_02 AC 2 ms
7,296 KB
testcase_03 WA -
testcase_04 AC 2 ms
7,296 KB
testcase_05 AC 2 ms
7,352 KB
testcase_06 WA -
testcase_07 AC 2 ms
7,316 KB
testcase_08 AC 2 ms
7,304 KB
testcase_09 WA -
testcase_10 AC 2 ms
7,308 KB
testcase_11 AC 19 ms
48,452 KB
testcase_12 AC 30 ms
74,636 KB
testcase_13 AC 68 ms
83,864 KB
testcase_14 TLE -
testcase_15 TLE -
testcase_16 RE -
testcase_17 RE -
testcase_18 TLE -
testcase_19 RE -
testcase_20 TLE -
testcase_21 AC 84 ms
27,832 KB
testcase_22 AC 19 ms
64,904 KB
testcase_23 TLE -
testcase_24 TLE -
testcase_25 TLE -
testcase_26 RE -
testcase_27 WA -
testcase_28 RE -
testcase_29 TLE -
testcase_30 TLE -
testcase_31 TLE -
testcase_32 TLE -
testcase_33 TLE -
testcase_34 TLE -
testcase_35 TLE -
testcase_36 TLE -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:22:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   22 |         scanf("%d %d %d",&W,&H,&N);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~
main.cpp:25:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   25 |                 scanf("%d",&M);
      |                 ~~~~~^~~~~~~~~
main.cpp:26:33: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   26 |                 rep(j,M+1) scanf("%d %d",X+j,Y+j);
      |                            ~~~~~^~~~~~~~~~~~~~~~~

ソースコード

diff #

#include <stdio.h>
#include <tuple>
#include <queue>
#include <algorithm>

using namespace std;

typedef tuple <int, int, int> T;

#define range(i,a,b) for(int i=(a); i < (b); i++)
#define rep(i,n) range(i,0,n)

#define UW 5000
#define UH 5000
#define MAXD 25000001

int EX[UH][UW],EY[UW][UH],X[UW+1],Y[UH+1];
int D[UH][UW],dx[]={1,0,-1,0},dy[]={0,1,0,-1};
int main(){
	int W,H,N,M,G,x,y,nx,ny,lx,ly,ux,uy,d;
	queue<T> Q; 
	scanf("%d %d %d",&W,&H,&N);
	rep(j,H) rep(i,W){EX[j][i] = EY[i][j] = 0; D[j][i] = MAXD;}
	rep(i,N){
		scanf("%d",&M);
		rep(j,M+1) scanf("%d %d",X+j,Y+j);
		rep(j,M){
			lx = min(X[j],X[j+1]); ux = max(X[j],X[j+1]);
			ly = min(Y[j],Y[j+1]); uy = max(Y[j],Y[j+1]);
			range(k,lx,ux) EX[ly][k]++;
			range(k,ly,uy) EY[lx][k]++;
		}
	}
	D[0][0] = 0; Q.push(T(0,0,0)); G = W+H-2; 
	while (!Q.empty()){
		tie(x,y,d) = Q.front(); Q.pop();
		if (x+y == G){printf("%d\n",d);return 0;}
		rep(i,4){
			nx = x + dx[i]; ny = y + dy[i];
			if (nx < 0 || nx >= W || ny < 0 || ny >= H) continue;
			if (((x==nx && EY[x][min(y,ny)]>0)||(y==ny && EX[y][min(x,nx)]>0)) && d+1<D[ny][nx]){
				D[ny][nx] = d+1; Q.push(T(nx,ny,d+1));
			}
		}
	}
	puts("Odekakedekinai..");
	return 0;
}
0