#include "xylophone.h"
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define pll pair<ll,ll>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
using namespace std;
const ll maxn = 5005;
ll T[maxn];
ll n;
ll Min = 1, Max = 2;
void solve(int x)
{
n = x;
T[1] = 0;
T[2] = query(1,2);
ll ptr = 1;
ll cur = T[2];
for(int i = 3; i<= n; i++)
{
ll value = query(i-2, i);
ll value2 = query(i-1, i);
//cout << i << " " << value << " " << value2 << "\n";
if(value==abs(T[i-1]-T[i-2]))
{
//cout << -2;
if(T[i-2]>T[i-1]) T[i] = T[i-1]+value2;
else T[i] = T[i-1]-value2;
}
else
{
if(T[i-2]>T[i-1])
{
//cout << -3;
if(abs(T[i-1]-T[i-2])+value2==value) T[i] = T[i-1]-value2;
else
{
T[i] = T[i-1]+value2;
}
}
else
{
//cout << -1;
if(abs(T[i-1]-T[i-2])+value2==value) T[i] = T[i-1]+value2;
else
{
//cout << -5;
T[i] = T[i-1]-value2;
}
}
}
}
ll Minn = 0;
for(int i = 1; i<= n; i++) Minn = min(Minn, T[i]);
for(int i = 1; i<= n; i++) T[i] += abs(Minn)+1;
ll xMin = 0, xMax = 0;
for(int i = 1; i<= n; i++)
{
if(T[i]==n) xMax = i;
if(T[i]==1) xMin = i;
}
if(xMin>xMax)
{
for(int i = 1; i<= n; i++) T[i] = n-T[i]+1;
}
//for(int i = 1; i<= n; i++) cout << T[i] << " ";
for(int i = 1; i<= n; i++)
{
answer(i, T[i]);
}
}
Compilation message
xylophone.cpp: In function 'void solve(int)':
xylophone.cpp:20:8: warning: unused variable 'ptr' [-Wunused-variable]
20 | ll ptr = 1;
| ^~~
xylophone.cpp:21:8: warning: unused variable 'cur' [-Wunused-variable]
21 | ll cur = T[2];
| ^~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Output is correct |
2 |
Correct |
0 ms |
208 KB |
Output is correct |
3 |
Correct |
1 ms |
208 KB |
Output is correct |
4 |
Correct |
2 ms |
208 KB |
Output is correct |
5 |
Correct |
2 ms |
208 KB |
Output is correct |
6 |
Correct |
1 ms |
208 KB |
Output is correct |
7 |
Correct |
3 ms |
208 KB |
Output is correct |
8 |
Correct |
2 ms |
208 KB |
Output is correct |
9 |
Correct |
1 ms |
208 KB |
Output is correct |
10 |
Correct |
2 ms |
208 KB |
Output is correct |
11 |
Correct |
1 ms |
208 KB |
Output is correct |
12 |
Correct |
2 ms |
208 KB |
Output is correct |
13 |
Correct |
2 ms |
208 KB |
Output is correct |
14 |
Correct |
2 ms |
208 KB |
Output is correct |
15 |
Correct |
1 ms |
208 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Output is correct |
2 |
Correct |
0 ms |
208 KB |
Output is correct |
3 |
Correct |
1 ms |
208 KB |
Output is correct |
4 |
Correct |
2 ms |
208 KB |
Output is correct |
5 |
Correct |
2 ms |
208 KB |
Output is correct |
6 |
Correct |
1 ms |
208 KB |
Output is correct |
7 |
Correct |
3 ms |
208 KB |
Output is correct |
8 |
Correct |
2 ms |
208 KB |
Output is correct |
9 |
Correct |
1 ms |
208 KB |
Output is correct |
10 |
Correct |
2 ms |
208 KB |
Output is correct |
11 |
Correct |
1 ms |
208 KB |
Output is correct |
12 |
Correct |
2 ms |
208 KB |
Output is correct |
13 |
Correct |
2 ms |
208 KB |
Output is correct |
14 |
Correct |
2 ms |
208 KB |
Output is correct |
15 |
Correct |
1 ms |
208 KB |
Output is correct |
16 |
Correct |
4 ms |
208 KB |
Output is correct |
17 |
Correct |
8 ms |
208 KB |
Output is correct |
18 |
Correct |
12 ms |
208 KB |
Output is correct |
19 |
Correct |
19 ms |
308 KB |
Output is correct |
20 |
Correct |
17 ms |
208 KB |
Output is correct |
21 |
Correct |
17 ms |
296 KB |
Output is correct |
22 |
Correct |
15 ms |
208 KB |
Output is correct |
23 |
Correct |
12 ms |
308 KB |
Output is correct |
24 |
Correct |
13 ms |
304 KB |
Output is correct |
25 |
Correct |
15 ms |
304 KB |
Output is correct |
26 |
Correct |
16 ms |
292 KB |
Output is correct |
27 |
Correct |
15 ms |
208 KB |
Output is correct |
28 |
Correct |
13 ms |
308 KB |
Output is correct |
29 |
Correct |
16 ms |
312 KB |
Output is correct |
30 |
Correct |
10 ms |
304 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Output is correct |
2 |
Correct |
0 ms |
208 KB |
Output is correct |
3 |
Correct |
1 ms |
208 KB |
Output is correct |
4 |
Correct |
2 ms |
208 KB |
Output is correct |
5 |
Correct |
2 ms |
208 KB |
Output is correct |
6 |
Correct |
1 ms |
208 KB |
Output is correct |
7 |
Correct |
3 ms |
208 KB |
Output is correct |
8 |
Correct |
2 ms |
208 KB |
Output is correct |
9 |
Correct |
1 ms |
208 KB |
Output is correct |
10 |
Correct |
2 ms |
208 KB |
Output is correct |
11 |
Correct |
1 ms |
208 KB |
Output is correct |
12 |
Correct |
2 ms |
208 KB |
Output is correct |
13 |
Correct |
2 ms |
208 KB |
Output is correct |
14 |
Correct |
2 ms |
208 KB |
Output is correct |
15 |
Correct |
1 ms |
208 KB |
Output is correct |
16 |
Correct |
4 ms |
208 KB |
Output is correct |
17 |
Correct |
8 ms |
208 KB |
Output is correct |
18 |
Correct |
12 ms |
208 KB |
Output is correct |
19 |
Correct |
19 ms |
308 KB |
Output is correct |
20 |
Correct |
17 ms |
208 KB |
Output is correct |
21 |
Correct |
17 ms |
296 KB |
Output is correct |
22 |
Correct |
15 ms |
208 KB |
Output is correct |
23 |
Correct |
12 ms |
308 KB |
Output is correct |
24 |
Correct |
13 ms |
304 KB |
Output is correct |
25 |
Correct |
15 ms |
304 KB |
Output is correct |
26 |
Correct |
16 ms |
292 KB |
Output is correct |
27 |
Correct |
15 ms |
208 KB |
Output is correct |
28 |
Correct |
13 ms |
308 KB |
Output is correct |
29 |
Correct |
16 ms |
312 KB |
Output is correct |
30 |
Correct |
10 ms |
304 KB |
Output is correct |
31 |
Correct |
29 ms |
304 KB |
Output is correct |
32 |
Correct |
40 ms |
320 KB |
Output is correct |
33 |
Correct |
67 ms |
312 KB |
Output is correct |
34 |
Correct |
75 ms |
444 KB |
Output is correct |
35 |
Correct |
81 ms |
300 KB |
Output is correct |
36 |
Correct |
89 ms |
292 KB |
Output is correct |
37 |
Correct |
69 ms |
308 KB |
Output is correct |
38 |
Correct |
83 ms |
328 KB |
Output is correct |
39 |
Correct |
74 ms |
296 KB |
Output is correct |
40 |
Correct |
67 ms |
360 KB |
Output is correct |
41 |
Correct |
72 ms |
436 KB |
Output is correct |
42 |
Correct |
75 ms |
320 KB |
Output is correct |
43 |
Correct |
76 ms |
420 KB |
Output is correct |
44 |
Correct |
50 ms |
304 KB |
Output is correct |
45 |
Correct |
72 ms |
316 KB |
Output is correct |
46 |
Correct |
85 ms |
320 KB |
Output is correct |
47 |
Correct |
56 ms |
312 KB |
Output is correct |
48 |
Correct |
76 ms |
420 KB |
Output is correct |
49 |
Correct |
97 ms |
328 KB |
Output is correct |
50 |
Correct |
95 ms |
364 KB |
Output is correct |
51 |
Correct |
65 ms |
332 KB |
Output is correct |
52 |
Correct |
79 ms |
424 KB |
Output is correct |
53 |
Correct |
80 ms |
300 KB |
Output is correct |
54 |
Correct |
92 ms |
328 KB |
Output is correct |
55 |
Correct |
81 ms |
544 KB |
Output is correct |
56 |
Correct |
88 ms |
312 KB |
Output is correct |
57 |
Correct |
74 ms |
416 KB |
Output is correct |
58 |
Correct |
94 ms |
332 KB |
Output is correct |
59 |
Correct |
88 ms |
300 KB |
Output is correct |
60 |
Correct |
79 ms |
320 KB |
Output is correct |