#include "xylophone.h"
#include <bits/stdc++.h>
using namespace std;
#define fo(i,s,t) for(int i = s; i <= t; ++ i)
#define fd(i,s,t) for(int i = s; i >= t; -- i)
#define bf(i,s) for(int i = head[s]; i; i = e[i].next)
#define mp make_pair
#define fi first
#define se second
#define pii pair<int,int>
#define pb push_back
#define VI vector<int>
#define sf scanf
#define pf printf
#define fp freopen
#define SZ(x) ((int)(x).size())
#ifdef MPS
#define D(x...) printf(x)
#else
#define D(x...)
#endif
typedef long long ll;
typedef double db;
typedef unsigned long long ull;
const int inf = 1<<30;
const ll INF = 1ll<<60;
const db Inf = 1e20;
const db eps = 1e-9;
void gmax(int &a,int b){a = (a > b ? a : b);}
void gmin(int &a,int b){a = (a < b ? a : b);}
const int maxn = 5005;
int two[maxn], three[maxn], a[maxn];
void solve(int N)
{
fo(i,1,N-1) two[i] = query(i, i+1);
fo(i,1,N-2) three[i] = query(i, i+2);
a[1] = 0; a[2] = two[1];
int lastorder = 1;
fo(i,1,N-2)
{
if(three[i] == two[i] + two[i+1])
{
a[i+2] = a[i+1] + lastorder * two[i+1];
}
else
{
lastorder *= -1;
a[i+2] = a[i+1] + lastorder * two[i+1];
}
}
int mn = inf, mx;
// fo(i,1,N) pf("%d ", a[i]);
fo(i,1,N) gmin(mn, a[i]);
fo(i,1,N) a[i] -= mn - 1;
mn = mx = -1;
fo(i,1,N)
{
if(mn == -1 || a[mn] > a[i]) mn = i;
if(mx == -1 || a[mx] < a[i]) mx = i;
}
if(mx < mn) fo(i,1,N) a[i] = N - a[i] + 1;
fo(i,1,N) answer(i, a[i]);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
312 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
3 ms |
248 KB |
Output is correct |
4 |
Correct |
2 ms |
444 KB |
Output is correct |
5 |
Correct |
4 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
396 KB |
Output is correct |
7 |
Correct |
3 ms |
276 KB |
Output is correct |
8 |
Correct |
3 ms |
376 KB |
Output is correct |
9 |
Correct |
2 ms |
312 KB |
Output is correct |
10 |
Correct |
3 ms |
248 KB |
Output is correct |
11 |
Correct |
2 ms |
320 KB |
Output is correct |
12 |
Correct |
3 ms |
376 KB |
Output is correct |
13 |
Correct |
4 ms |
376 KB |
Output is correct |
14 |
Correct |
4 ms |
376 KB |
Output is correct |
15 |
Correct |
2 ms |
320 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
312 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
3 ms |
248 KB |
Output is correct |
4 |
Correct |
2 ms |
444 KB |
Output is correct |
5 |
Correct |
4 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
396 KB |
Output is correct |
7 |
Correct |
3 ms |
276 KB |
Output is correct |
8 |
Correct |
3 ms |
376 KB |
Output is correct |
9 |
Correct |
2 ms |
312 KB |
Output is correct |
10 |
Correct |
3 ms |
248 KB |
Output is correct |
11 |
Correct |
2 ms |
320 KB |
Output is correct |
12 |
Correct |
3 ms |
376 KB |
Output is correct |
13 |
Correct |
4 ms |
376 KB |
Output is correct |
14 |
Correct |
4 ms |
376 KB |
Output is correct |
15 |
Correct |
2 ms |
320 KB |
Output is correct |
16 |
Correct |
7 ms |
296 KB |
Output is correct |
17 |
Correct |
10 ms |
328 KB |
Output is correct |
18 |
Correct |
16 ms |
376 KB |
Output is correct |
19 |
Correct |
8 ms |
320 KB |
Output is correct |
20 |
Correct |
17 ms |
324 KB |
Output is correct |
21 |
Correct |
8 ms |
404 KB |
Output is correct |
22 |
Correct |
19 ms |
248 KB |
Output is correct |
23 |
Correct |
19 ms |
324 KB |
Output is correct |
24 |
Correct |
9 ms |
400 KB |
Output is correct |
25 |
Correct |
19 ms |
248 KB |
Output is correct |
26 |
Correct |
15 ms |
376 KB |
Output is correct |
27 |
Correct |
17 ms |
248 KB |
Output is correct |
28 |
Correct |
21 ms |
380 KB |
Output is correct |
29 |
Correct |
18 ms |
248 KB |
Output is correct |
30 |
Correct |
17 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
312 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
3 ms |
248 KB |
Output is correct |
4 |
Correct |
2 ms |
444 KB |
Output is correct |
5 |
Correct |
4 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
396 KB |
Output is correct |
7 |
Correct |
3 ms |
276 KB |
Output is correct |
8 |
Correct |
3 ms |
376 KB |
Output is correct |
9 |
Correct |
2 ms |
312 KB |
Output is correct |
10 |
Correct |
3 ms |
248 KB |
Output is correct |
11 |
Correct |
2 ms |
320 KB |
Output is correct |
12 |
Correct |
3 ms |
376 KB |
Output is correct |
13 |
Correct |
4 ms |
376 KB |
Output is correct |
14 |
Correct |
4 ms |
376 KB |
Output is correct |
15 |
Correct |
2 ms |
320 KB |
Output is correct |
16 |
Correct |
7 ms |
296 KB |
Output is correct |
17 |
Correct |
10 ms |
328 KB |
Output is correct |
18 |
Correct |
16 ms |
376 KB |
Output is correct |
19 |
Correct |
8 ms |
320 KB |
Output is correct |
20 |
Correct |
17 ms |
324 KB |
Output is correct |
21 |
Correct |
8 ms |
404 KB |
Output is correct |
22 |
Correct |
19 ms |
248 KB |
Output is correct |
23 |
Correct |
19 ms |
324 KB |
Output is correct |
24 |
Correct |
9 ms |
400 KB |
Output is correct |
25 |
Correct |
19 ms |
248 KB |
Output is correct |
26 |
Correct |
15 ms |
376 KB |
Output is correct |
27 |
Correct |
17 ms |
248 KB |
Output is correct |
28 |
Correct |
21 ms |
380 KB |
Output is correct |
29 |
Correct |
18 ms |
248 KB |
Output is correct |
30 |
Correct |
17 ms |
376 KB |
Output is correct |
31 |
Correct |
27 ms |
376 KB |
Output is correct |
32 |
Correct |
59 ms |
516 KB |
Output is correct |
33 |
Correct |
65 ms |
520 KB |
Output is correct |
34 |
Correct |
89 ms |
416 KB |
Output is correct |
35 |
Correct |
34 ms |
400 KB |
Output is correct |
36 |
Correct |
79 ms |
424 KB |
Output is correct |
37 |
Correct |
45 ms |
356 KB |
Output is correct |
38 |
Correct |
53 ms |
332 KB |
Output is correct |
39 |
Correct |
34 ms |
316 KB |
Output is correct |
40 |
Correct |
88 ms |
424 KB |
Output is correct |
41 |
Correct |
86 ms |
376 KB |
Output is correct |
42 |
Correct |
93 ms |
292 KB |
Output is correct |
43 |
Correct |
33 ms |
504 KB |
Output is correct |
44 |
Correct |
95 ms |
376 KB |
Output is correct |
45 |
Correct |
90 ms |
376 KB |
Output is correct |
46 |
Correct |
84 ms |
248 KB |
Output is correct |
47 |
Correct |
86 ms |
248 KB |
Output is correct |
48 |
Correct |
52 ms |
404 KB |
Output is correct |
49 |
Correct |
50 ms |
348 KB |
Output is correct |
50 |
Correct |
90 ms |
376 KB |
Output is correct |
51 |
Correct |
89 ms |
424 KB |
Output is correct |
52 |
Correct |
83 ms |
380 KB |
Output is correct |
53 |
Correct |
86 ms |
248 KB |
Output is correct |
54 |
Correct |
97 ms |
376 KB |
Output is correct |
55 |
Correct |
96 ms |
336 KB |
Output is correct |
56 |
Correct |
63 ms |
464 KB |
Output is correct |
57 |
Correct |
50 ms |
376 KB |
Output is correct |
58 |
Correct |
56 ms |
332 KB |
Output is correct |
59 |
Correct |
59 ms |
336 KB |
Output is correct |
60 |
Correct |
82 ms |
248 KB |
Output is correct |