#include "xylophone.h"
#include <bits/stdc++.h>
using namespace std;
#define oo 1e9
#define fi first
#define se second
#define sp(iiii) setprecision(iiii)
#define IO ios_base::sync_with_stdio(false); cin.tie(0)
#define ms(aaaa,xxxx) memset(aaaa,xxxx,sizeof(aaaa))
#define cntbit(xxxx) __builtin_popcount(xxxx)
#define getbit(xxxx,aaaa) (((xxxx)>>(aaaa-1))&1)
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<pair<int,int>,int> piii;
typedef pair<pair<int,int>,pair<int,int>> piiii;
typedef pair<long long,long long> pll;
typedef pair<pair<long long,long long>,long long> plll;
typedef pair<pair<long long,long long>,pair<long long,long long>> pllll;
typedef pair<pair<long long,long long>,bool> pllb;
typedef pair<long double,long double> pld;
typedef pair<pair<long double,long double>,long double> plld;
typedef pair<long double,long long> pdl;
const ll base=2e9+4257;
const ll mod=998244353;
const ll mod2=1e9+4233;
const ld eps=1e-3;
const ld eps2=1e-7;
const ll maxn=1e16;
const ld pi=acos(-1);
const ll delta=1e5+7;
const int dx[4]={1,-1,0,0};
const int dy[4]={0,0,1,-1};
static int A[5000];
int ans[5009],n,i,val[5009],val2[5009];
bool chan[5009];
bool tryt(int x,int y) {
int depth=0;
int posl=0;
int posr=0;
ans[1]=0;
for (i=2;i<=n;i++) {
ans[i]=ans[i-1]+val[i-1]*y;
if (chan[i]) y*=-1;
depth=min(depth,ans[i]);
}
for (i=1;i<=n;i++) {
ans[i]+=1-depth;
if (ans[i]==1) {
posl=i;
}
else if (ans[i]==n) {
posr=i;
}
}
if (posl<posr) {
return true;
}
else {
return false;
}
}
void print() {
for (i=1;i<=n;i++) {
answer(i,ans[i]);
}
}
void solve(int N) {
n=N;
for (i=1;i<=n-1;i++) {
val[i]=query(i,i+1);
}
for (i=1;i<n-1;i++) {
val2[i]=query(i,i+2);
}
for (i=1;i<=n-2;i++) {
if (val[i]+val[i+1]!=val2[i]) {
chan[i+1]=true;
}
}
if (tryt(1,1)) {
print();
}
else {
tryt(1,-1);
print();
}
}
Compilation message
xylophone.cpp:39:12: warning: 'A' defined but not used [-Wunused-variable]
39 | static int A[5000];
| ^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
200 KB |
Output is correct |
2 |
Correct |
1 ms |
200 KB |
Output is correct |
3 |
Correct |
1 ms |
200 KB |
Output is correct |
4 |
Correct |
3 ms |
200 KB |
Output is correct |
5 |
Correct |
3 ms |
200 KB |
Output is correct |
6 |
Correct |
2 ms |
200 KB |
Output is correct |
7 |
Correct |
2 ms |
200 KB |
Output is correct |
8 |
Correct |
3 ms |
200 KB |
Output is correct |
9 |
Correct |
3 ms |
200 KB |
Output is correct |
10 |
Correct |
3 ms |
200 KB |
Output is correct |
11 |
Correct |
3 ms |
328 KB |
Output is correct |
12 |
Correct |
3 ms |
200 KB |
Output is correct |
13 |
Correct |
2 ms |
200 KB |
Output is correct |
14 |
Correct |
2 ms |
200 KB |
Output is correct |
15 |
Correct |
2 ms |
200 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
200 KB |
Output is correct |
2 |
Correct |
1 ms |
200 KB |
Output is correct |
3 |
Correct |
1 ms |
200 KB |
Output is correct |
4 |
Correct |
3 ms |
200 KB |
Output is correct |
5 |
Correct |
3 ms |
200 KB |
Output is correct |
6 |
Correct |
2 ms |
200 KB |
Output is correct |
7 |
Correct |
2 ms |
200 KB |
Output is correct |
8 |
Correct |
3 ms |
200 KB |
Output is correct |
9 |
Correct |
3 ms |
200 KB |
Output is correct |
10 |
Correct |
3 ms |
200 KB |
Output is correct |
11 |
Correct |
3 ms |
328 KB |
Output is correct |
12 |
Correct |
3 ms |
200 KB |
Output is correct |
13 |
Correct |
2 ms |
200 KB |
Output is correct |
14 |
Correct |
2 ms |
200 KB |
Output is correct |
15 |
Correct |
2 ms |
200 KB |
Output is correct |
16 |
Correct |
5 ms |
304 KB |
Output is correct |
17 |
Correct |
13 ms |
308 KB |
Output is correct |
18 |
Correct |
13 ms |
296 KB |
Output is correct |
19 |
Correct |
24 ms |
200 KB |
Output is correct |
20 |
Correct |
23 ms |
308 KB |
Output is correct |
21 |
Correct |
25 ms |
300 KB |
Output is correct |
22 |
Correct |
21 ms |
312 KB |
Output is correct |
23 |
Correct |
23 ms |
300 KB |
Output is correct |
24 |
Correct |
25 ms |
288 KB |
Output is correct |
25 |
Correct |
17 ms |
292 KB |
Output is correct |
26 |
Correct |
17 ms |
200 KB |
Output is correct |
27 |
Correct |
20 ms |
296 KB |
Output is correct |
28 |
Correct |
18 ms |
200 KB |
Output is correct |
29 |
Correct |
18 ms |
296 KB |
Output is correct |
30 |
Correct |
22 ms |
288 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
200 KB |
Output is correct |
2 |
Correct |
1 ms |
200 KB |
Output is correct |
3 |
Correct |
1 ms |
200 KB |
Output is correct |
4 |
Correct |
3 ms |
200 KB |
Output is correct |
5 |
Correct |
3 ms |
200 KB |
Output is correct |
6 |
Correct |
2 ms |
200 KB |
Output is correct |
7 |
Correct |
2 ms |
200 KB |
Output is correct |
8 |
Correct |
3 ms |
200 KB |
Output is correct |
9 |
Correct |
3 ms |
200 KB |
Output is correct |
10 |
Correct |
3 ms |
200 KB |
Output is correct |
11 |
Correct |
3 ms |
328 KB |
Output is correct |
12 |
Correct |
3 ms |
200 KB |
Output is correct |
13 |
Correct |
2 ms |
200 KB |
Output is correct |
14 |
Correct |
2 ms |
200 KB |
Output is correct |
15 |
Correct |
2 ms |
200 KB |
Output is correct |
16 |
Correct |
5 ms |
304 KB |
Output is correct |
17 |
Correct |
13 ms |
308 KB |
Output is correct |
18 |
Correct |
13 ms |
296 KB |
Output is correct |
19 |
Correct |
24 ms |
200 KB |
Output is correct |
20 |
Correct |
23 ms |
308 KB |
Output is correct |
21 |
Correct |
25 ms |
300 KB |
Output is correct |
22 |
Correct |
21 ms |
312 KB |
Output is correct |
23 |
Correct |
23 ms |
300 KB |
Output is correct |
24 |
Correct |
25 ms |
288 KB |
Output is correct |
25 |
Correct |
17 ms |
292 KB |
Output is correct |
26 |
Correct |
17 ms |
200 KB |
Output is correct |
27 |
Correct |
20 ms |
296 KB |
Output is correct |
28 |
Correct |
18 ms |
200 KB |
Output is correct |
29 |
Correct |
18 ms |
296 KB |
Output is correct |
30 |
Correct |
22 ms |
288 KB |
Output is correct |
31 |
Correct |
51 ms |
296 KB |
Output is correct |
32 |
Correct |
67 ms |
296 KB |
Output is correct |
33 |
Correct |
49 ms |
304 KB |
Output is correct |
34 |
Correct |
106 ms |
320 KB |
Output is correct |
35 |
Correct |
129 ms |
320 KB |
Output is correct |
36 |
Correct |
83 ms |
508 KB |
Output is correct |
37 |
Correct |
103 ms |
308 KB |
Output is correct |
38 |
Correct |
62 ms |
284 KB |
Output is correct |
39 |
Correct |
110 ms |
568 KB |
Output is correct |
40 |
Correct |
129 ms |
316 KB |
Output is correct |
41 |
Correct |
127 ms |
304 KB |
Output is correct |
42 |
Correct |
113 ms |
304 KB |
Output is correct |
43 |
Correct |
130 ms |
316 KB |
Output is correct |
44 |
Correct |
78 ms |
300 KB |
Output is correct |
45 |
Correct |
83 ms |
316 KB |
Output is correct |
46 |
Correct |
124 ms |
296 KB |
Output is correct |
47 |
Correct |
97 ms |
320 KB |
Output is correct |
48 |
Correct |
129 ms |
320 KB |
Output is correct |
49 |
Correct |
116 ms |
316 KB |
Output is correct |
50 |
Correct |
116 ms |
312 KB |
Output is correct |
51 |
Correct |
124 ms |
304 KB |
Output is correct |
52 |
Correct |
125 ms |
320 KB |
Output is correct |
53 |
Correct |
113 ms |
292 KB |
Output is correct |
54 |
Correct |
121 ms |
320 KB |
Output is correct |
55 |
Correct |
89 ms |
308 KB |
Output is correct |
56 |
Correct |
108 ms |
312 KB |
Output is correct |
57 |
Correct |
101 ms |
292 KB |
Output is correct |
58 |
Correct |
81 ms |
328 KB |
Output is correct |
59 |
Correct |
122 ms |
320 KB |
Output is correct |
60 |
Correct |
84 ms |
320 KB |
Output is correct |