답안 #1044942

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1044942 2024-08-05T14:54:26 Z vjudge1 가로등 (APIO19_street_lamps) C++17
20 / 100
58 ms 7392 KB
#include <bits/stdc++.h>
#define fast cin.tie(0)->sync_with_stdio(0);
#define int long long
#define inf ((int)1e18)
using namespace std;

int32_t main(){
	fast
	int n, q;
	cin >> n >> q;
	string s;
	cin >> s;
	vector <int> till(n, -1), ans(n); // till[ind] = 0 means closed
	for(int i = 0; i < n; i++) {
		if(s[i] == '1') till[i] = 0;
	}
	for(int i = 1; i <= q; i++) {
		string type;
		cin >> type;
		if(type == "toggle") {
			int ind;
			cin >> ind;
			ind--;
			if(~till[ind]) {
				ans[ind] += i - till[ind];
				till[ind] = -1;
			}
			else {
				till[ind] = i;
			}
		}
		else {
			int a, b;
			cin >> a >> b;
			a--, b-=2;
			int tmp = (~till[a]) ? i - till[a] : 0;
			cout << tmp + ans[a] << "\n";
		}
	}
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 33 ms 1136 KB Output is correct
2 Correct 36 ms 1364 KB Output is correct
3 Correct 39 ms 1360 KB Output is correct
4 Correct 50 ms 6264 KB Output is correct
5 Correct 48 ms 6544 KB Output is correct
6 Correct 42 ms 6120 KB Output is correct
7 Correct 53 ms 6008 KB Output is correct
8 Correct 58 ms 7392 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -