# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
765724 | 2023-06-25T04:07:16 Z | 1075508020060209tc | Drvca (COCI19_drvca) | C++14 | 43 ms | 4896 KB |
#include<bits/stdc++.h> using namespace std; #define int long long #define X first #define Y second int n; int ar[200005]; int tar[200005]; int sfok[200005]; int chk(vector<int>A){ for(int i=1;i<A.size();i++){ // cout<<A[i]-A[i-1]<<endl; if((A[i]-A[i-1])!=(A[1]-A[0]) ){ return 0; } } return 1; } vector<int>A;vector<int>B;int bok; void fot(int spl){ // cout<<"ft"; for(int i=spl;i<=n;i++){ B.push_back(i); } if(B.size()==0){ B.push_back(n); A.pop_back(); } cout<<A.size()<<endl; for(int i=0;i<A.size();i++){ cout<<ar[A[i]]<<" "; }cout<<endl; cout<<B.size()<<endl; for(int i=0;i<B.size();i++){ cout<<ar[B[i]]<<" "; } exit(0); } void ot(){ if(bok==0){return;} //cout<<"tyu"; int lstpl=A[A.size()-1]; if(lstpl==n){fot(n+1);} if(lstpl==n-1){ if(B.size()==0){ fot(n); } if(B.size()==1){ fot(n); } if(B.size()>=2){ if(ar[B[1]]-ar[B[0]]==ar[n]-ar[B[B.size()-1]]){ fot(n); }else{ return; } } return; } if(sfok[lstpl+1]==0){return;} if(B.size()==0){ fot(lstpl+1); return; } if(B.size()==1){ if(ar[lstpl+1]-ar[B[0]]==ar[n]-ar[n-1]){ fot(lstpl+1); } return; } if(ar[lstpl+1]-ar[B[B.size()-1]]==ar[n]-ar[n-1]&&ar[B[1]]-ar[B[0]]==ar[n]-ar[n-1]){ fot(lstpl+1); } } signed main(){ cin>>n; for(int i=1;i<=n;i++){ cin>>ar[i]; } if(n==2){ cout<<"1\n"; cout<<ar[1]<<endl; cout<<"1\n"; cout<<ar[2]<<endl;return 0; } sort(ar+1,ar+n+1); sfok[n]=1; for(int i=n-1;i>=1;i--){ if(ar[i]-ar[i+1]!=ar[n-1]-ar[n]){ break; } sfok[i]=1; } A.clear();B.clear();bok=1; A.push_back(1); A.push_back(2); //cout<<"hehe"; ot(); for(int i=3;i<=n;i++){ //cout<<i<<" "; if(ar[i]-ar[A[A.size()-1]]==ar[2]-ar[1]){ A.push_back(i); ot(); }else{ if(B.size()<=1){ B.push_back(i); continue; } if(ar[i]-ar[B.back()]!=ar[B[1]]-ar[B[0]]){ bok=0; } B.push_back(i); } } //cout<<"hihi"; A.clear();B.clear();bok=1; A.push_back(1); A.push_back(3); B.push_back(2); ot(); for(int i=4;i<=n;i++){ if(ar[i]-ar[A[A.size()-1]]==ar[3]-ar[1]){ A.push_back(i); ot(); }else{ if(B.size()==1){ B.push_back(i); continue; } if(ar[i]-ar[B.back()]!=ar[B[1]]-ar[B[0]]){ bok=0; } B.push_back(i); } } A.clear();B.clear();bok=1; B.push_back(1); A.push_back(2); A.push_back(3); ot(); for(int i=4;i<=n;i++){ if(ar[i]-ar[A[A.size()-1]]==ar[3]-ar[2]){ A.push_back(i); ot(); }else{ if(B.size()==1){ B.push_back(i); continue; } if(ar[i]-ar[B.back()]!=ar[B[1]]-ar[B[0]]){ bok=0; } B.push_back(i); } } cout<<-1<<endl; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 1 ms | 316 KB | Output is correct |
5 | Correct | 1 ms | 304 KB | Output is correct |
6 | Correct | 1 ms | 212 KB | Output is correct |
7 | Correct | 1 ms | 312 KB | Output is correct |
8 | Correct | 0 ms | 212 KB | Output is correct |
9 | Correct | 0 ms | 212 KB | Output is correct |
10 | Correct | 0 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 | 0 ms | 212 KB | Output is correct |
14 | 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 | 1 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 1 ms | 316 KB | Output is correct |
5 | Correct | 1 ms | 304 KB | Output is correct |
6 | Correct | 1 ms | 212 KB | Output is correct |
7 | Correct | 1 ms | 312 KB | Output is correct |
8 | Correct | 0 ms | 212 KB | Output is correct |
9 | Correct | 0 ms | 212 KB | Output is correct |
10 | Correct | 0 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 | 0 ms | 212 KB | Output is correct |
14 | Correct | 1 ms | 212 KB | Output is correct |
15 | Correct | 1 ms | 212 KB | Output is correct |
16 | Correct | 1 ms | 212 KB | Output is correct |
17 | Correct | 1 ms | 312 KB | Output is correct |
18 | Correct | 1 ms | 212 KB | Output is correct |
19 | Correct | 1 ms | 212 KB | Output is correct |
20 | Correct | 1 ms | 212 KB | Output is correct |
21 | Correct | 1 ms | 324 KB | Output is correct |
22 | Correct | 1 ms | 212 KB | Output is correct |
23 | Correct | 1 ms | 212 KB | Output is correct |
24 | Correct | 1 ms | 212 KB | Output is correct |
25 | Correct | 1 ms | 212 KB | Output is correct |
26 | Correct | 1 ms | 304 KB | Output is correct |
27 | Correct | 1 ms | 212 KB | Output is correct |
28 | Correct | 1 ms | 212 KB | Output is correct |
29 | Correct | 1 ms | 212 KB | Output is correct |
30 | Correct | 1 ms | 212 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 41 ms | 4028 KB | Output is correct |
2 | Correct | 41 ms | 4240 KB | Output is correct |
3 | Correct | 41 ms | 3976 KB | Output is correct |
4 | Correct | 42 ms | 4344 KB | Output is correct |
5 | Correct | 41 ms | 4004 KB | Output is correct |
6 | Correct | 41 ms | 4348 KB | Output is correct |
7 | Correct | 41 ms | 4032 KB | Output is correct |
8 | Correct | 42 ms | 4296 KB | Output is correct |
9 | Correct | 35 ms | 3412 KB | Output is correct |
10 | Correct | 41 ms | 4168 KB | Output is correct |
11 | Correct | 36 ms | 4672 KB | Output is correct |
12 | 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 | 1 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 1 ms | 316 KB | Output is correct |
5 | Correct | 1 ms | 304 KB | Output is correct |
6 | Correct | 1 ms | 212 KB | Output is correct |
7 | Correct | 1 ms | 312 KB | Output is correct |
8 | Correct | 0 ms | 212 KB | Output is correct |
9 | Correct | 0 ms | 212 KB | Output is correct |
10 | Correct | 0 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 | 0 ms | 212 KB | Output is correct |
14 | Correct | 1 ms | 212 KB | Output is correct |
15 | Correct | 1 ms | 212 KB | Output is correct |
16 | Correct | 1 ms | 212 KB | Output is correct |
17 | Correct | 1 ms | 312 KB | Output is correct |
18 | Correct | 1 ms | 212 KB | Output is correct |
19 | Correct | 1 ms | 212 KB | Output is correct |
20 | Correct | 1 ms | 212 KB | Output is correct |
21 | Correct | 1 ms | 324 KB | Output is correct |
22 | Correct | 1 ms | 212 KB | Output is correct |
23 | Correct | 1 ms | 212 KB | Output is correct |
24 | Correct | 1 ms | 212 KB | Output is correct |
25 | Correct | 1 ms | 212 KB | Output is correct |
26 | Correct | 1 ms | 304 KB | Output is correct |
27 | Correct | 1 ms | 212 KB | Output is correct |
28 | Correct | 1 ms | 212 KB | Output is correct |
29 | Correct | 1 ms | 212 KB | Output is correct |
30 | Correct | 1 ms | 212 KB | Output is correct |
31 | Correct | 41 ms | 4028 KB | Output is correct |
32 | Correct | 41 ms | 4240 KB | Output is correct |
33 | Correct | 41 ms | 3976 KB | Output is correct |
34 | Correct | 42 ms | 4344 KB | Output is correct |
35 | Correct | 41 ms | 4004 KB | Output is correct |
36 | Correct | 41 ms | 4348 KB | Output is correct |
37 | Correct | 41 ms | 4032 KB | Output is correct |
38 | Correct | 42 ms | 4296 KB | Output is correct |
39 | Correct | 35 ms | 3412 KB | Output is correct |
40 | Correct | 41 ms | 4168 KB | Output is correct |
41 | Correct | 36 ms | 4672 KB | Output is correct |
42 | Correct | 0 ms | 212 KB | Output is correct |
43 | Correct | 43 ms | 3912 KB | Output is correct |
44 | Correct | 35 ms | 3728 KB | Output is correct |
45 | Correct | 35 ms | 3788 KB | Output is correct |
46 | Correct | 41 ms | 4212 KB | Output is correct |
47 | Correct | 35 ms | 3820 KB | Output is correct |
48 | Correct | 40 ms | 3652 KB | Output is correct |
49 | Correct | 41 ms | 3932 KB | Output is correct |
50 | Correct | 35 ms | 3272 KB | Output is correct |
51 | Correct | 35 ms | 3908 KB | Output is correct |
52 | Correct | 43 ms | 4300 KB | Output is correct |
53 | Correct | 37 ms | 3876 KB | Output is correct |
54 | Correct | 42 ms | 3708 KB | Output is correct |
55 | Correct | 43 ms | 4164 KB | Output is correct |
56 | Correct | 37 ms | 4172 KB | Output is correct |
57 | Correct | 39 ms | 4896 KB | Output is correct |
58 | Correct | 0 ms | 212 KB | Output is correct |