結果

問題 No.2697 Range LIS Query
ユーザー kotatsugamekotatsugame
提出日時 2024-03-22 21:56:31
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 267 ms / 10,000 ms
コード長 1,119 bytes
コンパイル時間 1,107 ms
コンパイル使用メモリ 86,080 KB
実行使用メモリ 26,576 KB
最終ジャッジ日時 2024-03-22 21:56:39
合計ジャッジ時間 4,942 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 2 ms
6,676 KB
testcase_03 AC 7 ms
6,676 KB
testcase_04 AC 8 ms
6,676 KB
testcase_05 AC 7 ms
6,676 KB
testcase_06 AC 232 ms
26,576 KB
testcase_07 AC 262 ms
26,576 KB
testcase_08 AC 232 ms
26,576 KB
testcase_09 AC 165 ms
26,576 KB
testcase_10 AC 165 ms
26,576 KB
testcase_11 AC 164 ms
26,576 KB
testcase_12 AC 146 ms
25,656 KB
testcase_13 AC 163 ms
24,424 KB
testcase_14 AC 240 ms
24,568 KB
testcase_15 AC 265 ms
26,576 KB
testcase_16 AC 267 ms
26,576 KB
testcase_17 AC 263 ms
26,576 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<array>
#include<cassert>
#include<atcoder/lazysegtree>
using namespace std;
using dat=array<array<int,4>,4>;
dat op(dat a,dat b)
{
	dat ret={};
	for(int i=0;i<4;i++)for(int j=i;j<4;j++)for(int k=j;k<4;k++)
	{
		ret[i][k]=max(ret[i][k],a[i][j]+b[j][k]);
	}
	ret[3][0]=a[3][0]+b[3][0];
	return ret;
}
dat e(){return(dat){};}
dat mk(int a,int len){
	a--;
	dat ret=e();
	for(int i=0;i<=a;i++)for(int j=a;j<4;j++)ret[i][j]=len;
	ret[3][0]=len;
	return ret;
}
dat mp(int f,dat x){
	if(f!=-1)
	{
		int len=x[3][0];
		return mk(f,len);
	}
	else return x;
}
int cmp(int f,int g){return f==-1?g:f;}
int id(){return-1;}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int N;cin>>N;
	vector<dat>init(N);
	for(int i=0;i<N;i++)
	{
		int a;cin>>a;
		init[i]=mk(a,1);
	}
	atcoder::lazy_segtree<dat,op,e,int,mp,cmp,id>seg(init);
	int Q;cin>>Q;
	for(;Q--;)
	{
		int t,l,r;cin>>t>>l>>r;l--;
		if(t==1)
		{
			dat now=seg.prod(l,r);
			int ans=0;
			for(int i=0;i<4;i++)for(int j=i;j<4;j++)ans=max(ans,now[i][j]);
			cout<<ans<<"\n";
		}
		else
		{
			int x;cin>>x;
			seg.apply(l,r,x);
		}
	}
}
0