#include "xylophone.h"
#include "bits/stdc++.h"
using namespace std;
#define fi first
#define se second
#define ll long long
#define dbg(v) cerr<<#v<<" = "<<v<<'\n'
#define vi vector<int>
#define vl vector <ll>
#define pii pair<int,int>
#define mp make_pair
#define db long double
#define pb push_back
#define all(s) s.begin(),s.end()
template < class P , class Q > ostream& operator<<(ostream& stream, pair < P , Q > v){ stream << "(" << v.fi << ',' << v.se << ")"; return stream;}
template < class T > ostream& operator<<(ostream& stream, const vector<T> v){ stream << "[ "; for (int i=0; i<(int)v.size(); i++) stream << v[i] << " "; stream << "]"; return stream;}
template < class T > T smin(T &a,T b) {if (a > b) a = b;return a;}
template < class T > T smax(T &a,T b) {if (a < b) a = b;return a;}
const int N = 1e6 + 5;
int s[N];
int d1[N];
int d2[N];
void solve(int NN) {
int n = NN;
for (int i = 0;i + 1 < n;++i)
d1[i] = query(i + 1,i + 2);
for (int i = 0;i + 2 < n;++i)
d2[i] = query(i + 1,i + 3);
for (int sg = 0;sg < 2;++sg) {
s[0] = 0;
int shit = sg;
for (int i = 1;i < n;++i) {
if (shit)
s[i] = s[i - 1] - d1[i - 1];
else
s[i] = s[i - 1] + d1[i - 1];
if (d2[i - 1] != d1[i - 1] + d1[i])
shit ^= 1;
}
int mn = min_element(s,s + n) - s;
int mx = max_element(s,s + n) - s;
const int val = s[mn];
for (int i = 0;i < n;++i)
s[i] -= val;
int ok = (mn < mx);
for (int i = 0;i < n;++i)
ok &= 0 <= s[i] && s[i] < n;
set < int > ss;
for (int i = 0;i < n;++i)
ss.insert(s[i]);
ok &= ss.size() == n;
if (ok) {
break;
} else {
assert(sg == 0);
}
}
for (int i = 0;i < n;++i)
answer(i + 1,s[i] + 1);
}
Compilation message
xylophone.cpp: In function 'void solve(int)':
xylophone.cpp:55:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
ok &= ss.size() == n;
~~~~~~~~~~^~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
3 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
468 KB |
Output is correct |
5 |
Correct |
4 ms |
496 KB |
Output is correct |
6 |
Correct |
4 ms |
628 KB |
Output is correct |
7 |
Correct |
4 ms |
628 KB |
Output is correct |
8 |
Correct |
3 ms |
628 KB |
Output is correct |
9 |
Correct |
5 ms |
628 KB |
Output is correct |
10 |
Correct |
3 ms |
628 KB |
Output is correct |
11 |
Correct |
3 ms |
628 KB |
Output is correct |
12 |
Correct |
2 ms |
628 KB |
Output is correct |
13 |
Correct |
3 ms |
628 KB |
Output is correct |
14 |
Correct |
4 ms |
628 KB |
Output is correct |
15 |
Correct |
5 ms |
628 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
3 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
468 KB |
Output is correct |
5 |
Correct |
4 ms |
496 KB |
Output is correct |
6 |
Correct |
4 ms |
628 KB |
Output is correct |
7 |
Correct |
4 ms |
628 KB |
Output is correct |
8 |
Correct |
3 ms |
628 KB |
Output is correct |
9 |
Correct |
5 ms |
628 KB |
Output is correct |
10 |
Correct |
3 ms |
628 KB |
Output is correct |
11 |
Correct |
3 ms |
628 KB |
Output is correct |
12 |
Correct |
2 ms |
628 KB |
Output is correct |
13 |
Correct |
3 ms |
628 KB |
Output is correct |
14 |
Correct |
4 ms |
628 KB |
Output is correct |
15 |
Correct |
5 ms |
628 KB |
Output is correct |
16 |
Correct |
7 ms |
628 KB |
Output is correct |
17 |
Correct |
12 ms |
716 KB |
Output is correct |
18 |
Correct |
18 ms |
716 KB |
Output is correct |
19 |
Correct |
22 ms |
716 KB |
Output is correct |
20 |
Correct |
20 ms |
720 KB |
Output is correct |
21 |
Correct |
12 ms |
720 KB |
Output is correct |
22 |
Correct |
9 ms |
720 KB |
Output is correct |
23 |
Correct |
19 ms |
720 KB |
Output is correct |
24 |
Correct |
13 ms |
720 KB |
Output is correct |
25 |
Correct |
21 ms |
720 KB |
Output is correct |
26 |
Correct |
19 ms |
720 KB |
Output is correct |
27 |
Correct |
22 ms |
720 KB |
Output is correct |
28 |
Correct |
15 ms |
720 KB |
Output is correct |
29 |
Correct |
18 ms |
720 KB |
Output is correct |
30 |
Correct |
22 ms |
720 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
3 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
468 KB |
Output is correct |
5 |
Correct |
4 ms |
496 KB |
Output is correct |
6 |
Correct |
4 ms |
628 KB |
Output is correct |
7 |
Correct |
4 ms |
628 KB |
Output is correct |
8 |
Correct |
3 ms |
628 KB |
Output is correct |
9 |
Correct |
5 ms |
628 KB |
Output is correct |
10 |
Correct |
3 ms |
628 KB |
Output is correct |
11 |
Correct |
3 ms |
628 KB |
Output is correct |
12 |
Correct |
2 ms |
628 KB |
Output is correct |
13 |
Correct |
3 ms |
628 KB |
Output is correct |
14 |
Correct |
4 ms |
628 KB |
Output is correct |
15 |
Correct |
5 ms |
628 KB |
Output is correct |
16 |
Correct |
7 ms |
628 KB |
Output is correct |
17 |
Correct |
12 ms |
716 KB |
Output is correct |
18 |
Correct |
18 ms |
716 KB |
Output is correct |
19 |
Correct |
22 ms |
716 KB |
Output is correct |
20 |
Correct |
20 ms |
720 KB |
Output is correct |
21 |
Correct |
12 ms |
720 KB |
Output is correct |
22 |
Correct |
9 ms |
720 KB |
Output is correct |
23 |
Correct |
19 ms |
720 KB |
Output is correct |
24 |
Correct |
13 ms |
720 KB |
Output is correct |
25 |
Correct |
21 ms |
720 KB |
Output is correct |
26 |
Correct |
19 ms |
720 KB |
Output is correct |
27 |
Correct |
22 ms |
720 KB |
Output is correct |
28 |
Correct |
15 ms |
720 KB |
Output is correct |
29 |
Correct |
18 ms |
720 KB |
Output is correct |
30 |
Correct |
22 ms |
720 KB |
Output is correct |
31 |
Correct |
39 ms |
720 KB |
Output is correct |
32 |
Correct |
54 ms |
736 KB |
Output is correct |
33 |
Correct |
49 ms |
840 KB |
Output is correct |
34 |
Correct |
104 ms |
972 KB |
Output is correct |
35 |
Correct |
109 ms |
972 KB |
Output is correct |
36 |
Correct |
114 ms |
972 KB |
Output is correct |
37 |
Correct |
93 ms |
972 KB |
Output is correct |
38 |
Correct |
101 ms |
972 KB |
Output is correct |
39 |
Correct |
122 ms |
972 KB |
Output is correct |
40 |
Correct |
79 ms |
972 KB |
Output is correct |
41 |
Correct |
111 ms |
976 KB |
Output is correct |
42 |
Correct |
89 ms |
976 KB |
Output is correct |
43 |
Correct |
69 ms |
976 KB |
Output is correct |
44 |
Correct |
81 ms |
976 KB |
Output is correct |
45 |
Correct |
40 ms |
976 KB |
Output is correct |
46 |
Correct |
88 ms |
980 KB |
Output is correct |
47 |
Correct |
56 ms |
980 KB |
Output is correct |
48 |
Correct |
44 ms |
980 KB |
Output is correct |
49 |
Correct |
41 ms |
980 KB |
Output is correct |
50 |
Correct |
93 ms |
980 KB |
Output is correct |
51 |
Correct |
47 ms |
980 KB |
Output is correct |
52 |
Correct |
83 ms |
980 KB |
Output is correct |
53 |
Correct |
102 ms |
980 KB |
Output is correct |
54 |
Correct |
67 ms |
980 KB |
Output is correct |
55 |
Correct |
104 ms |
980 KB |
Output is correct |
56 |
Correct |
87 ms |
980 KB |
Output is correct |
57 |
Correct |
89 ms |
980 KB |
Output is correct |
58 |
Correct |
83 ms |
980 KB |
Output is correct |
59 |
Correct |
87 ms |
980 KB |
Output is correct |
60 |
Correct |
87 ms |
980 KB |
Output is correct |