//debug icin gdb kullanmayi dene
#include<bits/stdc++.h>
using namespace std;
#define mods 1000000007
#define pb push_back
#define mp make_pair
#define st first
#define nd second
#define rs resize
#define pii pair<lint,lint>
#define piii pair<lint,pair<lint,lint> >
#define inf LLONG_MAX-7
#define vvL vector<vector<lint> >
#define vvB vector<vector<bool> >
#define vvvL vector<vector<vector<lint> > >
#define vL vector<lint>
#define vpii vector<pii>
#define vB vector<bool>
typedef long long int lint;
typedef unsigned long long int ulint;
lint fastpow(lint tab,lint us){
if(tab==0) return 0;
if(tab==1) return 1;
if(us==0) return 1;
if(us==1) return tab%mods;
tab%=mods;
if(us%2==1) return tab*fastpow(tab,us-1)%mods;
lint a=fastpow(tab,us/2)%mods;
return a*a%mods;
}
lint t=1,n,q;
string s;
vL cez,mev;
void solve(){
lint i,j,a,b,k;
cin>>n>>q;
cin>>s;
cez.rs(n+5,0);
mev.rs(n+5,-1);
string str;
for(i=1;i<=n;i++) if(s[i-1]=='0') mev[i]=0;
for(j=1;j<=q;j++){
cin>>str;
if(str=="query"){
cin>>a>>b;
if(mev[a]==-1) cout<<j-cez[a]<<endl;
else cout<<mev[a]-cez[a]<<endl;
}else{
cin>>a;
if(mev[a]!=-1){
cez[a]+=j-mev[a];
mev[a]=-1;
}else{
mev[a]=j;
}
}
}
return;
}
int main(){
// freopen("in.txt","r",stdin);freopen("out.txt","w",stdout);
ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
// cin>>t;
while(t--) solve();
return 0;
}
Compilation message
street_lamps.cpp: In function 'void solve()':
street_lamps.cpp:35:15: warning: unused variable 'k' [-Wunused-variable]
35 | lint i,j,a,b,k;
| ^
# |
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 |
314 ms |
4356 KB |
Output is correct |
2 |
Correct |
315 ms |
4660 KB |
Output is correct |
3 |
Correct |
322 ms |
5320 KB |
Output is correct |
4 |
Correct |
355 ms |
11236 KB |
Output is correct |
5 |
Correct |
414 ms |
11756 KB |
Output is correct |
6 |
Correct |
289 ms |
10968 KB |
Output is correct |
7 |
Correct |
607 ms |
12020 KB |
Output is correct |
8 |
Correct |
639 ms |
13340 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 |
- |