QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#267487#186. Street LampsFriskLSZ0 12ms9772kbC++141.7kb2023-11-27 13:14:022023-11-27 13:14:02

Judging History

你现在查看的是最新测评结果

  • [2023-11-27 13:14:02]
  • 评测
  • 测评结果:0
  • 用时:12ms
  • 内存:9772kb
  • [2023-11-27 13:14:02]
  • 提交

answer

#include<bits/stdc++.h>

using namespace std;

#define ll long long
#define ull unsigned ll
#define i128 __int128
#define db double
#define ld long db

#define M 5700005
#define N 300005
#define mod 1000000009
#define mod2 1222827239
#define base 51787
#define base2 38833
#define inf 1e9+7
#define dinf 1e15
#define linf 7e18

int n,q;
char c[N];
bool s[N];

int rt[N],tot;

struct segment_tree{
	bool sum[M];
	int ls[M],rs[M];
	
	void push_up(int p){
		sum[p]=sum[ls[p]]&sum[rs[p]];
	}
	
	int build(int l,int r){
		int p=++tot;
		if(l==r){
			sum[p]=s[l];
			return p;
		}
		int mid=(l+r)>>1;
		ls[p]=build(l,mid);
		rs[p]=build(mid+1,r);
		push_up(p);
		return p;
	}
	
	int clone(int p){
		int x=++tot;
		sum[x]=sum[p];
		ls[x]=ls[p];
		rs[x]=rs[p];
		return x;
	}
	
	int update(int p,int i,int L,int R){
		p=clone(p);
		if(L==R){
			sum[p]^=1;
			return p;
		}
		int mid=(L+R)>>1;
		if(i<=mid) ls[p]=update(ls[p],i,L,mid);
		else rs[p]=update(rs[p],i,mid+1,R);
		push_up(p);
		return p;
	}
	
	int query(int p,int l,int r,int L,int R){
		if(l<=L&&R<=r) return sum[p];
		int mid=(L+R)>>1;
		if(r<=mid) return query(ls[p],l,r,L,mid);
		if(l>mid) return query(rs[p],l,r,mid+1,R);
		return query(ls[p],l,r,L,mid)&query(rs[p],l,r,mid+1,R);
	}
}t;

int main(){
	scanf("%d %d %s",&n,&q,c+1);
	for(int i=1;i<=n;++i) s[i]=(c[i]=='1');
	rt[0]=t.build(1,n);
	char op[10];
	for(int p=1;p<=q;++p){
		scanf("%s",op);
		if(op[0]=='t'){
			int i;
			scanf("%d",&i);
			rt[p]=t.update(rt[p-1],i,1,n);
		} else {
			int l,r;
			scanf("%d %d",&l,&r);
			int res=0;
			for(int i=0;i<p;++i) res+=t.query(rt[i],l,r,1,n);
			printf("%d\n",res);
			rt[p]=rt[p-1];
		}
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 20
Accepted
time: 1ms
memory: 7652kb

input:

5 7
11011
query 1 2
query 1 2
query 1 6
query 3 4
toggle 3
query 3 4
query 1 6

output:

1
2
0
0
1
2

result:

ok 6 lines

Test #2:

score: -20
Wrong Answer
time: 1ms
memory: 7688kb

input:

5 50
01001
query 1 6
toggle 3
toggle 3
toggle 2
toggle 3
toggle 2
toggle 4
query 2 6
query 2 3
query 1 3
query 3 5
toggle 3
query 2 6
query 1 5
query 2 3
query 3 6
toggle 5
toggle 1
toggle 2
toggle 4
query 1 6
query 4 5
toggle 3
query 5 6
toggle 2
query 4 6
toggle 5
toggle 5
toggle 2
query 4 5
query...

output:

0
1
4
0
4
5
0
7
5
0
10
17
10
10
5
5
5
11
0
5
0
5
0
5
2

result:

wrong answer 3rd lines differ - expected: '7', found: '4'

Subtask #2:

score: 0
Time Limit Exceeded

Test #9:

score: 0
Time Limit Exceeded

input:

100 300000
1100100000000101010010100111010001100010001100111101000010111110001101101110100100100110101010110010
query 13 14
query 42 43
toggle 64
query 78 79
toggle 85
query 35 36
toggle 35
query 4 5
toggle 5
query 4 5
query 42 43
query 35 36
query 13 14
query 14 15
toggle 15
toggle 31
query 20 21
q...

output:

0
0
0
0
0
0
0
0
0
0
0
18
0
0
21
0
1
0
0
36
8
15
0
44
0
0
20
20
52
0
0
52
56
0
35
0
70
73
0
0
0
0
6
46
84
0
0
0
0
97
0
62
0
0
26
0
46
0
0
59
0
0
1
0
0
0
0
0
0
112
35
123
0
61
0
121
0
35
0
0
73
0
45
0
65
0
0
0
104
0
32
26
54
0
0
35
0
139
23
0
200
0
0
195
208
0
206
131
128
72
128
119
128
0
0
56
0
65
7
...

result:


Subtask #3:

score: 0
Time Limit Exceeded

Test #17:

score: 20
Accepted
time: 0ms
memory: 7884kb

input:

1000 1003
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

output:

0
0
0

result:

ok 3 lines

Test #18:

score: 0
Accepted
time: 5ms
memory: 9668kb

input:

1000 1003
00100001101000000001000001001000100010000010010010001001001010001010101100010001000010101100000001001111000001110000010110100000100110001000000101001110000001110001000100000011001110000011010100101000000010100110100010000000110000111100100000011000100010010100000000100000000010001001110101...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok 304 lines

Test #19:

score: 0
Accepted
time: 8ms
memory: 9772kb

input:

1000 1003
11001001111000111100001101101111110010111101110100101000111001111011110111110111111001110011111110111110101110011101111111111111010111010100011010011100101011111001111010111110111010111011101100100111010000110101110001000011100010111110011001010110101111011101100110001100111000000011000111...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
70
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0...

result:

ok 595 lines

Test #20:

score: 0
Accepted
time: 12ms
memory: 7732kb

input:

1000 1003
11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...

output:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
...

result:

ok 1003 lines

Test #21:

score: -20
Time Limit Exceeded

input:

300000 300000
0000000000000000000000000000000000000000000000000100000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000...

output:


result:


Subtask #4:

score: 0
Wrong Answer

Test #30:

score: 0
Wrong Answer
time: 12ms
memory: 7756kb

input:

1000 1003
10111011001010101101100010101100100010100110001000000001001100111110101100110100010001111101101100110111110100011000111101100100000110110010101011101001101110111100010100100000110001010001111101001010100101011111010000001110111110001011010111101100000001001110101110011111000101101100011010...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

wrong answer 262nd lines differ - expected: '274', found: '0'

Subtask #5:

score: 0
Skipped

Dependency #1:

0%