Submission #201486

# Submission time Handle Problem Language Result Execution time Memory
201486 2020-02-10T17:39:02 Z wilwxk Xylophone (JOI18_xylophone) C++14
100 / 100
101 ms 516 KB
#include "xylophone.h"
#include <bits/stdc++.h>
using namespace std;

const int MAXN = 5e3+5;
int ans[MAXN];
int mem[MAXN];
int mn;

void solve(int n) {
	ans[0] = 0;
	int op = 1;
	for(int i = 2; i <= n; i++) {
		mem[i] = query(i-1, i);
		if(i == 2) {
			ans[i] = mem[i];
			continue;
		}
		int x = query(i-2, i);
		if(mem[i-1] >= max(mem[i], x) || mem[i] >= max(mem[i-1], x)) op *= -1;
		ans[i] = ans[i-1]+op*mem[i];
		mn = min(ans[i], mn); 
	}

	for(int i = 1; i <= n; i++) ans[i] -= (mn-1);

	bool ok = 1; int mni, mxi;
	for(int i = 1; i <= n; i++) {
		if(ans[i] == 1) mni = i;
		if(ans[i] == n) mxi = i;
	}
	if(mni > mxi) ok = 0;
	if(!ok) {
		for(int i = 1; i <= n; i++) ans[i] = n-ans[i]+1;
	}

	for(int i = 1; i <= n; i++) answer(i, ans[i]);
}

Compilation message

xylophone.cpp: In function 'void solve(int)':
xylophone.cpp:32:2: warning: 'mxi' may be used uninitialized in this function [-Wmaybe-uninitialized]
  if(mni > mxi) ok = 0;
  ^~
xylophone.cpp:32:2: warning: 'mni' may be used uninitialized in this function [-Wmaybe-uninitialized]
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 6 ms 376 KB Output is correct
4 Correct 7 ms 376 KB Output is correct
5 Correct 6 ms 376 KB Output is correct
6 Correct 7 ms 248 KB Output is correct
7 Correct 7 ms 376 KB Output is correct
8 Correct 7 ms 376 KB Output is correct
9 Correct 7 ms 248 KB Output is correct
10 Correct 7 ms 376 KB Output is correct
11 Correct 7 ms 248 KB Output is correct
12 Correct 6 ms 248 KB Output is correct
13 Correct 7 ms 252 KB Output is correct
14 Correct 7 ms 376 KB Output is correct
15 Correct 7 ms 248 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 6 ms 376 KB Output is correct
4 Correct 7 ms 376 KB Output is correct
5 Correct 6 ms 376 KB Output is correct
6 Correct 7 ms 248 KB Output is correct
7 Correct 7 ms 376 KB Output is correct
8 Correct 7 ms 376 KB Output is correct
9 Correct 7 ms 248 KB Output is correct
10 Correct 7 ms 376 KB Output is correct
11 Correct 7 ms 248 KB Output is correct
12 Correct 6 ms 248 KB Output is correct
13 Correct 7 ms 252 KB Output is correct
14 Correct 7 ms 376 KB Output is correct
15 Correct 7 ms 248 KB Output is correct
16 Correct 8 ms 248 KB Output is correct
17 Correct 11 ms 248 KB Output is correct
18 Correct 21 ms 248 KB Output is correct
19 Correct 28 ms 376 KB Output is correct
20 Correct 24 ms 424 KB Output is correct
21 Correct 27 ms 376 KB Output is correct
22 Correct 22 ms 328 KB Output is correct
23 Correct 17 ms 376 KB Output is correct
24 Correct 23 ms 324 KB Output is correct
25 Correct 18 ms 376 KB Output is correct
26 Correct 22 ms 248 KB Output is correct
27 Correct 24 ms 248 KB Output is correct
28 Correct 26 ms 376 KB Output is correct
29 Correct 27 ms 376 KB Output is correct
30 Correct 19 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 6 ms 376 KB Output is correct
4 Correct 7 ms 376 KB Output is correct
5 Correct 6 ms 376 KB Output is correct
6 Correct 7 ms 248 KB Output is correct
7 Correct 7 ms 376 KB Output is correct
8 Correct 7 ms 376 KB Output is correct
9 Correct 7 ms 248 KB Output is correct
10 Correct 7 ms 376 KB Output is correct
11 Correct 7 ms 248 KB Output is correct
12 Correct 6 ms 248 KB Output is correct
13 Correct 7 ms 252 KB Output is correct
14 Correct 7 ms 376 KB Output is correct
15 Correct 7 ms 248 KB Output is correct
16 Correct 8 ms 248 KB Output is correct
17 Correct 11 ms 248 KB Output is correct
18 Correct 21 ms 248 KB Output is correct
19 Correct 28 ms 376 KB Output is correct
20 Correct 24 ms 424 KB Output is correct
21 Correct 27 ms 376 KB Output is correct
22 Correct 22 ms 328 KB Output is correct
23 Correct 17 ms 376 KB Output is correct
24 Correct 23 ms 324 KB Output is correct
25 Correct 18 ms 376 KB Output is correct
26 Correct 22 ms 248 KB Output is correct
27 Correct 24 ms 248 KB Output is correct
28 Correct 26 ms 376 KB Output is correct
29 Correct 27 ms 376 KB Output is correct
30 Correct 19 ms 332 KB Output is correct
31 Correct 51 ms 376 KB Output is correct
32 Correct 60 ms 248 KB Output is correct
33 Correct 84 ms 460 KB Output is correct
34 Correct 89 ms 376 KB Output is correct
35 Correct 82 ms 400 KB Output is correct
36 Correct 96 ms 376 KB Output is correct
37 Correct 100 ms 376 KB Output is correct
38 Correct 96 ms 376 KB Output is correct
39 Correct 93 ms 376 KB Output is correct
40 Correct 89 ms 392 KB Output is correct
41 Correct 93 ms 376 KB Output is correct
42 Correct 93 ms 384 KB Output is correct
43 Correct 89 ms 504 KB Output is correct
44 Correct 96 ms 336 KB Output is correct
45 Correct 87 ms 376 KB Output is correct
46 Correct 95 ms 376 KB Output is correct
47 Correct 98 ms 428 KB Output is correct
48 Correct 91 ms 380 KB Output is correct
49 Correct 94 ms 376 KB Output is correct
50 Correct 92 ms 376 KB Output is correct
51 Correct 101 ms 376 KB Output is correct
52 Correct 89 ms 380 KB Output is correct
53 Correct 96 ms 376 KB Output is correct
54 Correct 90 ms 376 KB Output is correct
55 Correct 92 ms 376 KB Output is correct
56 Correct 90 ms 516 KB Output is correct
57 Correct 90 ms 376 KB Output is correct
58 Correct 82 ms 428 KB Output is correct
59 Correct 87 ms 376 KB Output is correct
60 Correct 95 ms 376 KB Output is correct