#include <bits/stdc++.h>
#define chmax(x, v) x = max(x, v)
#define pii pair<int, int>
#define pb push_back
#define all(x) x.begin(), x.end()
#define chmin(x, v) x = min(x, v)
#define sz(x) (int)x.size()
#define int long long
using namespace std;
signed main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
int nVals, nReqs; cin >> nVals >> nReqs;
vector<int> vals(nVals);
string chaine; cin >> chaine;
for (int iVal = 0; iVal < nVals; ++iVal)
vals[iVal] = (chaine[iVal] - '0');
vector<vector<int>> etats;
etats.pb(vals);
for (int iReq = 0; iReq < nReqs; ++iReq){
string typeReq; cin >> typeReq;
if (typeReq == "toggle"){
int ind; cin >> ind;
vals[ind - 1] ^= 1;
}
else {
int sum = 0, a, b; cin >> a >> b;
--a; --b;
for (int inst = 0; inst <= iReq; ++inst){
bool ok = true;
for (int ind = a; ind < b; ++ind)
ok &= (etats[inst][ind] == 1);
sum += ok;
}
cout << sum << endl;
}
etats.pb(vals);
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
1 ms |
332 KB |
Output is correct |
6 |
Correct |
1 ms |
336 KB |
Output is correct |
7 |
Correct |
2 ms |
332 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
5054 ms |
30964 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
8140 KB |
Output is correct |
2 |
Correct |
64 ms |
8096 KB |
Output is correct |
3 |
Correct |
129 ms |
8192 KB |
Output is correct |
4 |
Correct |
164 ms |
8096 KB |
Output is correct |
5 |
Runtime error |
282 ms |
524292 KB |
Execution killed with signal 9 |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
212 ms |
8132 KB |
Output is correct |
2 |
Correct |
205 ms |
8120 KB |
Output is correct |
3 |
Correct |
101 ms |
8204 KB |
Output is correct |
4 |
Correct |
15 ms |
8140 KB |
Output is correct |
5 |
Runtime error |
261 ms |
524292 KB |
Execution killed with signal 9 |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
1 ms |
332 KB |
Output is correct |
6 |
Correct |
1 ms |
336 KB |
Output is correct |
7 |
Correct |
2 ms |
332 KB |
Output is correct |
8 |
Execution timed out |
5054 ms |
30964 KB |
Time limit exceeded |
9 |
Halted |
0 ms |
0 KB |
- |