//#define NDEBUG
#include <bits/stdc++.h>
#include <bits/extc++.h>
#define StarBurstStream ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define iter(a) a.begin(), a.end()
#define riter(a) a.rbegin(), a.rend()
#define lsort(a) sort(iter(a))
#define gsort(a) sort(riter(a))
#define pb(a) push_back(a)
#define eb(a) emplace_back(a)
#define pf(a) push_front(a)
#define pob pop_back()
#define pof pop_front()
#define mp(a, b) make_pair(a, b)
#define F first
#define S second
#define mt make_tuple
#define gt(t, i) get<i>(t)
#define iceil(a, b) ((a + b - 1) / b)
#define tomax(a, b) (a = max(a, b))
#define printv(a, b) {bool pvaspace=false; \
for(auto pva : a){ \
if(pvaspace) b << " "; pvaspace=true;\
b << pva;\
}\
b << "\n";}
//#define TEST
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pdd = pair<ld, ld>;
using tiii = tuple<int, int, int>;
const ll MOD = 1000000007;
const ll MAX = 2147483647;
template<typename A, typename B>
ostream& operator<<(ostream& o, pair<A, B> p){
return o << '(' << p.F << ',' << p.S << ')';
}
int main(){
StarBurstStream
int n, q;
cin >> n >> q;
string s;
cin >> s;
vector<vector<pii>> e(n);
for(int i = 0; i < q; i++){
string t;
cin >> t;
if(t == "toggle"){
int x;
cin >> x;
x--;
e[x].eb(mp(i, 0));
}
else{
int a, b;
cin >> a >> b;
a--; b--;
e[a].eb(mp(i, 1));
}
}
vector<pii> ans;
for(int i = 0; i < n; i++){
bool now = s[i] == '1';
int lst = -1;
int t = 0;
for(auto k : e[i]){
if(k.S == 0){
if(now){
t += k.F - lst;
lst = -1;
now = false;
}
else{
lst = k.F;
now = true;
}
}
else{
if(now){
t += k.F - lst;
lst = k.F;
}
ans.eb(mp(k.F, t));
}
}
}
lsort(ans);
for(auto i : ans){
cout << i.S << "\n";
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
92 ms |
8176 KB |
Output is correct |
2 |
Correct |
103 ms |
9292 KB |
Output is correct |
3 |
Correct |
121 ms |
10600 KB |
Output is correct |
4 |
Correct |
206 ms |
21508 KB |
Output is correct |
5 |
Correct |
200 ms |
22304 KB |
Output is correct |
6 |
Correct |
192 ms |
20996 KB |
Output is correct |
7 |
Correct |
240 ms |
24448 KB |
Output is correct |
8 |
Correct |
232 ms |
24696 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |