Submission #1010420

# Submission time Handle Problem Language Result Execution time Memory
1010420 2024-06-29T05:48:28 Z 12345678 Drvca (COCI19_drvca) C++17
0 / 110
18 ms 2776 KB
#include <bits/stdc++.h>

using namespace std;

const int nx=1e5+5;

int n, tmp;
vector<int> v, x, y;

int solve(int a, int b)
{
    x.clear();
    y.clear();
    vector<int> vs(n);
    x.push_back(v[a]);
    x.push_back(v[b]);
    vs[a]=vs[b]=1;
    int g=v[b]-v[a], p=v[b];
    for (int i=b+1; i<n; i++) if (v[i]-p==g) x.push_back(v[i]), vs[i]=1;
    for (int i=0; i<n;i ++) if (!vs[i]) y.push_back(v[i]);
    set<int> s;
    for (int i=1; i<y.size(); i++) s.insert(y[i]-y[i-1]);
    return (s.size()==1);
}

void show()
{
    if (y.empty()) y.push_back(x.back()), x.pop_back();
    cout<<x.size()<<'\n';
    for (auto t:x) cout<<t<<' ';
    cout<<'\n';
    cout<<y.size()<<'\n';
    for (auto t:y) cout<<t<<' ';
}

int main()
{
    cin.tie(NULL)->sync_with_stdio(false);
    cin>>n;
    for (int i=1; i<=n; i++) cin>>tmp, v.push_back(tmp);
    sort(v.begin(), v.end());
    if (solve(0, 1)) show();
    else if (solve(0, 2)) show();
    else if (solve(1, 2)) show();
    else cout<<-1;
}

Compilation message

drvca.cpp: In function 'int solve(int, int)':
drvca.cpp:22:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |     for (int i=1; i<y.size(); i++) s.insert(y[i]-y[i-1]);
      |                   ~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 18 ms 2776 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -