結果

問題 No.1868 Teleporting Cyanmond
ユーザー publflpublfl
提出日時 2022-03-11 21:25:35
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 38 ms / 2,000 ms
コード長 823 bytes
コンパイル時間 474 ms
コンパイル使用メモリ 34,560 KB
実行使用メモリ 4,444 KB
最終ジャッジ日時 2023-10-14 06:08:03
合計ジャッジ時間 2,288 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,348 KB
testcase_01 AC 2 ms
4,352 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 38 ms
4,352 KB
testcase_04 AC 29 ms
4,352 KB
testcase_05 AC 3 ms
4,356 KB
testcase_06 AC 7 ms
4,356 KB
testcase_07 AC 19 ms
4,352 KB
testcase_08 AC 12 ms
4,348 KB
testcase_09 AC 17 ms
4,352 KB
testcase_10 AC 35 ms
4,352 KB
testcase_11 AC 2 ms
4,352 KB
testcase_12 AC 10 ms
4,356 KB
testcase_13 AC 18 ms
4,348 KB
testcase_14 AC 34 ms
4,348 KB
testcase_15 AC 22 ms
4,348 KB
testcase_16 AC 5 ms
4,348 KB
testcase_17 AC 8 ms
4,352 KB
testcase_18 AC 33 ms
4,352 KB
testcase_19 AC 34 ms
4,392 KB
testcase_20 AC 33 ms
4,388 KB
testcase_21 AC 33 ms
4,368 KB
testcase_22 AC 33 ms
4,444 KB
testcase_23 AC 32 ms
4,404 KB
testcase_24 AC 31 ms
4,388 KB
testcase_25 AC 32 ms
4,388 KB
testcase_26 AC 32 ms
4,420 KB
testcase_27 AC 32 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#define MAX 12345678

struct segTree{
	int value[400010];
	void setValue(int ind, int val, int l=1, int r=100000, int v=1)
	{
		if(l==r) value[v] = val;
		else
		{
			int h = (l+r)/2;
			if(ind<=h) setValue(ind,val,l,h,2*v);
			else setValue(ind,val,h+1,r,2*v+1);
			value[v] = value[2*v]<value[2*v+1]?value[2*v]:value[2*v+1];
		}
	}
	int getMin(int L, int R, int l=1, int r=100000, int v=1)
	{
		if(L<=l&&r<=R) return value[v];
		else if(r<L) return MAX;
		else if(R<l) return MAX;
		else
		{
			int h = (l+r)/2;
			int s1 = getMin(L,R,l,h,2*v);
			int s2 = getMin(L,R,h+1,r,2*v+1);
			return s1<s2?s1:s2;
		}
	}
}T;

int x[100010];
int main()
{
	int a;
	scanf("%d",&a);
	for(int i=1;i<a;i++) scanf("%d",&x[i]);
	for(int i=a-1;i>=1;i--) T.setValue(i,T.getMin(i+1,x[i])+1);
	printf("%d",T.getMin(1,1));
}
0