結果

問題 No.5006 Hidden Maze
ユーザー tailstails
提出日時 2022-06-12 17:37:09
言語 cLay
(20240104-1)
結果
AC  
実行時間 60 ms / 2,000 ms
コード長 1,560 bytes
コンパイル時間 2,715 ms
実行使用メモリ 22,868 KB
スコア 75,598
平均クエリ数 245.02
最終ジャッジ日時 2022-06-12 17:37:19
合計ジャッジ時間 9,936 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
純コード判定しない問題か言語
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 20 ms
22,016 KB
testcase_01 AC 21 ms
22,588 KB
testcase_02 AC 21 ms
21,892 KB
testcase_03 AC 20 ms
21,952 KB
testcase_04 AC 24 ms
21,780 KB
testcase_05 AC 33 ms
21,952 KB
testcase_06 AC 23 ms
21,768 KB
testcase_07 AC 27 ms
22,016 KB
testcase_08 AC 27 ms
21,780 KB
testcase_09 AC 55 ms
22,004 KB
testcase_10 AC 18 ms
22,576 KB
testcase_11 AC 17 ms
21,916 KB
testcase_12 AC 20 ms
21,904 KB
testcase_13 AC 22 ms
21,940 KB
testcase_14 AC 19 ms
22,420 KB
testcase_15 AC 20 ms
21,928 KB
testcase_16 AC 19 ms
21,892 KB
testcase_17 AC 35 ms
22,588 KB
testcase_18 AC 31 ms
22,624 KB
testcase_19 AC 20 ms
22,644 KB
testcase_20 AC 18 ms
22,588 KB
testcase_21 AC 19 ms
21,904 KB
testcase_22 AC 18 ms
21,916 KB
testcase_23 AC 21 ms
21,952 KB
testcase_24 AC 22 ms
22,620 KB
testcase_25 AC 23 ms
22,600 KB
testcase_26 AC 57 ms
22,716 KB
testcase_27 AC 42 ms
22,716 KB
testcase_28 AC 23 ms
22,240 KB
testcase_29 AC 48 ms
21,928 KB
testcase_30 AC 19 ms
21,940 KB
testcase_31 AC 19 ms
21,904 KB
testcase_32 AC 25 ms
21,916 KB
testcase_33 AC 24 ms
21,952 KB
testcase_34 AC 19 ms
21,928 KB
testcase_35 AC 24 ms
21,904 KB
testcase_36 AC 31 ms
22,264 KB
testcase_37 AC 41 ms
21,916 KB
testcase_38 AC 23 ms
21,920 KB
testcase_39 AC 29 ms
21,928 KB
testcase_40 AC 19 ms
22,868 KB
testcase_41 AC 21 ms
22,004 KB
testcase_42 AC 19 ms
21,904 KB
testcase_43 AC 30 ms
22,600 KB
testcase_44 AC 23 ms
21,904 KB
testcase_45 AC 26 ms
22,252 KB
testcase_46 AC 49 ms
22,016 KB
testcase_47 AC 27 ms
22,228 KB
testcase_48 AC 53 ms
21,792 KB
testcase_49 AC 53 ms
21,928 KB
testcase_50 AC 19 ms
22,228 KB
testcase_51 AC 18 ms
22,240 KB
testcase_52 AC 23 ms
22,600 KB
testcase_53 AC 38 ms
22,456 KB
testcase_54 AC 27 ms
21,780 KB
testcase_55 AC 25 ms
21,952 KB
testcase_56 AC 25 ms
22,264 KB
testcase_57 AC 28 ms
22,456 KB
testcase_58 AC 29 ms
22,240 KB
testcase_59 AC 19 ms
22,576 KB
testcase_60 AC 18 ms
21,904 KB
testcase_61 AC 19 ms
21,824 KB
testcase_62 AC 25 ms
21,904 KB
testcase_63 AC 20 ms
21,916 KB
testcase_64 AC 25 ms
21,940 KB
testcase_65 AC 22 ms
21,904 KB
testcase_66 AC 23 ms
22,228 KB
testcase_67 AC 28 ms
21,916 KB
testcase_68 AC 40 ms
21,880 KB
testcase_69 AC 46 ms
21,780 KB
testcase_70 AC 22 ms
22,456 KB
testcase_71 AC 23 ms
22,612 KB
testcase_72 AC 18 ms
21,904 KB
testcase_73 AC 31 ms
21,916 KB
testcase_74 AC 25 ms
21,940 KB
testcase_75 AC 40 ms
22,480 KB
testcase_76 AC 31 ms
21,916 KB
testcase_77 AC 41 ms
22,624 KB
testcase_78 AC 29 ms
22,600 KB
testcase_79 AC 53 ms
21,940 KB
testcase_80 AC 20 ms
21,892 KB
testcase_81 AC 21 ms
22,004 KB
testcase_82 AC 21 ms
22,216 KB
testcase_83 AC 18 ms
22,228 KB
testcase_84 AC 22 ms
21,904 KB
testcase_85 AC 26 ms
21,768 KB
testcase_86 AC 20 ms
22,704 KB
testcase_87 AC 23 ms
21,952 KB
testcase_88 AC 29 ms
21,892 KB
testcase_89 AC 56 ms
22,216 KB
testcase_90 AC 20 ms
21,804 KB
testcase_91 AC 21 ms
22,612 KB
testcase_92 AC 20 ms
21,892 KB
testcase_93 AC 23 ms
21,792 KB
testcase_94 AC 28 ms
21,952 KB
testcase_95 AC 22 ms
21,940 KB
testcase_96 AC 25 ms
21,964 KB
testcase_97 AC 60 ms
21,880 KB
testcase_98 AC 28 ms
21,904 KB
testcase_99 AC 26 ms
21,952 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

