답안 #207905

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
207905 2020-03-09T11:45:37 Z Segtree 가로등 (APIO19_street_lamps) C++14
20 / 100
1156 ms 15768 KB
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<set>
#include<unordered_set>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define chmin(a,b) a=min(a,b)
#define chmax(a,b) a=max(a,b)
#define all(x) x.begin(),x.end()
#define N 300010
ll n,q;
ll tim[N],pnt[N],flag[N];
int main(){
	cin>>n>>q;
	string s;
	cin>>s;
	rep(i,n){
		tim[i]=0,pnt[i]=0,flag[i]=(s[i]=='1');
	}
	for(int i=1;i<=q;i++){
		string typ;
		cin>>typ;
		if(typ=="toggle"){
			ll x; cin>>x;
			x--;
			pnt[x]+=flag[x]*(i-tim[x]);
			tim[x]=i;
			flag[x]^=1;
		}
		else{
			ll x,b; cin>>x>>b;
			x--;
			pnt[x]+=flag[x]*(i-tim[x]);
			tim[x]=i;
			cout<<pnt[x]<<endl;
		}
	}
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 6 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 561 ms 1272 KB Output is correct
2 Correct 596 ms 4856 KB Output is correct
3 Correct 602 ms 5496 KB Output is correct
4 Correct 720 ms 13744 KB Output is correct
5 Correct 796 ms 14144 KB Output is correct
6 Correct 663 ms 13460 KB Output is correct
7 Correct 1156 ms 14324 KB Output is correct
8 Correct 1115 ms 15768 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 6 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 8 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 6 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -