Submission #1116510

# Submission time Handle Problem Language Result Execution time Memory
1116510 2024-11-21T18:25:13 Z hyakup Xylophone (JOI18_xylophone) C++17
100 / 100
196 ms 584 KB
#include "xylophone.h"
#include <bits/stdc++.h>
using namespace std;
#define bug(x) cerr << #x << " " << x << endl;

void solve(int N) {
	int n = N;
	vector<int> dif( n + 1 ), x( n + 1, 1 );
	for( int i = 2; i <= n; i++ ){
		dif[i] = query( i - 1, i );
		if( i > 2 ){
			int aux = query( i - 2, i );
			if( aux == dif[i - 1] || aux == dif[i] ) x[i] = -x[i - 1];
			else x[i] = x[i - 1];
		}
	}

	pair<int, int> maxi( 0, 1 ), mini( 0, 1 );
	for( int i = 2, sum = 0; i <= n; i++ ){
		sum += dif[i]*x[i];
		maxi = max( maxi, make_pair( sum, i ) );
		mini = min( mini, make_pair( sum, i ) );
	}

	int val;
	if( maxi.second < mini.second ){
		val = 1 + abs(maxi.first);
		for( int i = 2; i <= n; i++ ) x[i] = -x[i];
	}
	else val = 1 + abs(mini.first);
	answer( 1, val );
	for( int i = 2; i <= n; i++ ){
		val += dif[i]*x[i];
		answer( i, val );
	}

}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 2 ms 336 KB Output is correct
4 Correct 4 ms 336 KB Output is correct
5 Correct 4 ms 336 KB Output is correct
6 Correct 4 ms 336 KB Output is correct
7 Correct 3 ms 336 KB Output is correct
8 Correct 4 ms 336 KB Output is correct
9 Correct 4 ms 336 KB Output is correct
10 Correct 3 ms 336 KB Output is correct
11 Correct 3 ms 336 KB Output is correct
12 Correct 4 ms 504 KB Output is correct
13 Correct 3 ms 336 KB Output is correct
14 Correct 4 ms 336 KB Output is correct
15 Correct 4 ms 336 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 2 ms 336 KB Output is correct
4 Correct 4 ms 336 KB Output is correct
5 Correct 4 ms 336 KB Output is correct
6 Correct 4 ms 336 KB Output is correct
7 Correct 3 ms 336 KB Output is correct
8 Correct 4 ms 336 KB Output is correct
9 Correct 4 ms 336 KB Output is correct
10 Correct 3 ms 336 KB Output is correct
11 Correct 3 ms 336 KB Output is correct
12 Correct 4 ms 504 KB Output is correct
13 Correct 3 ms 336 KB Output is correct
14 Correct 4 ms 336 KB Output is correct
15 Correct 4 ms 336 KB Output is correct
16 Correct 7 ms 336 KB Output is correct
17 Correct 15 ms 336 KB Output is correct
18 Correct 28 ms 336 KB Output is correct
19 Correct 26 ms 508 KB Output is correct
20 Correct 28 ms 336 KB Output is correct
21 Correct 29 ms 336 KB Output is correct
22 Correct 29 ms 336 KB Output is correct
23 Correct 28 ms 504 KB Output is correct
24 Correct 38 ms 336 KB Output is correct
25 Correct 34 ms 336 KB Output is correct
26 Correct 29 ms 336 KB Output is correct
27 Correct 29 ms 336 KB Output is correct
28 Correct 31 ms 336 KB Output is correct
29 Correct 29 ms 584 KB Output is correct
30 Correct 28 ms 336 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 2 ms 336 KB Output is correct
4 Correct 4 ms 336 KB Output is correct
5 Correct 4 ms 336 KB Output is correct
6 Correct 4 ms 336 KB Output is correct
7 Correct 3 ms 336 KB Output is correct
8 Correct 4 ms 336 KB Output is correct
9 Correct 4 ms 336 KB Output is correct
10 Correct 3 ms 336 KB Output is correct
11 Correct 3 ms 336 KB Output is correct
12 Correct 4 ms 504 KB Output is correct
13 Correct 3 ms 336 KB Output is correct
14 Correct 4 ms 336 KB Output is correct
15 Correct 4 ms 336 KB Output is correct
16 Correct 7 ms 336 KB Output is correct
17 Correct 15 ms 336 KB Output is correct
18 Correct 28 ms 336 KB Output is correct
19 Correct 26 ms 508 KB Output is correct
20 Correct 28 ms 336 KB Output is correct
21 Correct 29 ms 336 KB Output is correct
22 Correct 29 ms 336 KB Output is correct
23 Correct 28 ms 504 KB Output is correct
24 Correct 38 ms 336 KB Output is correct
25 Correct 34 ms 336 KB Output is correct
26 Correct 29 ms 336 KB Output is correct
27 Correct 29 ms 336 KB Output is correct
28 Correct 31 ms 336 KB Output is correct
29 Correct 29 ms 584 KB Output is correct
30 Correct 28 ms 336 KB Output is correct
31 Correct 70 ms 336 KB Output is correct
32 Correct 113 ms 336 KB Output is correct
33 Correct 164 ms 464 KB Output is correct
34 Correct 174 ms 336 KB Output is correct
35 Correct 177 ms 336 KB Output is correct
36 Correct 191 ms 336 KB Output is correct
37 Correct 173 ms 468 KB Output is correct
38 Correct 181 ms 336 KB Output is correct
39 Correct 167 ms 464 KB Output is correct
40 Correct 184 ms 336 KB Output is correct
41 Correct 191 ms 336 KB Output is correct
42 Correct 177 ms 336 KB Output is correct
43 Correct 188 ms 464 KB Output is correct
44 Correct 173 ms 336 KB Output is correct
45 Correct 177 ms 464 KB Output is correct
46 Correct 171 ms 336 KB Output is correct
47 Correct 180 ms 504 KB Output is correct
48 Correct 177 ms 336 KB Output is correct
49 Correct 186 ms 336 KB Output is correct
50 Correct 168 ms 472 KB Output is correct
51 Correct 177 ms 336 KB Output is correct
52 Correct 180 ms 336 KB Output is correct
53 Correct 170 ms 336 KB Output is correct
54 Correct 196 ms 336 KB Output is correct
55 Correct 183 ms 468 KB Output is correct
56 Correct 186 ms 336 KB Output is correct
57 Correct 172 ms 336 KB Output is correct
58 Correct 184 ms 336 KB Output is correct
59 Correct 179 ms 336 KB Output is correct
60 Correct 183 ms 336 KB Output is correct