#include "xylophone.h"
#include <bits/stdc++.h>
using namespace std;
const int N = 5001;
int a[N],b[N],d[N],ans[N];
void solve(int n)
{
for(int i = 1;i < n;i++) a[i] = query(i,i+1);
for(int i = 1;i < n-1;i++) b[i] = query(i,i+2);
int now = -1,cur = 1,mn = 1;
for(int i = 1;i < n;i++)
{
d[i] = now*a[i];
if(b[i]==a[i] or b[i]==a[i+1]) now = -now;
cur+=d[i];
mn = min(mn,cur);
}
int st = 1+1-mn;
for(int i = 1;i <= n;i++) ans[i] = st,st+=d[i];
int lo,hi;
for(int i = 1;i <= n;i++) if(ans[i]==1) lo = i; else if(ans[i]==n) hi = i;
if(lo>hi) for(int i = 1;i <= n;i++) ans[i] = n+1-ans[i];
for(int i = 1;i <= n;i++) answer(i,ans[i]);
}
Compilation message
xylophone.cpp: In function 'void solve(int)':
xylophone.cpp:25:5: warning: 'hi' may be used uninitialized in this function [-Wmaybe-uninitialized]
if(lo>hi) for(int i = 1;i <= n;i++) ans[i] = n+1-ans[i];
^~
xylophone.cpp:25:5: warning: 'lo' may be used uninitialized in this function [-Wmaybe-uninitialized]
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
256 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
4 |
Correct |
6 ms |
384 KB |
Output is correct |
5 |
Correct |
6 ms |
256 KB |
Output is correct |
6 |
Correct |
7 ms |
384 KB |
Output is correct |
7 |
Correct |
7 ms |
384 KB |
Output is correct |
8 |
Correct |
7 ms |
384 KB |
Output is correct |
9 |
Correct |
6 ms |
384 KB |
Output is correct |
10 |
Correct |
7 ms |
372 KB |
Output is correct |
11 |
Correct |
8 ms |
384 KB |
Output is correct |
12 |
Correct |
6 ms |
384 KB |
Output is correct |
13 |
Correct |
6 ms |
384 KB |
Output is correct |
14 |
Correct |
6 ms |
384 KB |
Output is correct |
15 |
Correct |
7 ms |
384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
256 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
4 |
Correct |
6 ms |
384 KB |
Output is correct |
5 |
Correct |
6 ms |
256 KB |
Output is correct |
6 |
Correct |
7 ms |
384 KB |
Output is correct |
7 |
Correct |
7 ms |
384 KB |
Output is correct |
8 |
Correct |
7 ms |
384 KB |
Output is correct |
9 |
Correct |
6 ms |
384 KB |
Output is correct |
10 |
Correct |
7 ms |
372 KB |
Output is correct |
11 |
Correct |
8 ms |
384 KB |
Output is correct |
12 |
Correct |
6 ms |
384 KB |
Output is correct |
13 |
Correct |
6 ms |
384 KB |
Output is correct |
14 |
Correct |
6 ms |
384 KB |
Output is correct |
15 |
Correct |
7 ms |
384 KB |
Output is correct |
16 |
Correct |
8 ms |
412 KB |
Output is correct |
17 |
Correct |
13 ms |
380 KB |
Output is correct |
18 |
Correct |
21 ms |
384 KB |
Output is correct |
19 |
Correct |
37 ms |
376 KB |
Output is correct |
20 |
Correct |
23 ms |
384 KB |
Output is correct |
21 |
Correct |
25 ms |
376 KB |
Output is correct |
22 |
Correct |
21 ms |
384 KB |
Output is correct |
23 |
Correct |
28 ms |
384 KB |
Output is correct |
24 |
Correct |
26 ms |
384 KB |
Output is correct |
25 |
Correct |
26 ms |
384 KB |
Output is correct |
26 |
Correct |
27 ms |
384 KB |
Output is correct |
27 |
Correct |
27 ms |
408 KB |
Output is correct |
28 |
Correct |
25 ms |
412 KB |
Output is correct |
29 |
Correct |
20 ms |
384 KB |
Output is correct |
30 |
Correct |
23 ms |
372 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
256 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
4 |
Correct |
6 ms |
384 KB |
Output is correct |
5 |
Correct |
6 ms |
256 KB |
Output is correct |
6 |
Correct |
7 ms |
384 KB |
Output is correct |
7 |
Correct |
7 ms |
384 KB |
Output is correct |
8 |
Correct |
7 ms |
384 KB |
Output is correct |
9 |
Correct |
6 ms |
384 KB |
Output is correct |
10 |
Correct |
7 ms |
372 KB |
Output is correct |
11 |
Correct |
8 ms |
384 KB |
Output is correct |
12 |
Correct |
6 ms |
384 KB |
Output is correct |
13 |
Correct |
6 ms |
384 KB |
Output is correct |
14 |
Correct |
6 ms |
384 KB |
Output is correct |
15 |
Correct |
7 ms |
384 KB |
Output is correct |
16 |
Correct |
8 ms |
412 KB |
Output is correct |
17 |
Correct |
13 ms |
380 KB |
Output is correct |
18 |
Correct |
21 ms |
384 KB |
Output is correct |
19 |
Correct |
37 ms |
376 KB |
Output is correct |
20 |
Correct |
23 ms |
384 KB |
Output is correct |
21 |
Correct |
25 ms |
376 KB |
Output is correct |
22 |
Correct |
21 ms |
384 KB |
Output is correct |
23 |
Correct |
28 ms |
384 KB |
Output is correct |
24 |
Correct |
26 ms |
384 KB |
Output is correct |
25 |
Correct |
26 ms |
384 KB |
Output is correct |
26 |
Correct |
27 ms |
384 KB |
Output is correct |
27 |
Correct |
27 ms |
408 KB |
Output is correct |
28 |
Correct |
25 ms |
412 KB |
Output is correct |
29 |
Correct |
20 ms |
384 KB |
Output is correct |
30 |
Correct |
23 ms |
372 KB |
Output is correct |
31 |
Correct |
57 ms |
388 KB |
Output is correct |
32 |
Correct |
63 ms |
384 KB |
Output is correct |
33 |
Correct |
106 ms |
384 KB |
Output is correct |
34 |
Correct |
113 ms |
444 KB |
Output is correct |
35 |
Correct |
122 ms |
384 KB |
Output is correct |
36 |
Correct |
102 ms |
436 KB |
Output is correct |
37 |
Correct |
122 ms |
376 KB |
Output is correct |
38 |
Correct |
110 ms |
404 KB |
Output is correct |
39 |
Correct |
90 ms |
480 KB |
Output is correct |
40 |
Correct |
126 ms |
376 KB |
Output is correct |
41 |
Correct |
108 ms |
416 KB |
Output is correct |
42 |
Correct |
130 ms |
480 KB |
Output is correct |
43 |
Correct |
106 ms |
396 KB |
Output is correct |
44 |
Correct |
131 ms |
388 KB |
Output is correct |
45 |
Correct |
94 ms |
456 KB |
Output is correct |
46 |
Correct |
114 ms |
460 KB |
Output is correct |
47 |
Correct |
114 ms |
384 KB |
Output is correct |
48 |
Correct |
96 ms |
632 KB |
Output is correct |
49 |
Correct |
113 ms |
376 KB |
Output is correct |
50 |
Correct |
93 ms |
404 KB |
Output is correct |
51 |
Correct |
116 ms |
504 KB |
Output is correct |
52 |
Correct |
112 ms |
480 KB |
Output is correct |
53 |
Correct |
109 ms |
388 KB |
Output is correct |
54 |
Correct |
117 ms |
384 KB |
Output is correct |
55 |
Correct |
117 ms |
384 KB |
Output is correct |
56 |
Correct |
113 ms |
504 KB |
Output is correct |
57 |
Correct |
114 ms |
504 KB |
Output is correct |
58 |
Correct |
110 ms |
376 KB |
Output is correct |
59 |
Correct |
109 ms |
504 KB |
Output is correct |
60 |
Correct |
108 ms |
376 KB |
Output is correct |