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

#TimeUsernameProblemLanguageResultExecution timeMemory
811203pccDrvca (COCI19_drvca)C++14
0 / 110
127 ms7408 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; map<ll,ll> mp; for(int i = 0;i<n;i++)st.insert(arr[i]); for(auto it = ++st.begin();it != st.end();it++){ mp[*it-*prev(it)]++; } while(st.find(now) != st.end()){ v.push_back(now); auto it = st.find(now); now+= d; ///cout<<start<<' '<<d<<' '<<now<<":";for(auto &i:mp)cout<<i.fs<<','<<i.sc<<' ';cout<<'\n'; //for(auto &i:st)cout<<i<<' ';cout<<'\n'; if(it != st.begin()){ ll dd = *it-*prev(it); mp[dd]--; if(mp[dd] == 0)mp.erase(dd); } if(it != --st.end()){ ll dd = *next(it)-*it; mp[dd]--; if(mp[dd] == 0)mp.erase(dd); } if(it != st.begin()&&it != st.end()){ ll dd = *next(it)-*prev(it); mp[dd]++; } st.erase(it); if(mp.size() == 1){ if(st.empty()){ st.insert(v.back()); v.pop_back(); } cout<<v.size()<<'\n'; for(auto &i:v)cout<<i<<' ';cout<<'\n'; cout<<st.size()<<'\n'; for(auto &i:st)cout<<i<<' ';cout<<'\n'; exit(0); } } return; } 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); if(n<=2){ cout<<"1\n"<<arr[0]<<'\n'<<"1\n"<<arr[1]<<'\n'; exit(0); } check(arr[0],arr[1]-arr[0]); 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:51:4: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   51 |    for(auto &i:v)cout<<i<<' ';cout<<'\n';
      |    ^~~
drvca.cpp:51:31: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   51 |    for(auto &i:v)cout<<i<<' ';cout<<'\n';
      |                               ^~~~
drvca.cpp:53:4: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   53 |    for(auto &i:st)cout<<i<<' ';cout<<'\n';
      |    ^~~
drvca.cpp:53:32: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   53 |    for(auto &i:st)cout<<i<<' ';cout<<'\n';
      |                                ^~~~
drvca.cpp: At global scope:
drvca.cpp:60:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   60 | 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...