結果

問題 No.340 雪の足跡
ユーザー FF256grhyFF256grhy
提出日時 2016-01-30 02:23:29
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,345 bytes
コンパイル時間 141 ms
コンパイル使用メモリ 24,780 KB
実行使用メモリ 13,328 KB
最終ジャッジ日時 2023-10-21 17:43:09
合計ジャッジ時間 11,680 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,728 KB
testcase_01 AC 1 ms
5,732 KB
testcase_02 AC 1 ms
4,348 KB
testcase_03 AC 1 ms
5,728 KB
testcase_04 AC 1 ms
5,528 KB
testcase_05 AC 1 ms
4,348 KB
testcase_06 AC 2 ms
5,736 KB
testcase_07 AC 1 ms
4,348 KB
testcase_08 AC 1 ms
5,540 KB
testcase_09 AC 1 ms
4,348 KB
testcase_10 AC 1 ms
5,544 KB
testcase_11 AC 3 ms
5,816 KB
testcase_12 AC 2 ms
5,968 KB
testcase_13 AC 3 ms
5,924 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 TLE -
testcase_22 AC 1 ms
4,348 KB
testcase_23 WA -
testcase_24 TLE -
testcase_25 AC 498 ms
12,372 KB
testcase_26 AC 31 ms
5,912 KB
testcase_27 AC 7 ms
5,904 KB
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:7:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    7 |         scanf("%d%d%d", &w, &h, &n);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~
main.cpp:11:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   11 |                 scanf("%d%d", &m, &b);
      |                 ~~~~~^~~~~~~~~~~~~~~~
main.cpp:14:30: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   14 |                         scanf("%d", &b);
      |                         ~~~~~^~~~~~~~~~

ソースコード

diff #

#include <stdio.h>

int w, h, n, WE[999][1000], NS[1000][999];
int val[1000][1000], queue_x[1000], queue_y[100], set, get;

int main(void) {
	scanf("%d%d%d", &w, &h, &n);
	int i, j;
	for(i = 0; i < n; i++) {
		int m, b, p;
		scanf("%d%d", &m, &b);
		for(j = 0; j < m; j++) {
			p = b;
			scanf("%d", &b);
			if(b % w == p % w) {
				int x = b % w;
				int y_s = (p < b ? p : b) / w;
				int y_g = (p < b ? b : p) / w;
				int k;
				for(k = y_s; k < y_g; k++) { NS[x][k] = 1; }
			} else {
				int x_s = (p < b ? p : b) % w;
				int x_g = (p < b ? b : p) % w;
				int y = b / w;
				int k;
				for(k = x_s; k < x_g; k++) { WE[k][y] = 1; }
			}
		}
	}
	
	int dx[4] = { 1, 0, -1,  0 };
	int dy[4] = { 0, 1,  0, -1 };
	
	val[0][0] = 1;
	queue_x[set] = 0;
	queue_y[set] = 0;
	set++;
	while(set != get) {
		int x = queue_x[get];
		int y = queue_y[get];
		get++;
		
		for(i = 0; i < 4; i++) {
			int x2 = x + dx[i];
			int y2 = y + dy[i];
			if(
				(
					( i % 2 == 0 && 0 <= x2 && x2 < w && WE[x - (i == 2)][y] ) ||
					( i % 2 == 1 && 0 <= y2 && y2 < h && NS[x][y - (i == 3)] )
				) && val[x2][y2] == 0
			) {
				val[x2][y2] = val[x][y] + 1;
				queue_x[set] = x2;
				queue_y[set] = y2;
				set++;
			}
		}
	}
	
	if(val[w - 1][h - 1] != 0) {
		printf("%d\n", val[w - 1][h - 1] - 1);
	} else {
		printf("Odekakedekinai..\n");
	}
	
	return 0;
}
0