#include "xylophone.h"
#include <bits/stdc++.h>
//#define int long long
#define ll long long
#define pb push_back
#define p_q priority_queue
#define m_p make_pair
#define pii pair<int,int>
#define endl '\n'
#define INIT ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define FOR(i, a, b) for(int i = a; i <= b; i++)
#define forn(i, n) for (int i = 0; i < n; i++)
#define forn1(i, n) for (int i = 1; i <= n; i++)
#define all(x) x.begin(),x.end()
#define ft first
#define sd second
using namespace std;
const int N = 6969;
const int INF = 1e9;
const int MOD = 1e9+7;
int a[N];
int nx[N];
int nx3[N];
bool bl[N];
void solve(int n) {
for(int i = 1; i < n; i++) {
nx[i] = query(i,i+1);
}
for(int i = 1; i < n-1; i++) {
nx3[i] = query(i,i+2);
}
for(int i = 2; i < n; i++) {
bl[i] = (nx3[i-1] != nx[i-1] + nx[i]);
}
a[1] = 1;
bool flag = 1;
for(int i = 2; i <= n; i++) {
if(flag) a[i] = a[i-1]+nx[i-1];
else a[i] = a[i-1]-nx[i-1];
flag = flag!=bl[i];
}
int min_ = INF;
forn1(i,n) {
min_ = min(min_,a[i]);
}
int pos1, posn;
forn1(i,n) {
a[i] += 1 - min_;
if(a[i] == 1) pos1 = i;
if(a[i] == n) posn = i;
}
if(pos1 > posn) {
forn1(i,n) {
a[i] = n+1-a[i];
}
}
forn1(i,n) answer(i, a[i]);
}
Compilation message
xylophone.cpp: In function 'void solve(int)':
xylophone.cpp:55:2: warning: 'posn' may be used uninitialized in this function [-Wmaybe-uninitialized]
55 | if(pos1 > posn) {
| ^~
xylophone.cpp:55:2: warning: 'pos1' may be used uninitialized in this function [-Wmaybe-uninitialized]
# |
결과 |
실행 시간 |
메모리 |
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 |
1 ms |
208 KB |
Output is correct |
6 |
Correct |
2 ms |
208 KB |
Output is correct |
7 |
Correct |
1 ms |
316 KB |
Output is correct |
8 |
Correct |
2 ms |
284 KB |
Output is correct |
9 |
Correct |
1 ms |
308 KB |
Output is correct |
10 |
Correct |
2 ms |
304 KB |
Output is correct |
11 |
Correct |
2 ms |
300 KB |
Output is correct |
12 |
Correct |
1 ms |
300 KB |
Output is correct |
13 |
Correct |
1 ms |
308 KB |
Output is correct |
14 |
Correct |
3 ms |
208 KB |
Output is correct |
15 |
Correct |
2 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 |
1 ms |
208 KB |
Output is correct |
6 |
Correct |
2 ms |
208 KB |
Output is correct |
7 |
Correct |
1 ms |
316 KB |
Output is correct |
8 |
Correct |
2 ms |
284 KB |
Output is correct |
9 |
Correct |
1 ms |
308 KB |
Output is correct |
10 |
Correct |
2 ms |
304 KB |
Output is correct |
11 |
Correct |
2 ms |
300 KB |
Output is correct |
12 |
Correct |
1 ms |
300 KB |
Output is correct |
13 |
Correct |
1 ms |
308 KB |
Output is correct |
14 |
Correct |
3 ms |
208 KB |
Output is correct |
15 |
Correct |
2 ms |
304 KB |
Output is correct |
16 |
Correct |
3 ms |
208 KB |
Output is correct |
17 |
Correct |
4 ms |
304 KB |
Output is correct |
18 |
Correct |
7 ms |
308 KB |
Output is correct |
19 |
Correct |
18 ms |
292 KB |
Output is correct |
20 |
Correct |
19 ms |
208 KB |
Output is correct |
21 |
Correct |
19 ms |
312 KB |
Output is correct |
22 |
Correct |
19 ms |
296 KB |
Output is correct |
23 |
Correct |
19 ms |
304 KB |
Output is correct |
24 |
Correct |
17 ms |
312 KB |
Output is correct |
25 |
Correct |
19 ms |
296 KB |
Output is correct |
26 |
Correct |
13 ms |
308 KB |
Output is correct |
27 |
Correct |
17 ms |
296 KB |
Output is correct |
28 |
Correct |
15 ms |
312 KB |
Output is correct |
29 |
Correct |
16 ms |
308 KB |
Output is correct |
30 |
Correct |
19 ms |
332 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 |
1 ms |
208 KB |
Output is correct |
6 |
Correct |
2 ms |
208 KB |
Output is correct |
7 |
Correct |
1 ms |
316 KB |
Output is correct |
8 |
Correct |
2 ms |
284 KB |
Output is correct |
9 |
Correct |
1 ms |
308 KB |
Output is correct |
10 |
Correct |
2 ms |
304 KB |
Output is correct |
11 |
Correct |
2 ms |
300 KB |
Output is correct |
12 |
Correct |
1 ms |
300 KB |
Output is correct |
13 |
Correct |
1 ms |
308 KB |
Output is correct |
14 |
Correct |
3 ms |
208 KB |
Output is correct |
15 |
Correct |
2 ms |
304 KB |
Output is correct |
16 |
Correct |
3 ms |
208 KB |
Output is correct |
17 |
Correct |
4 ms |
304 KB |
Output is correct |
18 |
Correct |
7 ms |
308 KB |
Output is correct |
19 |
Correct |
18 ms |
292 KB |
Output is correct |
20 |
Correct |
19 ms |
208 KB |
Output is correct |
21 |
Correct |
19 ms |
312 KB |
Output is correct |
22 |
Correct |
19 ms |
296 KB |
Output is correct |
23 |
Correct |
19 ms |
304 KB |
Output is correct |
24 |
Correct |
17 ms |
312 KB |
Output is correct |
25 |
Correct |
19 ms |
296 KB |
Output is correct |
26 |
Correct |
13 ms |
308 KB |
Output is correct |
27 |
Correct |
17 ms |
296 KB |
Output is correct |
28 |
Correct |
15 ms |
312 KB |
Output is correct |
29 |
Correct |
16 ms |
308 KB |
Output is correct |
30 |
Correct |
19 ms |
332 KB |
Output is correct |
31 |
Correct |
36 ms |
300 KB |
Output is correct |
32 |
Correct |
44 ms |
436 KB |
Output is correct |
33 |
Correct |
68 ms |
328 KB |
Output is correct |
34 |
Correct |
79 ms |
300 KB |
Output is correct |
35 |
Correct |
101 ms |
312 KB |
Output is correct |
36 |
Correct |
78 ms |
300 KB |
Output is correct |
37 |
Correct |
85 ms |
328 KB |
Output is correct |
38 |
Correct |
81 ms |
324 KB |
Output is correct |
39 |
Correct |
80 ms |
332 KB |
Output is correct |
40 |
Correct |
96 ms |
304 KB |
Output is correct |
41 |
Correct |
60 ms |
428 KB |
Output is correct |
42 |
Correct |
90 ms |
300 KB |
Output is correct |
43 |
Correct |
103 ms |
296 KB |
Output is correct |
44 |
Correct |
95 ms |
328 KB |
Output is correct |
45 |
Correct |
117 ms |
332 KB |
Output is correct |
46 |
Correct |
93 ms |
332 KB |
Output is correct |
47 |
Correct |
70 ms |
328 KB |
Output is correct |
48 |
Correct |
91 ms |
308 KB |
Output is correct |
49 |
Correct |
71 ms |
336 KB |
Output is correct |
50 |
Correct |
93 ms |
328 KB |
Output is correct |
51 |
Correct |
80 ms |
684 KB |
Output is correct |
52 |
Correct |
83 ms |
308 KB |
Output is correct |
53 |
Correct |
63 ms |
308 KB |
Output is correct |
54 |
Correct |
78 ms |
312 KB |
Output is correct |
55 |
Correct |
76 ms |
304 KB |
Output is correct |
56 |
Correct |
93 ms |
300 KB |
Output is correct |
57 |
Correct |
85 ms |
308 KB |
Output is correct |
58 |
Correct |
74 ms |
452 KB |
Output is correct |
59 |
Correct |
78 ms |
304 KB |
Output is correct |
60 |
Correct |
106 ms |
336 KB |
Output is correct |