QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#267523#186. Street LampsFriskLSZ0 115ms18356kbC++143.0kb2023-11-27 13:48:002023-11-27 13:48:02

Judging History

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

  • [2023-11-27 13:48:02]
  • 评测
  • 测评结果:0
  • 用时:115ms
  • 内存:18356kb
  • [2023-11-27 13:48:00]
  • 提交

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 6000005
#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

#define LOCAL

namespace qwq{
    namespace IO{
    	
        #ifndef LOCAL
            #define SIZE (1<<20)
            char in[SIZE],out[SIZE],*p1=in,*p2=in,*p3=out;
            #define getchar() (p1==p2&&(p2=(p1=in)+fread(in,1,SIZE,stdin),p1==p2)?EOF:*p1++)
            #define flush() (fwrite(p3=out,1,SIZE,stdout))
            #define putchar(ch) (p3==out+SIZE&&flush(),*p3++=(ch))
            class Flush{public:~Flush(){flush();}}_;
        #endif
        
        template<typename type>
        inline void read(type &x){
            x=0;bool flag(0);char ch=getchar();
            while(!isdigit(ch)) flag^=ch=='-',ch=getchar();
            while(isdigit(ch)) x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
            flag?x=-x:0;
        }
        
        template<typename type>
        inline void write(type x,bool flag=1){
            x<0?x=-x,putchar('-'):0;static short Stack[50],top(0);
            do Stack[++top]=x%10,x/=10;while(x);
            while(top) putchar(Stack[top--]|48);
            flag?putchar('\n'):putchar(' ');
        }
        
        #ifndef LOCAL
            #undef SIZE
            #undef getchar
            #undef putchar
            #undef flush
        #endif
    }
} using namespace qwq::IO;

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;
	}
	
	bool 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(){
	read(n); read(q);
	scanf("%s",c+1);
	for(int i=1;i<=n;++i) s[i]=(c[i]=='1');
	rt[0]=t.build(1,n);
	char op[7];
	for(int p=1;p<=q;++p){
		scanf("%s",op);
		if(op[0]=='t'){
			int i;
			read(i);
			rt[p]=t.update(rt[p-1],i,1,n);
		} else {
			int l,r;
			read(l); read(r);
			int L=0,R=p-1,res=p;
			while(L<=R){
				int mid=(L+R)>>1;
				if(t.query(rt[mid],l,r,1,n)) res=mid,R=mid-1;
				else L=mid+1;
			}
			printf("%d\n",p-res);
			rt[p]=rt[p-1];
		}
	}
	return 0;
} // sub3

详细

Subtask #1:

score: 0
Wrong Answer

Test #1:

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

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: 0ms
memory: 7704kb

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
3
0
4
6
0
9
9
0
15
24
19
23
0
0
10
2
0
0
0
0
0
0
0

result:

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

Subtask #2:

score: 0
Wrong Answer

Test #9:

score: 0
Wrong Answer
time: 115ms
memory: 18356kb

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
40
0
70
73
0
0
0
0
6
46
84
0
0
0
0
97
0
70
0
0
26
0
0
0
0
59
0
0
0
0
0
0
0
0
0
112
0
142
0
61
0
121
0
35
0
0
73
0
45
0
118
0
0
0
63
0
0
26
75
0
0
0
0
197
0
0
200
0
0
206
208
0
208
103
153
0
155
119
158
0
0
72
0
0
7
230
0
2...

result:

wrong answer 4th lines differ - expected: '6', found: '0'

Subtask #3:

score: 0
Runtime Error

Test #17:

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

input:

1000 1003
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

output:

0
0
0

result:

ok 3 lines

Test #18:

score: 0
Accepted
time: 2ms
memory: 9728kb

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: 2ms
memory: 7928kb

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: 2ms
memory: 9768kb

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
Runtime Error

input:

300000 300000
0000000000000000000000000000000000000000000000000100000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000...

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:


Subtask #4:

score: 0
Wrong Answer

Test #30:

score: 0
Wrong Answer
time: 0ms
memory: 7884kb

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%