結果

問題 No.2242 Cities and Teleporters
ユーザー tailstails
提出日時 2023-03-11 14:46:17
言語 cLay
(20240104-1)
結果
AC  
実行時間 348 ms / 3,000 ms
コード長 365 bytes
コンパイル時間 8,226 ms
コンパイル使用メモリ 220,564 KB
実行使用メモリ 47,304 KB
最終ジャッジ日時 2023-10-18 09:53:25
合計ジャッジ時間 14,335 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 31 ms
35,960 KB
testcase_01 AC 31 ms
35,960 KB
testcase_02 AC 31 ms
35,960 KB
testcase_03 AC 31 ms
35,960 KB
testcase_04 AC 31 ms
35,960 KB
testcase_05 AC 202 ms
47,304 KB
testcase_06 AC 206 ms
47,304 KB
testcase_07 AC 216 ms
47,304 KB
testcase_08 AC 348 ms
47,304 KB
testcase_09 AC 172 ms
47,304 KB
testcase_10 AC 72 ms
47,304 KB
testcase_11 AC 111 ms
47,084 KB
testcase_12 AC 113 ms
47,084 KB
testcase_13 AC 134 ms
47,264 KB
testcase_14 AC 193 ms
47,304 KB
testcase_15 AC 133 ms
47,264 KB
testcase_16 AC 188 ms
47,304 KB
testcase_17 AC 304 ms
47,304 KB
testcase_18 AC 128 ms
47,152 KB
testcase_19 AC 278 ms
47,140 KB
testcase_20 AC 133 ms
47,180 KB
testcase_21 AC 124 ms
47,100 KB
testcase_22 AC 271 ms
47,100 KB
testcase_23 AC 252 ms
47,184 KB
testcase_24 AC 142 ms
47,184 KB
testcase_25 AC 83 ms
47,184 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

int@n,@h[n],@t[],e[18][4d5]{},@q;
coordcomp(n,h,n,t);
rep(i,n){
	e[0][h[i]]>?=t[i];
}
rep(i,1,4d5){
	e[0][i]>?=e[0][i-1];
}
rep(k,1,18){
	rep(i,4d5){
		e[k][i]=e[k-1][e[k-1][i]];
	}
}
rep(q){
	int@a--,@b--;
	if(t[a]>=h[b]){
		wt(1);
	}else{
		int c=t[a];
		int z=1;
		rrep(k,18){
			if(e[k][c]<h[b]){
				z+=1<<k;
				c=e[k][c];
			}
		}
		wt(z<1<<18?z+1:-1);
	}
}
0