結果

問題 No.340 雪の足跡
ユーザー YasukeXXXYasukeXXX
提出日時 2016-02-12 00:53:03
言語 C90
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 1,125 bytes
コンパイル時間 337 ms
コンパイル使用メモリ 24,052 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-22 02:24:58
合計ジャッジ時間 6,342 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 0 ms
4,348 KB
testcase_01 AC 0 ms
4,348 KB
testcase_02 AC 1 ms
4,348 KB
testcase_03 AC 1 ms
4,348 KB
testcase_04 AC 0 ms
4,348 KB
testcase_05 AC 1 ms
4,348 KB
testcase_06 AC 0 ms
4,348 KB
testcase_07 AC 0 ms
4,348 KB
testcase_08 TLE -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function ‘main’:
main.c:13:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   13 |         scanf("%d%d%d",&w,&h,&n);l=w*h;
      |         ^~~~~~~~~~~~~~~~~~~~~~~~
main.c:17:26: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   17 |         for(i=0;i<n;i++){scanf("%d",&m);int tmp[m+1];
      |                          ^~~~~~~~~~~~~~
main.c:18:36: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   18 |                 for(j=0;j<m+1;j++){scanf("%d",tmp+j);}
      |                                    ^~~~~~~~~~~~~~~~~

ソースコード

diff #

#include<stdio.h>
int w,h,n,m,ld,min,i,j,k,l;
void dot(int list[l], int H[l][l]){
	int tmp[l],ans=0;
	for(i=0;i<l;i++){tmp[i]=list[i];}
	for(i=0;i<l;i++){for(j=0;j<l;j++){
		if(H[j][i]&&tmp[j]){list[i]=1;continue;}}
	}}
int not_zero(int L[l]){
	for(i=0;i<l;i++){if(L[i]==1)return 1;}return 0;
}
int main(){
	scanf("%d%d%d",&w,&h,&n);l=w*h;
	if(l==1){puts("0");return 0;}
	int H[l][l], check[l][l],d=1;
	for(i=0;i<l;i++){for(j=0;j<l;j++){H[i][j]=0;check[i][j]=0;}}
	for(i=0;i<n;i++){scanf("%d",&m);int tmp[m+1];
		for(j=0;j<m+1;j++){scanf("%d",tmp+j);}
		for(j=0;j<m;j++){
			if(check[tmp[j]][tmp[j+1]])continue;
				check[tmp[j]][tmp[j+1]]=1;check[tmp[j+1]][tmp[j]]=1;
				ld=tmp[j]>tmp[j+1]?(tmp[j]-tmp[j+1]):(tmp[j+1]-tmp[j]);
				min=tmp[j]>tmp[j+1]?tmp[j+1]:tmp[j];
				for(k=0;k<ld/w;k++){
					H[min+k*w][min+(k+1)*w]=1;H[min+(k+1)*w][min+k*w]=1;}
				if(ld/w==0){for(k=0;k<ld;k++){
					H[min+k][min+(k+1)]=1;H[min+(k+1)][min+k]=1;}}}}
	int H_dist[l];
	for(i=0;i<l;i++){H_dist[i]=H[0][i];}
	while(not_zero(H_dist)){
		dot(H_dist,H);d++;
		if(H_dist[l-1]){printf("%d",d);return 0;}}
	puts("Odekakedekinai..");return 0;}
0