結果

問題 No.1572 XI
ユーザー tailstails
提出日時 2021-06-28 11:04:01
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 122 ms / 2,000 ms
コード長 1,336 bytes
コンパイル時間 471 ms
コンパイル使用メモリ 31,732 KB
実行使用メモリ 22,636 KB
最終ジャッジ日時 2023-09-07 18:18:22
合計ジャッジ時間 3,936 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 0 ms
4,376 KB
testcase_03 AC 0 ms
4,376 KB
testcase_04 AC 14 ms
4,800 KB
testcase_05 AC 65 ms
13,168 KB
testcase_06 AC 50 ms
12,080 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 3 ms
4,376 KB
testcase_09 AC 30 ms
10,072 KB
testcase_10 AC 14 ms
5,304 KB
testcase_11 AC 5 ms
4,380 KB
testcase_12 AC 23 ms
9,468 KB
testcase_13 AC 8 ms
4,376 KB
testcase_14 AC 18 ms
5,704 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 15 ms
5,600 KB
testcase_17 AC 3 ms
4,376 KB
testcase_18 AC 1 ms
4,380 KB
testcase_19 AC 11 ms
4,548 KB
testcase_20 AC 8 ms
4,376 KB
testcase_21 AC 53 ms
12,684 KB
testcase_22 AC 64 ms
14,492 KB
testcase_23 AC 2 ms
4,376 KB
testcase_24 AC 1 ms
4,376 KB
testcase_25 AC 1 ms
4,380 KB
testcase_26 AC 0 ms
4,376 KB
testcase_27 AC 1 ms
4,380 KB
testcase_28 AC 1 ms
4,380 KB
testcase_29 AC 0 ms
4,380 KB
testcase_30 AC 1 ms
4,380 KB
testcase_31 AC 1 ms
4,376 KB
testcase_32 AC 0 ms
4,380 KB
testcase_33 AC 1 ms
4,380 KB
testcase_34 AC 9 ms
4,516 KB
testcase_35 AC 4 ms
4,376 KB
testcase_36 AC 32 ms
9,504 KB
testcase_37 AC 120 ms
22,636 KB
testcase_38 AC 73 ms
14,412 KB
testcase_39 AC 53 ms
12,928 KB
testcase_40 AC 17 ms
5,976 KB
testcase_41 AC 72 ms
15,396 KB
testcase_42 AC 122 ms
22,588 KB
testcase_43 AC 49 ms
13,040 KB
testcase_44 AC 15 ms
5,604 KB
testcase_45 AC 88 ms
18,044 KB
testcase_46 AC 90 ms
17,884 KB
testcase_47 AC 2 ms
4,376 KB
testcase_48 AC 72 ms
14,480 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c:12:1: 警告: 戻り値の型をデフォルトの ‘int’ にします [-Wimplicit-int]
   12 | main(){
      | ^~~~
main.c: 関数 ‘main’ 内:
main.c:13:9: 警告: implicit declaration of function ‘read’; did you mean ‘rd’? [-Wimplicit-function-declaration]
   13 |         read(0,rbuf,sizeof rbuf);
      |         ^~~~
      |         rd
main.c:34:33: 警告: 関数 ‘write’ の暗黙的な宣言です [-Wimplicit-function-declaration]
   34 |                                 write(1,wp,wbuf+sizeof wbuf-wp);
      |                                 ^~~~~
main.c:35:33: 警告: implicit declaration of function ‘_exit’; did you mean ‘_Exit’? [-Wimplicit-function-declaration]
   35 |                                 _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][1001][6];
int q[6000000];

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

	++w;

	long r=0;
	long qr=0,qw=0;
	q[qw++]=0|sx<<3|sy<<13;
	while(qr<qw){
		long qn=qw;
		while(qr<qn){
			long d=q[qr]&7;
			long x=q[qr]>>3&1023;
			long y=q[qr]>>13;
			++qr;
			if(y==gy&&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[(y-0)*w+(x-1)]=='.'){
				long d2="\1\5\2\0\4\3"[d];
				if(!v[y+1][x][d2]){
					v[y+1][x][d2]=1;
					q[qw++]=d2|x<<3|y+1<<13;
				}
			}
			// x+1
			if(rp[(y-1)*w+(x-0)]=='.'){
				long d2="\2\1\5\3\0\4"[d];
				if(!v[y][x+1][d2]){
					v[y][x+1][d2]=1;
					q[qw++]=d2|x+1<<3|y<<13;
				}
			}
			// y-1
			if(rp[(y-2)*w+(x-1)]=='.'){
				long d2="\3\0\2\5\4\1"[d];
				if(!v[y-1][x][d2]){
					v[y-1][x][d2]=1;
					q[qw++]=d2|x<<3|y-1<<13;
				}
			}
			// x-1
			if(rp[(y-1)*w+(x-2)]=='.'){
				long d2="\4\1\0\3\5\2"[d];
				if(!v[y][x-1][d2]){
					v[y][x-1][d2]=1;
					q[qw++]=d2|x-1<<3|y<<13;
				}
			}
		}
		++r;
	}
	write(1,"-1",2);
	_exit(0);
}
0