結果

問題 No.1099 Range Square Sum
ユーザー tailstails
提出日時 2020-07-09 13:08:42
言語 cLay
(20240104-1)
結果
AC  
実行時間 149 ms / 2,000 ms
コード長 582 bytes
コンパイル時間 3,325 ms
コンパイル使用メモリ 185,532 KB
実行使用メモリ 26,848 KB
最終ジャッジ日時 2023-09-19 00:45:20
合計ジャッジ時間 6,529 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 2 ms
4,376 KB
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 2 ms
4,376 KB
testcase_20 AC 2 ms
4,376 KB
testcase_21 AC 149 ms
26,724 KB
testcase_22 AC 147 ms
26,796 KB
testcase_23 AC 147 ms
26,712 KB
testcase_24 AC 141 ms
26,724 KB
testcase_25 AC 145 ms
26,848 KB
testcase_26 AC 79 ms
26,800 KB
testcase_27 AC 79 ms
26,756 KB
testcase_28 AC 76 ms
26,688 KB
testcase_29 AC 78 ms
26,724 KB
testcase_30 AC 77 ms
26,704 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

struct V{
	ll x,y,m;
	V(){m=1;}
	V(int _x){x=_x;y=0;m=1;}
};

bool operator!=(V v,int i){return v.x;}

V operator*(int m,V v){
	v.m=m;
	return v;
}

void operator+=(V&v,V w){
	if(v.m==0&&w.m!=0){
		v.y+=(2*v.x+w.m*w.x)*w.x;
		v.x+=w.m*w.x;
	}else{
		v.y+=w.y;
		v.x+=w.x;
	}
}

V operator+(V v,V w){
	v+=w;
	return v;
}

{
	ll n,a;
	segtree_ChangeAdd_Sum<V> t;
	rd(n);
	t.walloc(n,1);
	rep(i,n){
		rd(a);
		t[i].x=a;
		t[i].y=a*a;
		t[i].m=0;
	}
	t.build();
	rd(n);
	rep(n){
		ll x,l,r;
		rd(x,l--,r);
		if(x==1){
			rd(x);
			t.add(l,r,x);
		}else{
			wt(t.getSum(l,r).y);
		}
	}
}
0