Submission #263813

# Submission time Handle Problem Language Result Execution time Memory
263813 2020-08-14T02:23:04 Z Falcon Xylophone (JOI18_xylophone) C++14
100 / 100
109 ms 536 KB
#pragma GCC optimize("O2")

#include "xylophone.h"
#include <bits/stdc++.h>
#ifdef DEBUG
    #include "debug.hpp"
#endif

using namespace std;

#define all(c) (c).begin(), (c).end()
#define traverse(c, it) for(auto it = (c).begin(); it != (c).end(); it++)
#define rep(i, N) for(int i = 0; i < (N); i++)
#define rep1(i, N) for(int i = 1; i <= (N); i++)
#define rep2(i, s, e) for(int i = (s); i <= (e); i++)
#define rep3(i, s, e, d) for(int i = (s); (d) >= 0 ? i <= (e) : i >= (e); i += (d))
#define pb push_back


#ifdef DEBUG
    #define debug(x...) {dbg::depth++; string dbg_vals = dbg::to_string(x); dbg::depth--; dbg::fprint(__func__, __LINE__, #x, dbg_vals);}
    #define light_debug(x) {dbg::light = 1; dbg::dout << __func__ << ":" << __LINE__ << "  " << #x << " = " << x << endl; dbg::light = 0;}
#else
    #define debug(x...)
    #define light_debug(x) 
#endif

template<typename T>
T& ckmin(T& a, T b){ return a = a > b ? b : a; }

template<typename T>
T& ckmax(T& a, T b){ return a = a < b ? b : a; }

using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
	

void solve(int N) {
	vi A(N + 1), d(N);
	rep1(i, N - 1)
		d[i] =  query(i, i + 1);
	A[2] = A[1] + d[1];

	int pre = 1;
	rep1(i, N - 2){
		if(query(i, i + 2) != d[i] + d[i + 1])
			pre *= -1;
		A[i + 2] = A[i + 1] + d[i + 1] * pre;
	}
	int shift = 1 - *min_element(1 + all(A));

	rep1(i, N) A[i] += shift;

	if(min_element(1 + all(A)) > max_element(1 + all(A)))
		rep1(i, N) A[i] = 1 + N - A[i];

	rep1(i, N) answer(i, A[i]);
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 1 ms 256 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
6 Correct 3 ms 256 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
8 Correct 2 ms 256 KB Output is correct
9 Correct 2 ms 256 KB Output is correct
10 Correct 2 ms 256 KB Output is correct
11 Correct 2 ms 256 KB Output is correct
12 Correct 2 ms 416 KB Output is correct
13 Correct 2 ms 256 KB Output is correct
14 Correct 3 ms 256 KB Output is correct
15 Correct 3 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 1 ms 256 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
6 Correct 3 ms 256 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
8 Correct 2 ms 256 KB Output is correct
9 Correct 2 ms 256 KB Output is correct
10 Correct 2 ms 256 KB Output is correct
11 Correct 2 ms 256 KB Output is correct
12 Correct 2 ms 416 KB Output is correct
13 Correct 2 ms 256 KB Output is correct
14 Correct 3 ms 256 KB Output is correct
15 Correct 3 ms 256 KB Output is correct
16 Correct 6 ms 256 KB Output is correct
17 Correct 9 ms 256 KB Output is correct
18 Correct 15 ms 376 KB Output is correct
19 Correct 22 ms 384 KB Output is correct
20 Correct 22 ms 256 KB Output is correct
21 Correct 22 ms 256 KB Output is correct
22 Correct 19 ms 256 KB Output is correct
23 Correct 18 ms 256 KB Output is correct
24 Correct 19 ms 384 KB Output is correct
25 Correct 19 ms 256 KB Output is correct
26 Correct 17 ms 376 KB Output is correct
27 Correct 16 ms 384 KB Output is correct
28 Correct 15 ms 376 KB Output is correct
29 Correct 19 ms 256 KB Output is correct
30 Correct 13 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 1 ms 256 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
6 Correct 3 ms 256 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
8 Correct 2 ms 256 KB Output is correct
9 Correct 2 ms 256 KB Output is correct
10 Correct 2 ms 256 KB Output is correct
11 Correct 2 ms 256 KB Output is correct
12 Correct 2 ms 416 KB Output is correct
13 Correct 2 ms 256 KB Output is correct
14 Correct 3 ms 256 KB Output is correct
15 Correct 3 ms 256 KB Output is correct
16 Correct 6 ms 256 KB Output is correct
17 Correct 9 ms 256 KB Output is correct
18 Correct 15 ms 376 KB Output is correct
19 Correct 22 ms 384 KB Output is correct
20 Correct 22 ms 256 KB Output is correct
21 Correct 22 ms 256 KB Output is correct
22 Correct 19 ms 256 KB Output is correct
23 Correct 18 ms 256 KB Output is correct
24 Correct 19 ms 384 KB Output is correct
25 Correct 19 ms 256 KB Output is correct
26 Correct 17 ms 376 KB Output is correct
27 Correct 16 ms 384 KB Output is correct
28 Correct 15 ms 376 KB Output is correct
29 Correct 19 ms 256 KB Output is correct
30 Correct 13 ms 376 KB Output is correct
31 Correct 39 ms 384 KB Output is correct
32 Correct 43 ms 392 KB Output is correct
33 Correct 66 ms 408 KB Output is correct
34 Correct 93 ms 384 KB Output is correct
35 Correct 90 ms 384 KB Output is correct
36 Correct 71 ms 408 KB Output is correct
37 Correct 77 ms 384 KB Output is correct
38 Correct 95 ms 384 KB Output is correct
39 Correct 97 ms 408 KB Output is correct
40 Correct 70 ms 408 KB Output is correct
41 Correct 109 ms 384 KB Output is correct
42 Correct 55 ms 384 KB Output is correct
43 Correct 95 ms 384 KB Output is correct
44 Correct 89 ms 384 KB Output is correct
45 Correct 89 ms 408 KB Output is correct
46 Correct 96 ms 408 KB Output is correct
47 Correct 85 ms 504 KB Output is correct
48 Correct 99 ms 536 KB Output is correct
49 Correct 101 ms 384 KB Output is correct
50 Correct 83 ms 408 KB Output is correct
51 Correct 91 ms 404 KB Output is correct
52 Correct 80 ms 504 KB Output is correct
53 Correct 81 ms 384 KB Output is correct
54 Correct 89 ms 384 KB Output is correct
55 Correct 92 ms 384 KB Output is correct
56 Correct 95 ms 384 KB Output is correct
57 Correct 89 ms 504 KB Output is correct
58 Correct 78 ms 504 KB Output is correct
59 Correct 70 ms 504 KB Output is correct
60 Correct 87 ms 504 KB Output is correct