답안 #154729

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
154729 2019-09-24T09:08:24 Z Pro_ktmr 가로등 (APIO19_street_lamps) C++14
20 / 100
1434 ms 28468 KB
#include"bits/stdc++.h"
using namespace std;
#define LL long long
#define MP make_pair

int N,Q;
string def;
int t[300000],a[300000],b[300000];
vector<int> toggle[300000];
int ans[300000] = {};
int idx[300000] = {};

int main(){
	cin >> N >> Q;
	cin >> def;
	for(int i=0; i<N; i++){
		if(def[i] == '1') toggle[i].push_back(0);
	}
	for(int i=0; i<Q; i++){
		string type;
		cin >> type;
		if(type == "toggle"){
			t[i] = 0;
			cin >> a[i];
			a[i]--;
			toggle[a[i]].push_back(i+1);
		}
		else{
			t[i] = 1;
			cin >> a[i] >> b[i];
			a[i]--; b[i]--;
			while(toggle[a[i]].size() > idx[a[i]] + 1){
				ans[a[i]] += toggle[a[i]][idx[a[i]]+1] - toggle[a[i]][idx[a[i]]];
				idx[a[i]] += 2;
			}
			int tmp = ans[a[i]];
			if(toggle[a[i]].size()%2 == 1){
				tmp += i+1 - toggle[a[i]].back();
			}
			cout << tmp << endl;
		}
	}
	
	return 0;
}

Compilation message

street_lamps.cpp: In function 'int main()':
street_lamps.cpp:32:30: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    while(toggle[a[i]].size() > idx[a[i]] + 1){
          ~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 9 ms 7420 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 730 ms 15684 KB Output is correct
2 Correct 770 ms 16312 KB Output is correct
3 Correct 808 ms 17148 KB Output is correct
4 Correct 970 ms 26016 KB Output is correct
5 Correct 1042 ms 26980 KB Output is correct
6 Correct 850 ms 25460 KB Output is correct
7 Correct 1362 ms 18024 KB Output is correct
8 Correct 1434 ms 28468 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 10 ms 7416 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 13 ms 7416 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 9 ms 7420 KB Output isn't correct
2 Halted 0 ms 0 KB -