# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
659044 |
2022-11-16T06:02:42 Z |
shmad |
Drvca (COCI19_drvca) |
C++17 |
|
169 ms |
12112 KB |
#pragma GCC optimize("O3", "unroll-loops") // "Ofast"
#pragma GCC target("avx2", "bmi", "bmi2", "lzcnt", "popcnt")
#include <bits/stdc++.h>
//#define int long long
#define vt vector
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
#define ff first
#define ss second
#define dbg(x) cerr << #x << " = " << x << '\n'
#define bit(x, i) ((x) >> (i) & 1)
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vvt = vt< vt<int> >;
const int N = 1e6 + 5, mod = 1e9 + 7, B = 500;
const ll inf = 1e18 + 7, LIM = (1ll << 60);
const double eps = 1e-6;
int n, a[N];
void go (int x, int y) {
multiset<int> diff, R;
vt<int> L;
int d = a[y] - a[x], lst = -1;
for (int i = 1; i <= n; i++) {
if (i == x || i == y) continue;
R.insert(a[i]);
}
L.pb(a[x]), L.pb(a[y]);
for (int i: R) {
if (lst != -1) diff.insert(i - lst);
lst = i;
}
int cur = a[y] + d;
do {
if (*diff.begin() == *diff.rbegin()) {
cout << sz(L) << '\n';
for (int i: L) cout << i << ' ';
cout << '\n';
cout << sz(R) << '\n';
for (int i: R) cout << i << ' ';
cout << '\n';
exit(0);
}
auto it = R.find(cur);
if (it == R.end()) return;
auto l = it, r = it;
if (it != R.begin()) {
l--;
diff.erase(diff.find(*it - *l));
}
r++;
if (r != R.end()) {
diff.erase(diff.find(*r - *it));
if (it != R.begin()) diff.insert(*r - *l);
}
R.erase(it);
L.pb(cur);
cur += d;
} while (sz(L) < n);
}
void solve () {
cin >> n;
for (int i = 1; i <= n; i++) cin >> a[i];
sort(a + 1, a + n + 1);
if (n == 2) {
cout << "1\n" << a[1] << "\n1\n" << a[2] << '\n';
return;
}
if (n == 3) {
cout << "2\n" << a[1] << ' ' << a[2] << "\n1\n" << a[3] << '\n';
return;
}
for (int i = 1; i <= 3; i++) {
for (int j = i + 1; j <= 3; j++) go(i, j);
}
cout << -1;
cout << '\n';
}
bool testcases = 0;
signed main() {
#ifdef ONLINE_JUDGE
freopen(".in", "r", stdin);
freopen(".out", "w", stdout);
#endif
cin.tie(0) -> sync_with_stdio(0);
int test = 1;
if (testcases) cin >> test;
for (int cs = 1; cs <= test; cs++) {
solve();
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
292 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
1 ms |
212 KB |
Output is correct |
13 |
Correct |
1 ms |
216 KB |
Output is correct |
14 |
Correct |
0 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
292 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
1 ms |
212 KB |
Output is correct |
13 |
Correct |
1 ms |
216 KB |
Output is correct |
14 |
Correct |
0 ms |
212 KB |
Output is correct |
15 |
Correct |
1 ms |
340 KB |
Output is correct |
16 |
Correct |
1 ms |
344 KB |
Output is correct |
17 |
Correct |
1 ms |
340 KB |
Output is correct |
18 |
Correct |
1 ms |
340 KB |
Output is correct |
19 |
Correct |
1 ms |
340 KB |
Output is correct |
20 |
Correct |
1 ms |
340 KB |
Output is correct |
21 |
Correct |
1 ms |
340 KB |
Output is correct |
22 |
Correct |
1 ms |
340 KB |
Output is correct |
23 |
Correct |
1 ms |
340 KB |
Output is correct |
24 |
Correct |
1 ms |
340 KB |
Output is correct |
25 |
Correct |
1 ms |
340 KB |
Output is correct |
26 |
Correct |
1 ms |
340 KB |
Output is correct |
27 |
Correct |
1 ms |
340 KB |
Output is correct |
28 |
Correct |
1 ms |
340 KB |
Output is correct |
29 |
Correct |
1 ms |
340 KB |
Output is correct |
30 |
Correct |
0 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
105 ms |
12032 KB |
Output is correct |
2 |
Correct |
68 ms |
12064 KB |
Output is correct |
3 |
Correct |
92 ms |
12032 KB |
Output is correct |
4 |
Correct |
68 ms |
12056 KB |
Output is correct |
5 |
Correct |
86 ms |
12104 KB |
Output is correct |
6 |
Correct |
67 ms |
12016 KB |
Output is correct |
7 |
Correct |
92 ms |
11984 KB |
Output is correct |
8 |
Correct |
71 ms |
12072 KB |
Output is correct |
9 |
Correct |
69 ms |
11488 KB |
Output is correct |
10 |
Correct |
78 ms |
12020 KB |
Output is correct |
11 |
Correct |
58 ms |
12112 KB |
Output is correct |
12 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
292 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
1 ms |
212 KB |
Output is correct |
13 |
Correct |
1 ms |
216 KB |
Output is correct |
14 |
Correct |
0 ms |
212 KB |
Output is correct |
15 |
Correct |
1 ms |
340 KB |
Output is correct |
16 |
Correct |
1 ms |
344 KB |
Output is correct |
17 |
Correct |
1 ms |
340 KB |
Output is correct |
18 |
Correct |
1 ms |
340 KB |
Output is correct |
19 |
Correct |
1 ms |
340 KB |
Output is correct |
20 |
Correct |
1 ms |
340 KB |
Output is correct |
21 |
Correct |
1 ms |
340 KB |
Output is correct |
22 |
Correct |
1 ms |
340 KB |
Output is correct |
23 |
Correct |
1 ms |
340 KB |
Output is correct |
24 |
Correct |
1 ms |
340 KB |
Output is correct |
25 |
Correct |
1 ms |
340 KB |
Output is correct |
26 |
Correct |
1 ms |
340 KB |
Output is correct |
27 |
Correct |
1 ms |
340 KB |
Output is correct |
28 |
Correct |
1 ms |
340 KB |
Output is correct |
29 |
Correct |
1 ms |
340 KB |
Output is correct |
30 |
Correct |
0 ms |
212 KB |
Output is correct |
31 |
Correct |
105 ms |
12032 KB |
Output is correct |
32 |
Correct |
68 ms |
12064 KB |
Output is correct |
33 |
Correct |
92 ms |
12032 KB |
Output is correct |
34 |
Correct |
68 ms |
12056 KB |
Output is correct |
35 |
Correct |
86 ms |
12104 KB |
Output is correct |
36 |
Correct |
67 ms |
12016 KB |
Output is correct |
37 |
Correct |
92 ms |
11984 KB |
Output is correct |
38 |
Correct |
71 ms |
12072 KB |
Output is correct |
39 |
Correct |
69 ms |
11488 KB |
Output is correct |
40 |
Correct |
78 ms |
12020 KB |
Output is correct |
41 |
Correct |
58 ms |
12112 KB |
Output is correct |
42 |
Correct |
1 ms |
212 KB |
Output is correct |
43 |
Correct |
79 ms |
12024 KB |
Output is correct |
44 |
Correct |
162 ms |
11468 KB |
Output is correct |
45 |
Correct |
75 ms |
11448 KB |
Output is correct |
46 |
Correct |
69 ms |
11996 KB |
Output is correct |
47 |
Correct |
148 ms |
11136 KB |
Output is correct |
48 |
Correct |
65 ms |
11364 KB |
Output is correct |
49 |
Correct |
77 ms |
11980 KB |
Output is correct |
50 |
Correct |
147 ms |
11216 KB |
Output is correct |
51 |
Correct |
62 ms |
11468 KB |
Output is correct |
52 |
Correct |
71 ms |
12052 KB |
Output is correct |
53 |
Correct |
169 ms |
11084 KB |
Output is correct |
54 |
Correct |
63 ms |
11460 KB |
Output is correct |
55 |
Correct |
80 ms |
12088 KB |
Output is correct |
56 |
Correct |
66 ms |
12092 KB |
Output is correct |
57 |
Correct |
60 ms |
12068 KB |
Output is correct |
58 |
Correct |
0 ms |
212 KB |
Output is correct |