(UPD: 2024-12-04 14:48 UTC) Judge is not working due to Cloudflare incident. (URL) We can do nothing about it, sorry. After the incident is resolved, we will grade all submissions.

Submission #1010421

#TimeUsernameProblemLanguageResultExecution timeMemory
101042112345678Drvca (COCI19_drvca)C++17
0 / 110
19 ms2776 KiB
#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 (y.empty()||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 (stderr)

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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...