답안 #265144

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
265144 2020-08-14T13:27:20 Z hanagasumi 가로등 (APIO19_street_lamps) C++17
20 / 100
235 ms 30328 KB
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <deque>
#include <map>
#include <set>
#include <complex>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <random>

#define ft first
#define sc second
#define pb push_back
#define len(v) (int)v.size()
#define int ll
#define all(v) v.begin(), v.end()

using namespace std;
typedef long long ll;
typedef long double ld;

signed main() {
	#ifdef PC
		freopen("in.txt", "r", stdin);
		freopen("out.txt", "w", stdout);
	#endif
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	int n, q;
	cin >> n >> q;
	vector<vector<pair<int, int>>> have(n);
	vector<int> ans(n, 0);
	for (int i = 0; i < n; i++) {
		char c;
		cin >> c;
		if(c == '1') 
			have[i].pb({0, 1});
		else
			have[i].pb({0, 0});
	}
	for (int i = 0; i < q; i++) {
		string s;
		cin >> s;
		if(s == "toggle") {
			int id;
			cin >> id;
			id--;
			have[id].pb({i + 1, 1 - have[id].back().sc});
			continue;
		}
		int l, r, anss = 0;
		cin >> l >> r;
		l--, r--;
		for (int j = 0; j < len(have[l]) - 1; j++) {
			if(have[l][j].sc != 1) 
				continue;
			ans[l] += (have[l][j + 1].ft - have[l][j].ft);
		}
		have[l] = {have[l].back()};
		anss = ans[l];
		if(have[l].back().sc == 1) 
			anss += (i + 1) - have[l].back().ft;
		cout << anss << '\n';
	}
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 83 ms 3832 KB Output is correct
2 Correct 96 ms 5168 KB Output is correct
3 Correct 98 ms 6264 KB Output is correct
4 Correct 235 ms 29688 KB Output is correct
5 Correct 225 ms 29304 KB Output is correct
6 Correct 216 ms 30328 KB Output is correct
7 Correct 221 ms 25720 KB Output is correct
8 Correct 220 ms 27084 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -