Submission #2166458
Source Code Expand
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;
const int MAXN = 101010 * 3;
struct node{
int l, r, len;
int stu;
node(bool s = true, int lc = 0, int rc = 0, int l = 0): stu(s), l(lc), r(rc), len(l){}
}tree[MAXN * 4], poin[MAXN];
struct question{
int l, r;
bool stu;
question(int lc = 0, int rc = 0, bool s = true): l(lc), r(rc), stu(s){}
}que[MAXN];
int n, q, tem, lef;
int arr[MAXN], len;
void build(int o, int l, int r){
if(l == r){
tree[o] = poin[l];
return ;
}
int m = (l + r) >> 1;
build(o<<1, l, m);
build(o*2+1, m+1, r);
poin[o].l = poin[o*2].l;
poin[o].r = poin[o*2+1].r;
poin[o].len = poin[o].r - poin[o].l;
}
void puin(){
scanf("%d%d", &n, &q);
for(int i = 1; i <= q; i ++){
scanf("%d%d%d", &que[i].l, &que[i].r, &tem);
que[i].stu = tem - 1;
arr[i*2-1] = que[i].l - 1;
arr[i*2] = que[i].r;
}
arr[q*2+1] = n;
sort(arr+1, arr+1+2*q+1);
int len = unique(arr, arr+1+2*q+1) - arr - 1;
for(int i = 1; i <= len; i ++){
poin[i].l = arr[i-1];
poin[i].r = arr[i];
poin[i].len = arr[i] - arr[i-1];
}
build(1, 1, len);
}
int ql, qr, stu;
void pushdown(int o, int l, int r){
int lc = o*2, rc = o*2 + 1;
if(tree[o].stu >= 0){
tree[lc].stu = tree[rc].stu = tree[o].stu;
tree[o].stu = -1;
}
}
void maintain(int o, int l, int r){
if(tree[o].stu != -1){
tree[o].len = (tree[o].r - tree[o].l) * tree[o].stu;
return ;
}
int lc = o*2, rc = o*2+1;
tree[o].len = tree[lc].len + tree[rc].len;
return ;
}
void deal(int o, int l, int r){
if(ql <= tree[o].l && tree[o].r <= qr){
tree[o].stu = stu;
tree[o].len = (tree[o].r - tree[o].l) * tree[o].stu;
return ;
}
pushdown(o, l, r);
int m = (l + r) >> 1;
int len = 0, lc = o*2, rc = o*2+1;
if(tree[m].l < qr)
deal(lc, l, m);
else
maintain(lc, l, m);
if(ql <= tree[m].r)
deal(rc, m+1, r);
else
maintain(rc, m+1, r);
maintain(o, l, r);
//return tree[o].len;
}
void proc(){
for(int i = 1; i <= q; i ++){
ql = que[i].l - 1;
qr = que[i].r;
stu = que[i].stu - 1;
//printf("test: %d %d %d\n", ql, qr, stu);
deal(1, 1, len);
printf("%d\n", tree[1].len);
}
}
int main(){
puin();
proc();
return 0;
}
Submission Info
Submission Time |
|
Task |
C - Paired Parentheses |
User |
vjudge3 |
Language |
Bash (GNU bash v4.3.11) |
Score |
0 |
Code Size |
2478 Byte |
Status |
RE |
Exec Time |
4 ms |
Memory |
648 KB |
Judge Result
Set Name |
Sample |
Subtask1 |
Subtask2 |
All |
Score / Max Score |
0 / 0 |
0 / 200 |
0 / 300 |
0 / 200 |
Status |
|
|
|
|
Set Name |
Test Cases |
Sample |
00_example_01.txt, 00_example_02.txt |
Subtask1 |
00_example_01.txt, s1_01.txt, s1_02.txt, s1_03.txt, s1_04.txt, s1_05.txt, s1_06.txt, s1_07.txt, s1_08.txt, s1_09.txt, s1_10.txt, s1_11.txt, s1_12.txt, s1_13.txt |
Subtask2 |
s2_14.txt, s2_15.txt, s2_16.txt, s2_17.txt, s2_18.txt, s2_19.txt, s2_20.txt, s2_21.txt, s2_22.txt, s2_23.txt, s2_24.txt, s2_25.txt, s2_26.txt, s2_27.txt, s2_28.txt |
All |
00_example_01.txt, 00_example_02.txt, s1_01.txt, s1_02.txt, s1_03.txt, s1_04.txt, s1_05.txt, s1_06.txt, s1_07.txt, s1_08.txt, s1_09.txt, s1_10.txt, s1_11.txt, s1_12.txt, s1_13.txt, s2_14.txt, s2_15.txt, s2_16.txt, s2_17.txt, s2_18.txt, s2_19.txt, s2_20.txt, s2_21.txt, s2_22.txt, s2_23.txt, s2_24.txt, s2_25.txt, s2_26.txt, s2_27.txt, s2_28.txt, s3_29.txt, s3_30.txt, s3_31.txt, s3_32.txt, s3_33.txt, s3_34.txt, s3_35.txt, s3_36.txt, s3_37.txt, s3_38.txt, s3_39.txt, s3_40.txt, s3_41.txt |
Case Name |
Status |
Exec Time |
Memory |
00_example_01.txt |
RE |
4 ms |
644 KB |
00_example_02.txt |
RE |
4 ms |
572 KB |
s1_01.txt |
RE |
4 ms |
572 KB |
s1_02.txt |
RE |
4 ms |
572 KB |
s1_03.txt |
RE |
4 ms |
572 KB |
s1_04.txt |
RE |
4 ms |
648 KB |
s1_05.txt |
RE |
4 ms |
576 KB |
s1_06.txt |
RE |
4 ms |
572 KB |
s1_07.txt |
RE |
4 ms |
572 KB |
s1_08.txt |
RE |
4 ms |
644 KB |
s1_09.txt |
RE |
4 ms |
572 KB |
s1_10.txt |
RE |
4 ms |
576 KB |
s1_11.txt |
RE |
4 ms |
576 KB |
s1_12.txt |
RE |
4 ms |
572 KB |
s1_13.txt |
RE |
4 ms |
572 KB |
s2_14.txt |
RE |
4 ms |
572 KB |
s2_15.txt |
RE |
4 ms |
572 KB |
s2_16.txt |
RE |
4 ms |
572 KB |
s2_17.txt |
RE |
4 ms |
576 KB |
s2_18.txt |
RE |
4 ms |
572 KB |
s2_19.txt |
RE |
4 ms |
572 KB |
s2_20.txt |
RE |
4 ms |
576 KB |
s2_21.txt |
RE |
4 ms |
572 KB |
s2_22.txt |
RE |
4 ms |
644 KB |
s2_23.txt |
RE |
4 ms |
572 KB |
s2_24.txt |
RE |
4 ms |
648 KB |
s2_25.txt |
RE |
4 ms |
572 KB |
s2_26.txt |
RE |
4 ms |
648 KB |
s2_27.txt |
RE |
4 ms |
640 KB |
s2_28.txt |
RE |
4 ms |
640 KB |
s3_29.txt |
RE |
4 ms |
576 KB |
s3_30.txt |
RE |
4 ms |
572 KB |
s3_31.txt |
RE |
4 ms |
572 KB |
s3_32.txt |
RE |
4 ms |
572 KB |
s3_33.txt |
RE |
4 ms |
572 KB |
s3_34.txt |
RE |
4 ms |
640 KB |
s3_35.txt |
RE |
4 ms |
572 KB |
s3_36.txt |
RE |
4 ms |
572 KB |
s3_37.txt |
RE |
4 ms |
572 KB |
s3_38.txt |
RE |
4 ms |
572 KB |
s3_39.txt |
RE |
4 ms |
572 KB |
s3_40.txt |
RE |
4 ms |
576 KB |
s3_41.txt |
RE |
4 ms |
572 KB |