//interactive

char sy[20][20];
char sx[20][20];
ll ey[20][20],ey0[20][20];
ll ex[20][20],ex0[20][20];
ll d[20][20];

ll cost_c=100000;
ll cost_i=800;
ll cost_w=1600000;

{
	rd_ll(); // H
	rd_ll(); // W
	rd_ll(); // p
	
	rep(y,20){
		rep(x,20){
			ey[y][x]=(ey0[y][x]=cost_c+abs(y*2+1-x*2))+cost_i;
			ex[y][x]=(ex0[y][x]=cost_c+abs(y*2-x*2-1))+cost_i;
		}
	}

	DijkstraHeap<ll> h;
	h.walloc(400);
	while(true){
		{
			h.init(400);
			h.change(19*20+19,-0);
			while(h.size){
				ll k=h.pop();
				ll v=h.val[k];
				ll y=k/20;
				ll x=k%20;
				d[y][x]=v;
				v&=~3l;
				if(y!= 0) h.change(k-20,v+ey[y-1][x]*4+0);
				if(y!=19) h.change(k+20,v+ey[y-0][x]*4+1);
				if(x!= 0) h.change(k- 1,v+ex[y][x-1]*4+2);
				if(x!=19) h.change(k+ 1,v+ex[y][x-0]*4+3);
			}
		}
		char p[401];
		{
			ll l=0;
			ll x=0;
			ll y=0;
			while(!(y==19&&x==19)){
				ll c=d[y][x]&3;
				p[l++]="DURL"[c];
				y+=(c==0)-(c==1);
				x+=(c==2)-(c==3);
			}
			p[l]=0;
			wt(p);
		}
		{
			ll@r;
			if(r<0) exit(0);
			ll x=0;
			ll y=0;
			rep(i,r){
				ll c=p[i];
				if(c=='U') if(!sy[--y][x]) sy[y-0][x]=1,ey[y-0][x]=ey0[y-0][x];
				if(c=='D') if(!sy[y++][x]) sy[y-1][x]=1,ey[y-1][x]=ey0[y-1][x];
				if(c=='L') if(!sx[y][--x]) sx[y][x-0]=1,ex[y][x-0]=ex0[y][x-0];
				if(c=='R') if(!sx[y][x++]) sx[y][x-1]=1,ex[y][x-1]=ex0[y][x-1];
			}
			{
				ll c=p[r];
				if(c=='U') if(!sy[--y][x]) ey[y-0][x]+=cost_w;
				if(c=='D') if(!sy[y++][x]) ey[y-1][x]+=cost_w;
				if(c=='L') if(!sx[y][--x]) ex[y][x-0]+=cost_w;
				if(c=='R') if(!sx[y][x++]) ex[y][x-1]+=cost_w;
			}
		}
	}
}
0