Submission #74329

# Submission time Handle Problem Language Result Execution time Memory
74329 2018-08-31T10:12:09 Z Mamnoon_Siam Xylophone (JOI18_xylophone) C++17
100 / 100
98 ms 716 KB
#include "xylophone.h"
#include <bits/stdc++.h>
using namespace std;

void solve(int N) {
	if(N == 2) {
		answer(1, 1);
		answer(2, 2);
		return;
	}
	vector<int> a(N), two(N), three(N);
	for(int i = 0; i < N - 1; i++) {
		two[i] = query(i + 1, i + 1 + 1);
		if(i < N - 2) three[i] = query(i + 1, i + 2 + 1);
	}
	a[1] = two[0];
	int tog = 1;
	for(int i = 2; i < N; i++) {
		if(three[i - 2] == two[i - 2] + two[i - 1]) {
			a[i] = tog ? a[i - 1] + two[i - 1] : a[i - 1] - two[i - 1];
		} else {
			a[i] = tog ? a[i - 1] - two[i - 1] : a[i - 1] + two[i - 1];
			tog ^= 1;
		}
	}
	int mxid, mnid, mx = -1e5, mn = 1e5;
	for(int i = 0; i < N; i++) {
		if(a[i] < mn) mn = a[i], mnid = i;
		if(a[i] > mx) mx = a[i], mxid = i;
	}
	if(mxid < mnid) {
		for(int &b : a) b = -b;
		swap(mn, mx);
		mx = -mx, mn = -mn;
	}
	for(int i = 0; i < N; i++) a[i] -= mn;
	for(int i = 0; i < N; i++) answer(i + 1, a[i] + 1);
}

Compilation message

xylophone.cpp: In function 'void solve(int)':
xylophone.cpp:31:2: warning: 'mxid' may be used uninitialized in this function [-Wmaybe-uninitialized]
  if(mxid < mnid) {
  ^~
xylophone.cpp:31:2: warning: 'mnid' may be used uninitialized in this function [-Wmaybe-uninitialized]
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 456 KB Output is correct
3 Correct 2 ms 456 KB Output is correct
4 Correct 3 ms 456 KB Output is correct
5 Correct 2 ms 456 KB Output is correct
6 Correct 3 ms 456 KB Output is correct
7 Correct 2 ms 456 KB Output is correct
8 Correct 3 ms 456 KB Output is correct
9 Correct 3 ms 496 KB Output is correct
10 Correct 3 ms 520 KB Output is correct
11 Correct 3 ms 520 KB Output is correct
12 Correct 3 ms 520 KB Output is correct
13 Correct 4 ms 520 KB Output is correct
14 Correct 3 ms 520 KB Output is correct
15 Correct 3 ms 520 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 456 KB Output is correct
3 Correct 2 ms 456 KB Output is correct
4 Correct 3 ms 456 KB Output is correct
5 Correct 2 ms 456 KB Output is correct
6 Correct 3 ms 456 KB Output is correct
7 Correct 2 ms 456 KB Output is correct
8 Correct 3 ms 456 KB Output is correct
9 Correct 3 ms 496 KB Output is correct
10 Correct 3 ms 520 KB Output is correct
11 Correct 3 ms 520 KB Output is correct
12 Correct 3 ms 520 KB Output is correct
13 Correct 4 ms 520 KB Output is correct
14 Correct 3 ms 520 KB Output is correct
15 Correct 3 ms 520 KB Output is correct
16 Correct 5 ms 520 KB Output is correct
17 Correct 9 ms 532 KB Output is correct
18 Correct 14 ms 532 KB Output is correct
19 Correct 18 ms 572 KB Output is correct
20 Correct 16 ms 588 KB Output is correct
21 Correct 11 ms 592 KB Output is correct
22 Correct 18 ms 592 KB Output is correct
23 Correct 17 ms 592 KB Output is correct
24 Correct 17 ms 592 KB Output is correct
25 Correct 19 ms 592 KB Output is correct
26 Correct 17 ms 592 KB Output is correct
27 Correct 20 ms 592 KB Output is correct
28 Correct 17 ms 592 KB Output is correct
29 Correct 17 ms 592 KB Output is correct
30 Correct 14 ms 592 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 456 KB Output is correct
3 Correct 2 ms 456 KB Output is correct
4 Correct 3 ms 456 KB Output is correct
5 Correct 2 ms 456 KB Output is correct
6 Correct 3 ms 456 KB Output is correct
7 Correct 2 ms 456 KB Output is correct
8 Correct 3 ms 456 KB Output is correct
9 Correct 3 ms 496 KB Output is correct
10 Correct 3 ms 520 KB Output is correct
11 Correct 3 ms 520 KB Output is correct
12 Correct 3 ms 520 KB Output is correct
13 Correct 4 ms 520 KB Output is correct
14 Correct 3 ms 520 KB Output is correct
15 Correct 3 ms 520 KB Output is correct
16 Correct 5 ms 520 KB Output is correct
17 Correct 9 ms 532 KB Output is correct
18 Correct 14 ms 532 KB Output is correct
19 Correct 18 ms 572 KB Output is correct
20 Correct 16 ms 588 KB Output is correct
21 Correct 11 ms 592 KB Output is correct
22 Correct 18 ms 592 KB Output is correct
23 Correct 17 ms 592 KB Output is correct
24 Correct 17 ms 592 KB Output is correct
25 Correct 19 ms 592 KB Output is correct
26 Correct 17 ms 592 KB Output is correct
27 Correct 20 ms 592 KB Output is correct
28 Correct 17 ms 592 KB Output is correct
29 Correct 17 ms 592 KB Output is correct
30 Correct 14 ms 592 KB Output is correct
31 Correct 32 ms 592 KB Output is correct
32 Correct 49 ms 592 KB Output is correct
33 Correct 77 ms 632 KB Output is correct
34 Correct 92 ms 632 KB Output is correct
35 Correct 40 ms 644 KB Output is correct
36 Correct 79 ms 644 KB Output is correct
37 Correct 67 ms 644 KB Output is correct
38 Correct 80 ms 644 KB Output is correct
39 Correct 83 ms 644 KB Output is correct
40 Correct 78 ms 644 KB Output is correct
41 Correct 85 ms 644 KB Output is correct
42 Correct 46 ms 644 KB Output is correct
43 Correct 84 ms 644 KB Output is correct
44 Correct 88 ms 644 KB Output is correct
45 Correct 87 ms 644 KB Output is correct
46 Correct 83 ms 716 KB Output is correct
47 Correct 48 ms 716 KB Output is correct
48 Correct 82 ms 716 KB Output is correct
49 Correct 81 ms 716 KB Output is correct
50 Correct 82 ms 716 KB Output is correct
51 Correct 83 ms 716 KB Output is correct
52 Correct 98 ms 716 KB Output is correct
53 Correct 45 ms 716 KB Output is correct
54 Correct 78 ms 716 KB Output is correct
55 Correct 85 ms 716 KB Output is correct
56 Correct 96 ms 716 KB Output is correct
57 Correct 82 ms 716 KB Output is correct
58 Correct 79 ms 716 KB Output is correct
59 Correct 39 ms 716 KB Output is correct
60 Correct 64 ms 716 KB Output is correct