#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), tot(nVals), depart(nVals);
string chaine; cin >> chaine;
for (int iVal = 0; iVal < nVals; ++iVal)
vals[iVal] = (chaine[iVal] - '0');
for (int iReq = 1; iReq <= nReqs; ++iReq){
string typeReq; cin >> typeReq;
if (typeReq == "toggle"){
int ind; cin >> ind;
ind--;
if (vals[ind] == 1)
tot[ind] += iReq - depart[ind];
else
depart[ind] = iReq;
vals[ind] ^= 1;
}
else {
int a, b; cin >> a >> b;
--a; --b;
int sum = tot[a];
if (vals[a] == 1)
sum += iReq - depart[a];
cout << sum << endl;
}
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
318 ms |
1228 KB |
Output is correct |
2 |
Correct |
338 ms |
1172 KB |
Output is correct |
3 |
Correct |
326 ms |
1348 KB |
Output is correct |
4 |
Correct |
389 ms |
8484 KB |
Output is correct |
5 |
Correct |
481 ms |
8824 KB |
Output is correct |
6 |
Correct |
349 ms |
8404 KB |
Output is correct |
7 |
Correct |
658 ms |
8404 KB |
Output is correct |
8 |
Correct |
688 ms |
9796 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
332 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
332 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |