답안 #85581

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
85581 2018-11-21T01:11:29 Z KCSC Xylophone (JOI18_xylophone) C++14
100 / 100
107 ms 1356 KB
#include <bits/stdc++.h>
using namespace std;

const int DIM = 5005;

int vec[DIM], dif[DIM], sol[DIM], arr[DIM];
/*
int query(int l, int r) {
	int mn = 1e9, mx = -1e9;
	for (int i = l; i <= r; ++i) {
		mn = min(mn, arr[i]); mx = max(mx, arr[i]); }
	return mx - mn; }
*/

int query(int l, int r);
void answer(int p, int v);

int _query(int l, int r) {
	static map<pair<int, int>, int> mmp;
	if (mmp.find(make_pair(l, r)) == mmp.end())
		mmp[make_pair(l, r)] = query(l, r);
	return mmp[make_pair(l, r)]; }
/*
void answer(int p, int v) {
	sol[p] = v; }
*/
void solve(int n) {
	vec[2] = query(1, 2);
	for (int i = 3, l = 1, s = 1; i <= n; ++i) {
		if (_query(l, i) != _query(l, i - 1) + _query(i - 1, i)) {
			s *= -1; l = i - 1; }
		vec[i] = s * _query(i - 1, i); }
	int mn = 0;
	for (int i = 2; i <= n; ++i) {
		vec[i] += vec[i - 1]; mn = min(mn, vec[i]); }
	int p1 = 0, pn = 0;
	for (int i = 1; i <= n; ++i) {
		vec[i] += 1 - mn;
		if (vec[i] == 1) { p1 = i; }
		if (vec[i] == n) { pn = i; } }
	if (p1 > pn) {
		for (int i = 1; i <= n; ++i) {
			vec[i] = n + 1 - vec[i]; } }
	for (int i = 1; i <= n; ++i) {
		answer(i, vec[i]); } }
/*
int main(void) {
#ifdef HOME
	freopen("xylophone.in", "r", stdin);
	freopen("xylophone.out", "w", stdout); 
#endif
	int n; cin >> n;
	for (int i = 1; i <= n; ++i) {
		cin >> arr[i]; cout << arr[i] << " "; }
	solve(n); cout << "\n";
	for (int i = 1; i <= n; ++i) {
		cout << sol[i] << " "; }
	return 0; }
*/
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 276 KB Output is correct
2 Correct 2 ms 496 KB Output is correct
3 Correct 2 ms 496 KB Output is correct
4 Correct 5 ms 496 KB Output is correct
5 Correct 3 ms 508 KB Output is correct
6 Correct 3 ms 540 KB Output is correct
7 Correct 3 ms 552 KB Output is correct
8 Correct 3 ms 564 KB Output is correct
9 Correct 4 ms 588 KB Output is correct
10 Correct 3 ms 588 KB Output is correct
11 Correct 3 ms 588 KB Output is correct
12 Correct 3 ms 588 KB Output is correct
13 Correct 3 ms 588 KB Output is correct
14 Correct 3 ms 588 KB Output is correct
15 Correct 4 ms 588 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 276 KB Output is correct
2 Correct 2 ms 496 KB Output is correct
3 Correct 2 ms 496 KB Output is correct
4 Correct 5 ms 496 KB Output is correct
5 Correct 3 ms 508 KB Output is correct
6 Correct 3 ms 540 KB Output is correct
7 Correct 3 ms 552 KB Output is correct
8 Correct 3 ms 564 KB Output is correct
9 Correct 4 ms 588 KB Output is correct
10 Correct 3 ms 588 KB Output is correct
11 Correct 3 ms 588 KB Output is correct
12 Correct 3 ms 588 KB Output is correct
13 Correct 3 ms 588 KB Output is correct
14 Correct 3 ms 588 KB Output is correct
15 Correct 4 ms 588 KB Output is correct
16 Correct 5 ms 588 KB Output is correct
17 Correct 9 ms 588 KB Output is correct
18 Correct 16 ms 588 KB Output is correct
19 Correct 22 ms 684 KB Output is correct
20 Correct 13 ms 704 KB Output is correct
21 Correct 20 ms 704 KB Output is correct
22 Correct 12 ms 708 KB Output is correct
23 Correct 18 ms 708 KB Output is correct
24 Correct 21 ms 708 KB Output is correct
25 Correct 20 ms 708 KB Output is correct
26 Correct 20 ms 708 KB Output is correct
27 Correct 13 ms 708 KB Output is correct
28 Correct 11 ms 708 KB Output is correct
29 Correct 23 ms 708 KB Output is correct
30 Correct 18 ms 708 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 276 KB Output is correct
2 Correct 2 ms 496 KB Output is correct
3 Correct 2 ms 496 KB Output is correct
4 Correct 5 ms 496 KB Output is correct
5 Correct 3 ms 508 KB Output is correct
6 Correct 3 ms 540 KB Output is correct
7 Correct 3 ms 552 KB Output is correct
8 Correct 3 ms 564 KB Output is correct
9 Correct 4 ms 588 KB Output is correct
10 Correct 3 ms 588 KB Output is correct
11 Correct 3 ms 588 KB Output is correct
12 Correct 3 ms 588 KB Output is correct
13 Correct 3 ms 588 KB Output is correct
14 Correct 3 ms 588 KB Output is correct
15 Correct 4 ms 588 KB Output is correct
16 Correct 5 ms 588 KB Output is correct
17 Correct 9 ms 588 KB Output is correct
18 Correct 16 ms 588 KB Output is correct
19 Correct 22 ms 684 KB Output is correct
20 Correct 13 ms 704 KB Output is correct
21 Correct 20 ms 704 KB Output is correct
22 Correct 12 ms 708 KB Output is correct
23 Correct 18 ms 708 KB Output is correct
24 Correct 21 ms 708 KB Output is correct
25 Correct 20 ms 708 KB Output is correct
26 Correct 20 ms 708 KB Output is correct
27 Correct 13 ms 708 KB Output is correct
28 Correct 11 ms 708 KB Output is correct
29 Correct 23 ms 708 KB Output is correct
30 Correct 18 ms 708 KB Output is correct
31 Correct 41 ms 756 KB Output is correct
32 Correct 55 ms 968 KB Output is correct
33 Correct 75 ms 1100 KB Output is correct
34 Correct 91 ms 1180 KB Output is correct
35 Correct 83 ms 1228 KB Output is correct
36 Correct 92 ms 1228 KB Output is correct
37 Correct 92 ms 1300 KB Output is correct
38 Correct 84 ms 1300 KB Output is correct
39 Correct 87 ms 1300 KB Output is correct
40 Correct 80 ms 1300 KB Output is correct
41 Correct 95 ms 1300 KB Output is correct
42 Correct 66 ms 1300 KB Output is correct
43 Correct 107 ms 1300 KB Output is correct
44 Correct 77 ms 1340 KB Output is correct
45 Correct 74 ms 1340 KB Output is correct
46 Correct 77 ms 1340 KB Output is correct
47 Correct 79 ms 1340 KB Output is correct
48 Correct 98 ms 1340 KB Output is correct
49 Correct 88 ms 1356 KB Output is correct
50 Correct 87 ms 1356 KB Output is correct
51 Correct 90 ms 1356 KB Output is correct
52 Correct 87 ms 1356 KB Output is correct
53 Correct 87 ms 1356 KB Output is correct
54 Correct 78 ms 1356 KB Output is correct
55 Correct 61 ms 1356 KB Output is correct
56 Correct 77 ms 1356 KB Output is correct
57 Correct 75 ms 1356 KB Output is correct
58 Correct 81 ms 1356 KB Output is correct
59 Correct 81 ms 1356 KB Output is correct
60 Correct 69 ms 1356 KB Output is correct