이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
//#pragma GCC optimize("Ofast,unroll-loops,O3")
//#pragma GCC optimize("avx,avx2,sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,fma,tune=native")
#include<bits/stdc++.h>
//#include<bits/extc++.h>
//#pragma pack(1)
#define fast ios::sync_with_stdio(0); cin.tie(0);
#define int long long
#define pii pair<int,int>
#define x first
#define y second
#define N 300015
using namespace std;
//using namespace __gnu_pbds;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//typedef tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update> order_multiset;
//typedef tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> order_set;
vector<int>all[N];
int n,q,ans[N];
bool arr[N];
signed main(){
fast
cin>>n>>q;
for (int i=1;i<=n;i++){
char c; cin>>c;
arr[i]=c-'0';
if (arr[i]==1)
all[i].emplace_back(0);
else {
all[i].emplace_back(0);
all[i].emplace_back(0);
}
}
for (int t=1;t<=q;t++){
string str; cin>>str;
if (str=="toggle"){
int i; cin>>i;
if (arr[i]==0)
all[i].emplace_back(t);
else {
ans[i]+=(t-all[i].back());
all[i].emplace_back(t);
}
arr[i]^=1;
}
else {
int l,r; cin>>l>>r;
if (arr[l]==0) cout<<ans[l]<<'\n';
else cout<<ans[l]+t-all[l].back()<<'\n';
}
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |