#include <bits/stdc++.h>
using namespace std;
const int nmax = 100;
int n,q;
int s[nmax + 5][nmax + 5];
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cin>>n>>q;
for(int i=1;i<=n;i++)
{
char ch;
cin>>ch;
s[1][i] = ch - '0';
}
for(int i=1;i<=q;i++)
{
string tip;
cin>>tip;
for(int j=1;j<=n;j++)
{
s[i + 1][j] = s[i][j];
}
if(tip == "query")
{
int a,b;
cin>>a>>b;
--b;
int rez = 0;
for(int t=1;t<=i;t++)
{
bool ok = true;
for(int j=a;j<=b;j++)
{
if(s[t][j] != 1)
{
ok = false;
}
}
rez += ok;
}
cout<<rez<<'\n';
}
else
{
int poz;
cin>>poz;
if(s[i + 1][poz] == 0)
{
s[i + 1][poz] = 1;
}
else
{
s[i + 1][poz] = 0;
}
}
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
460 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
604 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
600 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
2 ms |
604 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
460 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Runtime error |
1 ms |
604 KB |
Execution killed with signal 11 |
9 |
Halted |
0 ms |
0 KB |
- |