結果

問題 No.1572 XI
ユーザー tailstails
提出日時 2021-06-30 10:32:02
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 108 ms / 2,000 ms
コード長 1,260 bytes
コンパイル時間 407 ms
コンパイル使用メモリ 31,060 KB
実行使用メモリ 22,328 KB
最終ジャッジ日時 2023-09-09 04:16:16
合計ジャッジ時間 4,900 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 0 ms
4,380 KB
testcase_02 AC 0 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 12 ms
4,376 KB
testcase_05 AC 57 ms
12,952 KB
testcase_06 AC 42 ms
10,852 KB
testcase_07 AC 2 ms
4,384 KB
testcase_08 AC 3 ms
4,380 KB
testcase_09 AC 23 ms
6,940 KB
testcase_10 AC 12 ms
4,376 KB
testcase_11 AC 4 ms
4,380 KB
testcase_12 AC 18 ms
6,496 KB
testcase_13 AC 5 ms
4,376 KB
testcase_14 AC 14 ms
4,376 KB
testcase_15 AC 2 ms
4,376 KB
testcase_16 AC 11 ms
4,376 KB
testcase_17 AC 2 ms
4,376 KB
testcase_18 AC 1 ms
4,376 KB
testcase_19 AC 10 ms
4,376 KB
testcase_20 AC 7 ms
4,380 KB
testcase_21 AC 46 ms
11,736 KB
testcase_22 AC 55 ms
12,924 KB
testcase_23 AC 1 ms
4,380 KB
testcase_24 AC 1 ms
4,380 KB
testcase_25 AC 0 ms
4,380 KB
testcase_26 AC 1 ms
4,380 KB
testcase_27 AC 1 ms
4,380 KB
testcase_28 AC 1 ms
4,380 KB
testcase_29 AC 1 ms
4,376 KB
testcase_30 AC 0 ms
4,380 KB
testcase_31 AC 0 ms
4,380 KB
testcase_32 AC 0 ms
4,380 KB
testcase_33 AC 1 ms
4,380 KB
testcase_34 AC 8 ms
4,384 KB
testcase_35 AC 3 ms
4,376 KB
testcase_36 AC 29 ms
9,356 KB
testcase_37 AC 105 ms
22,328 KB
testcase_38 AC 65 ms
14,384 KB
testcase_39 AC 47 ms
12,928 KB
testcase_40 AC 16 ms
5,972 KB
testcase_41 AC 64 ms
15,220 KB
testcase_42 AC 108 ms
22,172 KB
testcase_43 AC 44 ms
12,812 KB
testcase_44 AC 13 ms
5,452 KB
testcase_45 AC 79 ms
18,156 KB
testcase_46 AC 79 ms
17,908 KB
testcase_47 AC 2 ms
4,380 KB
testcase_48 AC 64 ms
14,372 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c:12:1: 警告: 戻り値の型をデフォルトの ‘int’ にします [-Wimplicit-int]
   12 | main(){
      | ^~~~
main.c: 関数 ‘main’ 内:
main.c:14:9: 警告: implicit declaration of function ‘read’; did you mean ‘rd’? [-Wimplicit-function-declaration]
   14 |         read(0,rp,rp-rbuf+sizeof rbuf);
      |         ^~~~
      |         rd
main.c:35:33: 警告: 関数 ‘write’ の暗黙的な宣言です [-Wimplicit-function-declaration]
   35 |                                 write(1,wp,wbuf+sizeof wbuf-wp);
      |                                 ^~~~~
main.c:36:33: 警告: implicit declaration of function ‘_exit’; did you mean ‘_Exit’? [-Wimplicit-function-declaration]
   36 |                                 _exit(0);
      |                                 ^~~~~
      |                                 _Exit

ソースコード

diff #

#pragma GCC optimize("Ofast")
#pragma GCC target("avx2")

char rbuf[1<<20];

#define rd(v) int v=0;{int _c;while(_c=*rp++-48,_c>=0)v=v*10+_c;}
#define wt(v) {long _z=v;do*--wp=_z%10+48;while(_z/=10);}

char v[1001*1002][6];
int q[6000000];

main(){
	char*rp=rbuf+4096;
	read(0,rp,rp-rbuf+sizeof rbuf);
	rd(h); rd(w);
	rd(sy); rd(sx);
	rd(gy); rd(gx);

	++w;
	sx=(sx-1)+(sy-1)*w;
	gx=(gx-1)+(gy-1)*w;

	long r=0;
	long qr=0,qw=0;
	q[qw++]=0|sx<<3;
	while(qr<qw){
		long qn=qw;
		while(qr<qn){
			long d=q[qr]&7;
			long x=q[qr]>>3;
			++qr;
			if(x==gx&&d==0){
				char wbuf[64],*wp=wbuf+sizeof wbuf;
				wt(r);
				write(1,wp,wbuf+sizeof wbuf-wp);
				_exit(0);
			}
			// y+1
			if(rp[x+w]=='.'){
				long d2="\1\5\2\0\4\3"[d];
				if(!v[x+w][d2]){
					v[x+w][d2]=1;
					q[qw++]=d2|x+w<<3;
				}
			}
			// x+1
			if(rp[x+1]=='.'){
				long d2="\2\1\5\3\0\4"[d];
				if(!v[x+1][d2]){
					v[x+1][d2]=1;
					q[qw++]=d2|x+1<<3;
				}
			}
			// x-1
			if(rp[x-1]=='.'){
				long d2="\4\1\0\3\5\2"[d];
				if(!v[x-1][d2]){
					v[x-1][d2]=1;
					q[qw++]=d2|x-1<<3;
				}
			}
			// y-1
			if(rp[x-w]=='.'){
				long d2="\3\0\2\5\4\1"[d];
				if(!v[x-w][d2]){
					v[x-w][d2]=1;
					q[qw++]=d2|x-w<<3;
				}
			}
		}
		++r;
	}
	write(1,"-1",2);
	_exit(0);
}
0