# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
448812 |
2021-08-01T19:13:07 Z |
Antekb |
Drvca (COCI19_drvca) |
C++14 |
|
84 ms |
3568 KB |
#include<bits/stdc++.h>
using namespace std;
bool czy(vector<int> V){
//for(int i=0; i<V.size(); i++)cout<<V[i]<<" ";
// cout<<"\n";
if(V.size()==0)return 0;
if(V.size()==1)return 1;
int d=V[1]-V[0];
for(int i=1; i<V.size(); i++)if(V[i]-V[i-1]!=d)return 0;
return 1;
}
void out(vector<int> V){
cout<<V.size()<<"\n";
for(int i:V)cout<<i<<" ";
cout<<"\n";
}
vector<int> V;
bool roz(int a, int d){
vector<int> A, B;
for(int i:V){
if(i==a)A.push_back(i), a+=d;
else B.push_back(i);
}
if(B.size()==0){
B.push_back(A.back());
A.pop_back();
}
if(czy(B)){
out(A);
out(B);
return 1;
}
B.push_back(A.back());
A.pop_back();
sort(B.begin(), B.end());
a=B.back();
d=-B[B.size()-2]+B.back();
int wsk=B.size()-1;
while(wsk>=0){
if(B[wsk]==a){
wsk--;
a-=d;
}
else if(A.size() && A.back()==a){
B.push_back(A.back());
A.pop_back();
a-=d;
}
else{
return 0;
}
}
if(wsk==-1){
sort(B.begin(), B.end());
out(A);
out(B);
return 1;
}
return 0;
}
int main(){
int n;
cin>>n;
V.resize(n);
for(int &i:V)cin>>i;
sort(V.begin(), V.end());
if(roz(V[0], V[1]-V[0]))return 0;
if(n==2){
//cout<<1<<"\n"<<V[0]<<"\n"<<1<<"\n"<<V[1]<<"\n";
return 0;
}
if(roz(V[0], V[2]-V[0]))return 0;
if(roz(V[1], V[2]-V[1]))return 0;
cout<<-1;
return 0;
}
Compilation message
drvca.cpp: In function 'bool czy(std::vector<int>)':
drvca.cpp:9:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
9 | for(int i=1; i<V.size(); i++)if(V[i]-V[i-1]!=d)return 0;
| ~^~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
292 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
0 ms |
204 KB |
Output is correct |
9 |
Correct |
0 ms |
296 KB |
Output is correct |
10 |
Correct |
1 ms |
204 KB |
Output is correct |
11 |
Correct |
1 ms |
204 KB |
Output is correct |
12 |
Correct |
1 ms |
204 KB |
Output is correct |
13 |
Correct |
1 ms |
204 KB |
Output is correct |
14 |
Correct |
0 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
292 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
0 ms |
204 KB |
Output is correct |
9 |
Correct |
0 ms |
296 KB |
Output is correct |
10 |
Correct |
1 ms |
204 KB |
Output is correct |
11 |
Correct |
1 ms |
204 KB |
Output is correct |
12 |
Correct |
1 ms |
204 KB |
Output is correct |
13 |
Correct |
1 ms |
204 KB |
Output is correct |
14 |
Correct |
0 ms |
204 KB |
Output is correct |
15 |
Correct |
1 ms |
204 KB |
Output is correct |
16 |
Correct |
1 ms |
204 KB |
Output is correct |
17 |
Correct |
1 ms |
204 KB |
Output is correct |
18 |
Correct |
1 ms |
204 KB |
Output is correct |
19 |
Correct |
1 ms |
292 KB |
Output is correct |
20 |
Correct |
1 ms |
204 KB |
Output is correct |
21 |
Correct |
1 ms |
204 KB |
Output is correct |
22 |
Correct |
1 ms |
204 KB |
Output is correct |
23 |
Correct |
1 ms |
204 KB |
Output is correct |
24 |
Correct |
1 ms |
292 KB |
Output is correct |
25 |
Correct |
1 ms |
204 KB |
Output is correct |
26 |
Correct |
1 ms |
204 KB |
Output is correct |
27 |
Correct |
1 ms |
204 KB |
Output is correct |
28 |
Correct |
1 ms |
204 KB |
Output is correct |
29 |
Correct |
1 ms |
204 KB |
Output is correct |
30 |
Correct |
1 ms |
288 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
64 ms |
3184 KB |
Output is correct |
2 |
Correct |
70 ms |
3104 KB |
Output is correct |
3 |
Correct |
66 ms |
3136 KB |
Output is correct |
4 |
Correct |
69 ms |
3148 KB |
Output is correct |
5 |
Correct |
64 ms |
3220 KB |
Output is correct |
6 |
Correct |
65 ms |
3164 KB |
Output is correct |
7 |
Correct |
63 ms |
3236 KB |
Output is correct |
8 |
Correct |
64 ms |
3248 KB |
Output is correct |
9 |
Correct |
56 ms |
2576 KB |
Output is correct |
10 |
Correct |
84 ms |
3156 KB |
Output is correct |
11 |
Correct |
57 ms |
3484 KB |
Output is correct |
12 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
292 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
0 ms |
204 KB |
Output is correct |
9 |
Correct |
0 ms |
296 KB |
Output is correct |
10 |
Correct |
1 ms |
204 KB |
Output is correct |
11 |
Correct |
1 ms |
204 KB |
Output is correct |
12 |
Correct |
1 ms |
204 KB |
Output is correct |
13 |
Correct |
1 ms |
204 KB |
Output is correct |
14 |
Correct |
0 ms |
204 KB |
Output is correct |
15 |
Correct |
1 ms |
204 KB |
Output is correct |
16 |
Correct |
1 ms |
204 KB |
Output is correct |
17 |
Correct |
1 ms |
204 KB |
Output is correct |
18 |
Correct |
1 ms |
204 KB |
Output is correct |
19 |
Correct |
1 ms |
292 KB |
Output is correct |
20 |
Correct |
1 ms |
204 KB |
Output is correct |
21 |
Correct |
1 ms |
204 KB |
Output is correct |
22 |
Correct |
1 ms |
204 KB |
Output is correct |
23 |
Correct |
1 ms |
204 KB |
Output is correct |
24 |
Correct |
1 ms |
292 KB |
Output is correct |
25 |
Correct |
1 ms |
204 KB |
Output is correct |
26 |
Correct |
1 ms |
204 KB |
Output is correct |
27 |
Correct |
1 ms |
204 KB |
Output is correct |
28 |
Correct |
1 ms |
204 KB |
Output is correct |
29 |
Correct |
1 ms |
204 KB |
Output is correct |
30 |
Correct |
1 ms |
288 KB |
Output is correct |
31 |
Correct |
64 ms |
3184 KB |
Output is correct |
32 |
Correct |
70 ms |
3104 KB |
Output is correct |
33 |
Correct |
66 ms |
3136 KB |
Output is correct |
34 |
Correct |
69 ms |
3148 KB |
Output is correct |
35 |
Correct |
64 ms |
3220 KB |
Output is correct |
36 |
Correct |
65 ms |
3164 KB |
Output is correct |
37 |
Correct |
63 ms |
3236 KB |
Output is correct |
38 |
Correct |
64 ms |
3248 KB |
Output is correct |
39 |
Correct |
56 ms |
2576 KB |
Output is correct |
40 |
Correct |
84 ms |
3156 KB |
Output is correct |
41 |
Correct |
57 ms |
3484 KB |
Output is correct |
42 |
Correct |
1 ms |
204 KB |
Output is correct |
43 |
Correct |
63 ms |
3216 KB |
Output is correct |
44 |
Correct |
66 ms |
2584 KB |
Output is correct |
45 |
Correct |
60 ms |
2880 KB |
Output is correct |
46 |
Correct |
64 ms |
3216 KB |
Output is correct |
47 |
Correct |
66 ms |
2512 KB |
Output is correct |
48 |
Correct |
61 ms |
2868 KB |
Output is correct |
49 |
Correct |
77 ms |
3088 KB |
Output is correct |
50 |
Correct |
75 ms |
2588 KB |
Output is correct |
51 |
Correct |
61 ms |
2892 KB |
Output is correct |
52 |
Correct |
65 ms |
3564 KB |
Output is correct |
53 |
Correct |
65 ms |
2488 KB |
Output is correct |
54 |
Correct |
59 ms |
2828 KB |
Output is correct |
55 |
Correct |
65 ms |
3132 KB |
Output is correct |
56 |
Correct |
58 ms |
3220 KB |
Output is correct |
57 |
Correct |
62 ms |
3568 KB |
Output is correct |
58 |
Correct |
0 ms |
204 KB |
Output is correct |