#include<bits/stdc++.h>
using namespace std;
int List[105][105];
int main(){
int N,Q;
cin>>N>>Q;
for(int i=1;i<=N;i++){
char s;
cin>>s;
List[0][i]=s-'0';
}
int sp=-1;
for(int i=1;i<=Q;i++){
string s;
int a,b;
cin>>s;
for(int j=1;j<=N;j++){
List[i][j]=List[i-1][j];
}
if(sp!=-1) List[i-1][sp]=1-List[i-1][sp];
if(s=="query"){
sp = -1;
cin>>a>>b;
int answer = 0;
for(int j=1;j<=i;j++){
int flag = 1;
for(int k=a;k<b;k++){
if(!List[j][k]) flag = 0;
}
answer += flag;
}
cout << answer << "\n";
}
else{
cin>>a;
List[i][a]=1-List[i][a];
sp = a;
}
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
300 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
264 KB |
Output is correct |
7 |
Correct |
2 ms |
304 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
2 ms |
468 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
436 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
2 ms |
444 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
300 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
264 KB |
Output is correct |
7 |
Correct |
2 ms |
304 KB |
Output is correct |
8 |
Runtime error |
2 ms |
468 KB |
Execution killed with signal 11 |
9 |
Halted |
0 ms |
0 KB |
- |