#include <bits/stdc++.h>
using namespace std;
#include "xylophone.h"
// #define int long long
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define pb push_back
#define all(a) a.begin(), a.end()
#define endl "\n"
void printVector(vector<int> a){
for (auto x: a) cout << x << " ";
cout << endl;
}
void solve(int n){
vector<int> diff(n+1);
FOR(i,1,n){
diff[i] = query(i, i+1);
}
vector<int> type(n+1, -1);
type[1] = 1;
FOR(i,1,n-1){
int e = query(i, i+2);
if (e == diff[i]+diff[i+1]){
type[i+1] = type[i];
}else{
type[i+1] = type[i]^1;
}
}
vector<int> a(n+1);
FOR(i,1,n){
if (type[i] == 1){
a[i+1] = a[i]+diff[i];
}else{
a[i+1] = a[i]-diff[i];
}
}
int mini = 1e9; int maxi = 0;
int minind = 0; int maxind = 0;
FOR(i,1,n+1){
if (a[i] < mini){
minind = i;
}
if (a[i] > maxi){
maxind = i;
}
mini = min(mini, a[i]);
maxi = max(maxi, a[i]);
}
// printVector(a);
if (maxi - mini == n-1 && maxind > minind){
FOR(i,1,n+1){
answer(i, a[i]-(mini-1));
}
return;
}
a.clear();a.resize(n+1);
FOR(i,1,n){
if (type[i] == 1){
a[i+1] = a[i]-diff[i];
}else{
a[i+1] = a[i]+diff[i];
}
}
mini = 1e9; maxi = 0;
FOR(i,1,n+1){
mini = min(mini, a[i]);maxi = max(maxi, a[i]);
}
FOR(i,1,n+1){
answer(i, a[i]-(mini-1));
}
return;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
1 ms |
336 KB |
Output is correct |
4 |
Correct |
2 ms |
336 KB |
Output is correct |
5 |
Correct |
2 ms |
336 KB |
Output is correct |
6 |
Correct |
2 ms |
336 KB |
Output is correct |
7 |
Correct |
2 ms |
336 KB |
Output is correct |
8 |
Correct |
2 ms |
336 KB |
Output is correct |
9 |
Correct |
2 ms |
336 KB |
Output is correct |
10 |
Correct |
2 ms |
336 KB |
Output is correct |
11 |
Correct |
2 ms |
336 KB |
Output is correct |
12 |
Correct |
2 ms |
336 KB |
Output is correct |
13 |
Correct |
2 ms |
336 KB |
Output is correct |
14 |
Correct |
2 ms |
336 KB |
Output is correct |
15 |
Correct |
2 ms |
336 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
1 ms |
336 KB |
Output is correct |
4 |
Correct |
2 ms |
336 KB |
Output is correct |
5 |
Correct |
2 ms |
336 KB |
Output is correct |
6 |
Correct |
2 ms |
336 KB |
Output is correct |
7 |
Correct |
2 ms |
336 KB |
Output is correct |
8 |
Correct |
2 ms |
336 KB |
Output is correct |
9 |
Correct |
2 ms |
336 KB |
Output is correct |
10 |
Correct |
2 ms |
336 KB |
Output is correct |
11 |
Correct |
2 ms |
336 KB |
Output is correct |
12 |
Correct |
2 ms |
336 KB |
Output is correct |
13 |
Correct |
2 ms |
336 KB |
Output is correct |
14 |
Correct |
2 ms |
336 KB |
Output is correct |
15 |
Correct |
2 ms |
336 KB |
Output is correct |
16 |
Correct |
4 ms |
336 KB |
Output is correct |
17 |
Correct |
7 ms |
336 KB |
Output is correct |
18 |
Correct |
13 ms |
592 KB |
Output is correct |
19 |
Correct |
14 ms |
564 KB |
Output is correct |
20 |
Correct |
14 ms |
444 KB |
Output is correct |
21 |
Correct |
12 ms |
444 KB |
Output is correct |
22 |
Correct |
12 ms |
336 KB |
Output is correct |
23 |
Correct |
12 ms |
336 KB |
Output is correct |
24 |
Correct |
15 ms |
584 KB |
Output is correct |
25 |
Correct |
12 ms |
592 KB |
Output is correct |
26 |
Correct |
13 ms |
592 KB |
Output is correct |
27 |
Correct |
14 ms |
336 KB |
Output is correct |
28 |
Correct |
17 ms |
336 KB |
Output is correct |
29 |
Correct |
15 ms |
592 KB |
Output is correct |
30 |
Correct |
15 ms |
692 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
1 ms |
336 KB |
Output is correct |
4 |
Correct |
2 ms |
336 KB |
Output is correct |
5 |
Correct |
2 ms |
336 KB |
Output is correct |
6 |
Correct |
2 ms |
336 KB |
Output is correct |
7 |
Correct |
2 ms |
336 KB |
Output is correct |
8 |
Correct |
2 ms |
336 KB |
Output is correct |
9 |
Correct |
2 ms |
336 KB |
Output is correct |
10 |
Correct |
2 ms |
336 KB |
Output is correct |
11 |
Correct |
2 ms |
336 KB |
Output is correct |
12 |
Correct |
2 ms |
336 KB |
Output is correct |
13 |
Correct |
2 ms |
336 KB |
Output is correct |
14 |
Correct |
2 ms |
336 KB |
Output is correct |
15 |
Correct |
2 ms |
336 KB |
Output is correct |
16 |
Correct |
4 ms |
336 KB |
Output is correct |
17 |
Correct |
7 ms |
336 KB |
Output is correct |
18 |
Correct |
13 ms |
592 KB |
Output is correct |
19 |
Correct |
14 ms |
564 KB |
Output is correct |
20 |
Correct |
14 ms |
444 KB |
Output is correct |
21 |
Correct |
12 ms |
444 KB |
Output is correct |
22 |
Correct |
12 ms |
336 KB |
Output is correct |
23 |
Correct |
12 ms |
336 KB |
Output is correct |
24 |
Correct |
15 ms |
584 KB |
Output is correct |
25 |
Correct |
12 ms |
592 KB |
Output is correct |
26 |
Correct |
13 ms |
592 KB |
Output is correct |
27 |
Correct |
14 ms |
336 KB |
Output is correct |
28 |
Correct |
17 ms |
336 KB |
Output is correct |
29 |
Correct |
15 ms |
592 KB |
Output is correct |
30 |
Correct |
15 ms |
692 KB |
Output is correct |
31 |
Correct |
31 ms |
448 KB |
Output is correct |
32 |
Correct |
45 ms |
456 KB |
Output is correct |
33 |
Correct |
70 ms |
464 KB |
Output is correct |
34 |
Correct |
77 ms |
464 KB |
Output is correct |
35 |
Correct |
74 ms |
468 KB |
Output is correct |
36 |
Correct |
72 ms |
584 KB |
Output is correct |
37 |
Correct |
71 ms |
584 KB |
Output is correct |
38 |
Correct |
75 ms |
700 KB |
Output is correct |
39 |
Correct |
73 ms |
708 KB |
Output is correct |
40 |
Correct |
80 ms |
472 KB |
Output is correct |
41 |
Correct |
69 ms |
584 KB |
Output is correct |
42 |
Correct |
89 ms |
472 KB |
Output is correct |
43 |
Correct |
75 ms |
448 KB |
Output is correct |
44 |
Correct |
74 ms |
444 KB |
Output is correct |
45 |
Correct |
79 ms |
452 KB |
Output is correct |
46 |
Correct |
83 ms |
464 KB |
Output is correct |
47 |
Correct |
81 ms |
584 KB |
Output is correct |
48 |
Correct |
76 ms |
448 KB |
Output is correct |
49 |
Correct |
77 ms |
464 KB |
Output is correct |
50 |
Correct |
73 ms |
336 KB |
Output is correct |
51 |
Correct |
73 ms |
472 KB |
Output is correct |
52 |
Correct |
81 ms |
336 KB |
Output is correct |
53 |
Correct |
85 ms |
584 KB |
Output is correct |
54 |
Correct |
78 ms |
504 KB |
Output is correct |
55 |
Correct |
73 ms |
704 KB |
Output is correct |
56 |
Correct |
82 ms |
508 KB |
Output is correct |
57 |
Correct |
84 ms |
700 KB |
Output is correct |
58 |
Correct |
78 ms |
596 KB |
Output is correct |
59 |
Correct |
74 ms |
468 KB |
Output is correct |
60 |
Correct |
77 ms |
452 KB |
Output is correct |