提出 #32026452
ソースコード 拡げる
#include <bits/stdc++.h>
//#define int long long
#define pai 3.141592653589793238462643383279502884197169399375105820
#define MOD 1000000007
#define eps 0.00000001
inline int min(int a,int b) {return a<b?a:b;}
inline int max(int a,int b) {return a>b?a:b;}
#define ULL unsigned long long
#define LL long long
#define INF 0x3f3f3f3f
#define INF_LL 0x3f3f3f3f3f3f3f3f
static char buf[1000000],*paa=buf,*pd=buf;
static char buf2[1000000],*pp=buf2;
#define getchar() paa==pd&&(pd=(paa=buf)+fread(buf,1,1000000,stdin),paa==pd)?EOF:*paa++
inline void pc(char ch){
if(pp-buf2==1000000) fwrite(buf2,1,1000000,stdout),pp=buf2;
*pp++=ch;
}
inline void pcc(){
fwrite(buf2,1,pp-buf2,stdout);
pp=buf2;
}
inline int read(void) {
int w=1;
register int x(0);register char c(getchar());
while(c<'0'||c>'9') {if(c=='-') w=-1;c=getchar();}
while(c>='0'&&c<='9') x=(x<<1)+(x<<3)+(c^48),c=getchar();
return w*x;
}
void write(int x) {
static int sta[20];
int top=0;
do {
sta[top++]=x%10,x/=10;
} while(x);
while(top) pc(sta[--top]+48);
}
void we(int x) {
write(x);
pc('\n');
}
inline bool cmp_xi(int a,int b) {return a<b;}
inline bool cmp_da(int a,int b) {return a>b;}
#define md ((l+r)>>1)
int N,M,Q,rt[200009],fst[200009],ct[200009],ls[50000009],rs[50000009],k;long long seg[50000009];
void up(int& n1,int n2,int l,int r,int p1,int v1,int p2,int v2) {
if((p1<l||p1>r)&&(p2<l||p2>r)) {
n1=n2;
return;
}
if(n1==0) n1=++k;
if(l==r) {
if(l==p1) seg[n1]=seg[n2]+v1;
else seg[n1]=seg[n2]+v2;
return;
}
up(ls[n1],ls[n2],l,md,p1,v1,p2,v2);
up(rs[n1],rs[n2],md+1,r,p1,v1,p2,v2);
seg[n1]=seg[ls[n1]]+seg[rs[n1]];
}
long long q(int n,int l,int r,int L,int R) {
if(n==0||r<L||R<l) return 0;
if(L<=l&&r<=R) return seg[n];
return q(ls[n],l,md,L,R)+q(rs[n],md+1,r,L,R);
}
signed main(void) {
//freopen("m.in","r",stdin);
//freopen("m.out","w",stdout);
N=read(),M=read(),Q=read();
rt[0]=++k;
for(int i=1;i<=Q;i++) {
int op=read(),l,r,x;
if(op==1) {
l=read(),r=read(),x=read();
up(rt[i],rt[i-1],1,M,r+1,-x,l,x);
} else if(op==2) {
l=read(),x=read();
fst[l]=i;
ct[l]=x;
rt[i]=rt[i-1];
} else {
l=read(),r=read();
rt[i]=rt[i-1];
printf("%lld\n",q(rt[i],1,M,1,r)-q(rt[fst[l]],1,M,1,r)+ct[l]);
}
}
return 0;
}
提出情報
コンパイルエラー
./Main.cpp: In function ‘int read()’:
./Main.cpp:25:15: warning: ISO C++17 does not allow ‘register’ storage class specifier [-Wregister]
25 | register int x(0);register char c(getchar());
| ^
./Main.cpp:25:34: warning: ISO C++17 does not allow ‘register’ storage class specifier [-Wregister]
25 | register int x(0);register char c(getchar());
| ^
ジャッジ結果
| セット名 |
Sample |
All |
| 得点 / 配点 |
0 / 0 |
500 / 500 |
| 結果 |
|
|
| セット名 |
テストケース |
| Sample |
example_00.txt, example_01.txt, example_02.txt |
| All |
example_00.txt, example_01.txt, example_02.txt, test_00.txt, test_01.txt, test_02.txt, test_03.txt, test_04.txt, test_05.txt, test_06.txt, test_07.txt, test_08.txt, test_09.txt, test_10.txt, test_11.txt, test_12.txt, test_13.txt, test_14.txt, test_15.txt, test_16.txt, test_17.txt, test_18.txt, test_19.txt, test_20.txt, test_21.txt, test_22.txt, test_23.txt, test_24.txt, test_25.txt, test_26.txt, test_27.txt, test_28.txt, test_29.txt, test_30.txt |
| ケース名 |
結果 |
実行時間 |
メモリ |
| example_00.txt |
AC |
14 ms |
3504 KiB |
| example_01.txt |
AC |
2 ms |
3756 KiB |
| example_02.txt |
AC |
2 ms |
3596 KiB |
| test_00.txt |
AC |
170 ms |
43808 KiB |
| test_01.txt |
AC |
142 ms |
43832 KiB |
| test_02.txt |
AC |
159 ms |
43612 KiB |
| test_03.txt |
AC |
154 ms |
43648 KiB |
| test_04.txt |
AC |
141 ms |
43780 KiB |
| test_05.txt |
AC |
128 ms |
38484 KiB |
| test_06.txt |
AC |
124 ms |
41828 KiB |
| test_07.txt |
AC |
142 ms |
41948 KiB |
| test_08.txt |
AC |
134 ms |
41208 KiB |
| test_09.txt |
AC |
119 ms |
38352 KiB |
| test_10.txt |
AC |
7 ms |
4380 KiB |
| test_11.txt |
AC |
114 ms |
38228 KiB |
| test_12.txt |
AC |
52 ms |
20156 KiB |
| test_13.txt |
AC |
126 ms |
40424 KiB |
| test_14.txt |
AC |
61 ms |
22668 KiB |
| test_15.txt |
AC |
27 ms |
12104 KiB |
| test_16.txt |
AC |
35 ms |
13332 KiB |
| test_17.txt |
AC |
92 ms |
30804 KiB |
| test_18.txt |
AC |
39 ms |
15724 KiB |
| test_19.txt |
AC |
15 ms |
7408 KiB |
| test_20.txt |
AC |
119 ms |
44008 KiB |
| test_21.txt |
AC |
118 ms |
43540 KiB |
| test_22.txt |
AC |
120 ms |
43872 KiB |
| test_23.txt |
AC |
119 ms |
43772 KiB |
| test_24.txt |
AC |
122 ms |
43760 KiB |
| test_25.txt |
AC |
119 ms |
43740 KiB |
| test_26.txt |
AC |
121 ms |
43872 KiB |
| test_27.txt |
AC |
121 ms |
44008 KiB |
| test_28.txt |
AC |
121 ms |
43876 KiB |
| test_29.txt |
AC |
125 ms |
43728 KiB |
| test_30.txt |
AC |
91 ms |
64772 KiB |