# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
201393 | 2020-02-10T11:10:17 Z | Shelby | Drvca (COCI19_drvca) | C++11 | 47 ms | 3688 KB |
#include <bits/stdc++.h> #define MAXN 100005 using namespace std; int a[MAXN],n; bool f[MAXN]; bool check(int start,int d) { int now=a[start]; vector<int> v; f[start]=true; for(int i=start;i<n;i++) { if( (now+d)==a[i] ) { f[i]=true; now=a[i]; } } for(int i=0;i<n;i++) { if(f[i]==false) v.push_back(a[i]); } if(v.size()<=1) return true; else { int tmp=v[1]-v[0]; for(int i=1;i<v.size();i++) { if( (v[i]-v[i-1])!=tmp ) return false; } return true; } } void restart() { for(int i=0;i<n;i++) f[i]=false; } void ispisi() { vector<int> gr1; vector<int> gr2; for(int i=0;i<n;i++) { if(f[i]==true) gr2.push_back(a[i]); if(f[i]==false) gr1.push_back(a[i]); } printf("%d\n",gr1.size()); for(int i=0;i<gr1.size();i++) printf("%d ",gr1[i]); printf("\n"); printf("%d\n",gr2.size()); for(int i=0;i<gr2.size();i++) printf("%d ",gr2[i]); } int main() { int i,d; scanf("%d",&n); for(i=0;i<n;i++) scanf("%d",&a[i]); sort(a,a+n); d=a[2]-a[1]; restart(); if(check(1,d)) ispisi(); else { restart(); d=a[2]-a[0]; if(check(0,d)) ispisi(); else { restart(); d=a[1]-a[0]; if(check(0,d)) ispisi(); else printf("-1\n"); } } return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 376 KB | Output is correct |
2 | Correct | 5 ms | 376 KB | Output is correct |
3 | Correct | 5 ms | 376 KB | Output is correct |
4 | Correct | 5 ms | 376 KB | Output is correct |
5 | Correct | 5 ms | 404 KB | Output is correct |
6 | Correct | 5 ms | 376 KB | Output is correct |
7 | Correct | 5 ms | 376 KB | Output is correct |
8 | Correct | 5 ms | 376 KB | Output is correct |
9 | Incorrect | 5 ms | 376 KB | Output isn't correct |
10 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 376 KB | Output is correct |
2 | Correct | 5 ms | 376 KB | Output is correct |
3 | Correct | 5 ms | 376 KB | Output is correct |
4 | Correct | 5 ms | 376 KB | Output is correct |
5 | Correct | 5 ms | 404 KB | Output is correct |
6 | Correct | 5 ms | 376 KB | Output is correct |
7 | Correct | 5 ms | 376 KB | Output is correct |
8 | Correct | 5 ms | 376 KB | Output is correct |
9 | Incorrect | 5 ms | 376 KB | Output isn't correct |
10 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 45 ms | 3540 KB | Output is correct |
2 | Correct | 46 ms | 3436 KB | Output is correct |
3 | Correct | 47 ms | 3688 KB | Output is correct |
4 | Correct | 45 ms | 3436 KB | Output is correct |
5 | Correct | 45 ms | 3440 KB | Output is correct |
6 | Correct | 46 ms | 3568 KB | Output is correct |
7 | Correct | 43 ms | 3440 KB | Output is correct |
8 | Correct | 45 ms | 3568 KB | Output is correct |
9 | Incorrect | 33 ms | 2220 KB | Output isn't correct |
10 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 376 KB | Output is correct |
2 | Correct | 5 ms | 376 KB | Output is correct |
3 | Correct | 5 ms | 376 KB | Output is correct |
4 | Correct | 5 ms | 376 KB | Output is correct |
5 | Correct | 5 ms | 404 KB | Output is correct |
6 | Correct | 5 ms | 376 KB | Output is correct |
7 | Correct | 5 ms | 376 KB | Output is correct |
8 | Correct | 5 ms | 376 KB | Output is correct |
9 | Incorrect | 5 ms | 376 KB | Output isn't correct |
10 | Halted | 0 ms | 0 KB | - |