結果

問題 No.2697 Range LIS Query
ユーザー tailstails
提出日時 2024-03-27 11:40:49
言語 cLay
(20240104-1)
結果
AC  
実行時間 207 ms / 10,000 ms
コード長 956 bytes
コンパイル時間 4,008 ms
コンパイル使用メモリ 186,296 KB
実行使用メモリ 25,284 KB
最終ジャッジ日時 2024-03-27 11:40:56
合計ジャッジ時間 7,110 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
7,480 KB
testcase_01 AC 2 ms
7,480 KB
testcase_02 AC 1 ms
7,480 KB
testcase_03 AC 6 ms
7,992 KB
testcase_04 AC 6 ms
7,992 KB
testcase_05 AC 6 ms
7,992 KB
testcase_06 AC 183 ms
24,900 KB
testcase_07 AC 183 ms
24,900 KB
testcase_08 AC 183 ms
24,900 KB
testcase_09 AC 98 ms
24,900 KB
testcase_10 AC 97 ms
24,900 KB
testcase_11 AC 124 ms
24,900 KB
testcase_12 AC 115 ms
23,364 KB
testcase_13 AC 127 ms
22,212 KB
testcase_14 AC 173 ms
22,852 KB
testcase_15 AC 207 ms
25,284 KB
testcase_16 AC 205 ms
25,284 KB
testcase_17 AC 204 ms
25,284 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <sys/mman.h>

#define mminit() char*rp=static_cast<char*>(mmap(0,1<<25,1,2,0,0))
#define mmrd() ({int _v=0,_c;while(_c=*rp++-48,_c>=0)_v=_v*10+_c;_v;})

struct V{
	int l;
	int h[4][4];
};

struct F{
	int a;
};

inline
V segtree_rh_merge(V a, V b){
	V r;
	r.l=a.l+b.l;
	rep(u,4){
		rep(v,4){
			r.h[u][v]=0;
			rep(w,u,v+1){
				r.h[u][v]>?=a.h[u][w]+b.h[w][v];
			}
		}
	}
	return r;
}

inline
V segtree_rh_apply(F f, V a){
	V r;
	r.l=a.l;
	rep(u,4){
		rep(v,4){
			r.h[u][v]=u<=f.a&&f.a<=v?r.l:0;
		}
	}
	return r;
}

inline
F segtree_rh_compose(F f, F g){
	return f;
}

{
	mminit();
	segtree_rh<V,F>t;
	int n=mmrd();
	t.malloc(n,1);
	rep(i,n){
		int a=mmrd()-1;
		t[i].l=1;
		rep(u,4){
			rep(v,4){
				t[i].h[u][v]=u<=a&&a<=v;
			}
		}
	}
	t.build();
	int q=mmrd();
	rep(q){
		int y=mmrd();
		if(y==1){
			int l=mmrd(),r=mmrd();
			wt(t.get(l-1,r).h[0][3]);
		}
		if(y==2){
			int l=mmrd(),r=mmrd(),x=mmrd()-1;
			t.change(l-1,r,{x});
		}
	}
}
0