(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 #811167

#TimeUsernameProblemLanguageResultExecution timeMemory
811167pccDrvca (COCI19_drvca)C++14
0 / 110
59 ms7712 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define int ll #define pll pair<ll,ll> #define pii pair<int,int> #define fs first #define sc second const int mxn = 1e5+10; int n; ll arr[mxn]; void check(ll start,ll d){ ll now = start; multiset<ll> st; vector<ll> v; for(int i = 0;i<n;i++)st.insert(arr[i]); while(st.find(now) != st.end()){ st.erase(st.find(now)); v.push_back(now); now += d; } vector<ll> tmp; for(auto &i:st)tmp.push_back(i); if(tmp.empty()){ cout<<v.size()-1<<'\n'; for(int i = 0;i<v.size()-1;i++)cout<<v[i]<<' '; cout<<"\n1\n"<<v.back()<<'\n'; exit(0); } else if(tmp.size()<=2){ cout<<v.size()<<'\n'; for(auto &i:v)cout<<i<<' ';cout<<'\n'; cout<<tmp.size()<<'\n'; for(auto &i:tmp)cout<<i<<' ';cout<<'\n'; exit(0); } d = tmp[1]-tmp[0]; for(int i = 1;i<tmp.size();i++){ if(tmp[i]-tmp[i-1] != d)return; } cout<<v.size()<<'\n'; for(auto &i:v)cout<<i<<' ';cout<<'\n'; cout<<tmp.size()<<'\n'; for(auto &i:tmp)cout<<i<<' ';cout<<'\n'; exit(0); } main(){ ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); cin>>n; for(int i = 0;i<n;i++)cin>>arr[i]; sort(arr,arr+n); check(arr[0],arr[1]-arr[0]); if(n>2){ check(arr[0],arr[2]-arr[0]); check(arr[1],arr[2]-arr[1]); } cout<<"-1"; return 0; }

Compilation message (stderr)

drvca.cpp: In function 'void check(long long int, long long int)':
drvca.cpp:29:18: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |   for(int i = 0;i<v.size()-1;i++)cout<<v[i]<<' ';
      |                 ~^~~~~~~~~~~
drvca.cpp:35:3: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   35 |   for(auto &i:v)cout<<i<<' ';cout<<'\n';
      |   ^~~
drvca.cpp:35:30: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   35 |   for(auto &i:v)cout<<i<<' ';cout<<'\n';
      |                              ^~~~
drvca.cpp:37:3: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   37 |   for(auto &i:tmp)cout<<i<<' ';cout<<'\n';
      |   ^~~
drvca.cpp:37:32: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   37 |   for(auto &i:tmp)cout<<i<<' ';cout<<'\n';
      |                                ^~~~
drvca.cpp:41:17: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   41 |  for(int i = 1;i<tmp.size();i++){
      |                ~^~~~~~~~~~~
drvca.cpp:45:2: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   45 |  for(auto &i:v)cout<<i<<' ';cout<<'\n';
      |  ^~~
drvca.cpp:45:29: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   45 |  for(auto &i:v)cout<<i<<' ';cout<<'\n';
      |                             ^~~~
drvca.cpp:47:2: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   47 |  for(auto &i:tmp)cout<<i<<' ';cout<<'\n';
      |  ^~~
drvca.cpp:47:31: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   47 |  for(auto &i:tmp)cout<<i<<' ';cout<<'\n';
      |                               ^~~~
drvca.cpp: At global scope:
drvca.cpp:51:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   51 | main(){
      | ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...