# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
211749 |
2020-03-21T06:54:10 Z |
VEGAnn |
Drvca (COCI19_drvca) |
C++14 |
|
76 ms |
4396 KB |
#include <bits/stdc++.h>
#define PB push_back
#define sz(x) ((int)x.size())
using namespace std;
const int N = 100100;
vector<int> vc, vec;
map<int, int> mp;
int n, a[N], pre[N], net[N], dif, lst;
bool mrk[N];
void check(){
if (sz(mp) < 2){
vc.clear();
vec.clear();
for (int i = 0; i < n; i++)
if (mrk[i])
vc.PB(a[i]);
else vec.PB(a[i]);
cout << sz(vc) << '\n';
for (int cr : vc)
cout << cr << " "; cout << '\n';
cout << sz(vec) << '\n';
for (int cr : vec)
cout << cr << " "; cout << '\n';
exit(0);
}
}
void calc(){
int pr = -1;
mp.clear();
for (int i = 0; i < n; i++){
if (mrk[i]) continue;
pre[i] = pr;
if (pr >= 0)
mp[a[i] - a[pr]]++;
pr = i;
}
pr = n;
for (int i = n - 1; i >= 0; i--){
if (mrk[i]) continue;
net[i] = pr;
pr = i;
}
check();
for (int pt = 0; pt < n; ){
if (mrk[pt]) {
pt++;
continue;
}
int cp = pt;
while (cp < n && dif + lst != a[cp])
cp++;
if (cp == n) break;
int pr = pre[cp];
int nt = net[cp];
if (pr >= 0){
int def = a[cp] - a[pr];
mp[def]--;
if (mp[def] == 0)
mp.erase(mp.find(def));
net[pr] = nt;
}
if (nt < n){
int def = a[nt] - a[cp];
mp[def]--;
if (mp[def] == 0)
mp.erase(mp.find(def));
if (pr >= 0)
mp[a[nt] - a[pr]]++;
pre[nt] = pr;
}
mrk[cp] = 1;
lst += dif;
check();
pt = cp + 1;
}
}
int main(){
ios_base::sync_with_stdio(0); cin.tie(0);
cin >> n;
for (int i = 0; i < n; i++)
cin >> a[i];
sort(a, a + n);
if (n == 2){
cout << "1\n" << a[0];
cout << "\n1\n" << a[1];
return 0;
}
fill(mrk, mrk + n, 0);
mrk[0] = mrk[1] = 1;
dif = a[1] - a[0];
lst = a[1];
calc();
fill(mrk, mrk + n, 0);
mrk[0] = mrk[2] = 1;
dif = a[2] - a[0];
lst = a[2];
calc();
fill(mrk, mrk + n, 0);
mrk[1] = mrk[2] = 1;
dif = a[2] - a[1];
lst = a[2];
calc();
cout << -1;
return 0;
}
Compilation message
drvca.cpp: In function 'void check()':
drvca.cpp:22:9: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
for (int cr : vc)
^~~
drvca.cpp:23:32: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
cout << cr << " "; cout << '\n';
^~~~
drvca.cpp:26:9: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
for (int cr : vec)
^~~
drvca.cpp:27:32: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
cout << cr << " "; cout << '\n';
^~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
512 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
4 |
Correct |
4 ms |
384 KB |
Output is correct |
5 |
Correct |
5 ms |
384 KB |
Output is correct |
6 |
Correct |
5 ms |
384 KB |
Output is correct |
7 |
Correct |
5 ms |
384 KB |
Output is correct |
8 |
Correct |
4 ms |
384 KB |
Output is correct |
9 |
Correct |
5 ms |
384 KB |
Output is correct |
10 |
Correct |
5 ms |
384 KB |
Output is correct |
11 |
Correct |
5 ms |
384 KB |
Output is correct |
12 |
Correct |
5 ms |
384 KB |
Output is correct |
13 |
Correct |
5 ms |
384 KB |
Output is correct |
14 |
Correct |
5 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
512 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
4 |
Correct |
4 ms |
384 KB |
Output is correct |
5 |
Correct |
5 ms |
384 KB |
Output is correct |
6 |
Correct |
5 ms |
384 KB |
Output is correct |
7 |
Correct |
5 ms |
384 KB |
Output is correct |
8 |
Correct |
4 ms |
384 KB |
Output is correct |
9 |
Correct |
5 ms |
384 KB |
Output is correct |
10 |
Correct |
5 ms |
384 KB |
Output is correct |
11 |
Correct |
5 ms |
384 KB |
Output is correct |
12 |
Correct |
5 ms |
384 KB |
Output is correct |
13 |
Correct |
5 ms |
384 KB |
Output is correct |
14 |
Correct |
5 ms |
384 KB |
Output is correct |
15 |
Correct |
5 ms |
384 KB |
Output is correct |
16 |
Correct |
5 ms |
384 KB |
Output is correct |
17 |
Correct |
5 ms |
384 KB |
Output is correct |
18 |
Correct |
5 ms |
384 KB |
Output is correct |
19 |
Correct |
5 ms |
384 KB |
Output is correct |
20 |
Correct |
5 ms |
384 KB |
Output is correct |
21 |
Correct |
5 ms |
384 KB |
Output is correct |
22 |
Correct |
5 ms |
384 KB |
Output is correct |
23 |
Correct |
5 ms |
384 KB |
Output is correct |
24 |
Correct |
5 ms |
384 KB |
Output is correct |
25 |
Correct |
5 ms |
384 KB |
Output is correct |
26 |
Correct |
5 ms |
384 KB |
Output is correct |
27 |
Correct |
5 ms |
384 KB |
Output is correct |
28 |
Correct |
5 ms |
384 KB |
Output is correct |
29 |
Correct |
5 ms |
384 KB |
Output is correct |
30 |
Correct |
5 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
56 ms |
4200 KB |
Output is correct |
2 |
Correct |
46 ms |
4084 KB |
Output is correct |
3 |
Correct |
40 ms |
4216 KB |
Output is correct |
4 |
Correct |
39 ms |
4084 KB |
Output is correct |
5 |
Correct |
59 ms |
4212 KB |
Output is correct |
6 |
Correct |
40 ms |
4084 KB |
Output is correct |
7 |
Correct |
60 ms |
4252 KB |
Output is correct |
8 |
Correct |
42 ms |
3956 KB |
Output is correct |
9 |
Correct |
35 ms |
3572 KB |
Output is correct |
10 |
Correct |
46 ms |
4396 KB |
Output is correct |
11 |
Correct |
34 ms |
4084 KB |
Output is correct |
12 |
Correct |
5 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
512 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
4 |
Correct |
4 ms |
384 KB |
Output is correct |
5 |
Correct |
5 ms |
384 KB |
Output is correct |
6 |
Correct |
5 ms |
384 KB |
Output is correct |
7 |
Correct |
5 ms |
384 KB |
Output is correct |
8 |
Correct |
4 ms |
384 KB |
Output is correct |
9 |
Correct |
5 ms |
384 KB |
Output is correct |
10 |
Correct |
5 ms |
384 KB |
Output is correct |
11 |
Correct |
5 ms |
384 KB |
Output is correct |
12 |
Correct |
5 ms |
384 KB |
Output is correct |
13 |
Correct |
5 ms |
384 KB |
Output is correct |
14 |
Correct |
5 ms |
384 KB |
Output is correct |
15 |
Correct |
5 ms |
384 KB |
Output is correct |
16 |
Correct |
5 ms |
384 KB |
Output is correct |
17 |
Correct |
5 ms |
384 KB |
Output is correct |
18 |
Correct |
5 ms |
384 KB |
Output is correct |
19 |
Correct |
5 ms |
384 KB |
Output is correct |
20 |
Correct |
5 ms |
384 KB |
Output is correct |
21 |
Correct |
5 ms |
384 KB |
Output is correct |
22 |
Correct |
5 ms |
384 KB |
Output is correct |
23 |
Correct |
5 ms |
384 KB |
Output is correct |
24 |
Correct |
5 ms |
384 KB |
Output is correct |
25 |
Correct |
5 ms |
384 KB |
Output is correct |
26 |
Correct |
5 ms |
384 KB |
Output is correct |
27 |
Correct |
5 ms |
384 KB |
Output is correct |
28 |
Correct |
5 ms |
384 KB |
Output is correct |
29 |
Correct |
5 ms |
384 KB |
Output is correct |
30 |
Correct |
5 ms |
384 KB |
Output is correct |
31 |
Correct |
56 ms |
4200 KB |
Output is correct |
32 |
Correct |
46 ms |
4084 KB |
Output is correct |
33 |
Correct |
40 ms |
4216 KB |
Output is correct |
34 |
Correct |
39 ms |
4084 KB |
Output is correct |
35 |
Correct |
59 ms |
4212 KB |
Output is correct |
36 |
Correct |
40 ms |
4084 KB |
Output is correct |
37 |
Correct |
60 ms |
4252 KB |
Output is correct |
38 |
Correct |
42 ms |
3956 KB |
Output is correct |
39 |
Correct |
35 ms |
3572 KB |
Output is correct |
40 |
Correct |
46 ms |
4396 KB |
Output is correct |
41 |
Correct |
34 ms |
4084 KB |
Output is correct |
42 |
Correct |
5 ms |
384 KB |
Output is correct |
43 |
Correct |
56 ms |
4276 KB |
Output is correct |
44 |
Correct |
76 ms |
2808 KB |
Output is correct |
45 |
Correct |
35 ms |
3568 KB |
Output is correct |
46 |
Correct |
40 ms |
4084 KB |
Output is correct |
47 |
Correct |
36 ms |
2552 KB |
Output is correct |
48 |
Correct |
34 ms |
3568 KB |
Output is correct |
49 |
Correct |
58 ms |
4348 KB |
Output is correct |
50 |
Correct |
31 ms |
2680 KB |
Output is correct |
51 |
Correct |
35 ms |
3568 KB |
Output is correct |
52 |
Correct |
37 ms |
4084 KB |
Output is correct |
53 |
Correct |
37 ms |
2552 KB |
Output is correct |
54 |
Correct |
35 ms |
3568 KB |
Output is correct |
55 |
Correct |
39 ms |
4084 KB |
Output is correct |
56 |
Correct |
32 ms |
4084 KB |
Output is correct |
57 |
Correct |
30 ms |
4084 KB |
Output is correct |
58 |
Correct |
5 ms |
384 KB |
Output is correct |