Submission #266656

# Submission time Handle Problem Language Result Execution time Memory
266656 2020-08-15T12:02:26 Z define Street Lamps (APIO19_street_lamps) C++17
20 / 100
1216 ms 11412 KB
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define len(s) (int)s.size()
 
template<class T> inline bool chmin(T &a, T b){
	if(a>b){a=b;return true;}
	return false;
}
template<class T> inline bool chmax(T &a, T b){
	if(a<b){a=b;return true;}
	return false;
}
constexpr int mod = 1e9+7;
constexpr long long inf = 3e18;

int N,Q;
string S;
int ans[300005],now[300005];
signed main(){
	cin>>N>>Q>>S;
	rep(i,N)now[i]=-1;
	rep(i,Q){
		string s;cin>>s;
		if(s=="query"){
			int a,b;cin>>a>>b;a--;
			int res=ans[a];
			if(S[a]=='1')res+=i-now[a];
			cout<<res<<endl;
		}else {
			int a;cin>>a;a--;
			if(S[a]=='1'){
				ans[a]+=i-now[a];
				S[a]='0';
			}else {
				now[a]=i;
				S[a]='1';
			}
		}
	}
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 632 ms 4516 KB Output is correct
2 Correct 664 ms 4984 KB Output is correct
3 Correct 697 ms 5496 KB Output is correct
4 Correct 815 ms 11412 KB Output is correct
5 Correct 932 ms 9620 KB Output is correct
6 Correct 748 ms 11028 KB Output is correct
7 Correct 1198 ms 9748 KB Output is correct
8 Correct 1216 ms 11284 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -