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

#TimeUsernameProblemLanguageResultExecution timeMemory
866466vjudge1Drvca (COCI19_drvca)C++17
0 / 110
1085 ms4316 KiB
#pragma GCC optimize("unroll-loops,Ofast,O3") #include <bits/stdc++.h> #define pb push_back #define mp make_pair #define spc << " " << #define endl "\n" #define all(x) x.begin(), x.end() #define int long long #define ii pair<int,int> #define vi vector<int> #define vii vector<ii> #define st first #define nd second #define inf 1000000009 #define MOD 1000000007 #define lim 200005 using namespace std; void solve(){ int n; cin >> n; int arr[n+1]; for(int i=1; i<=n; i++) cin >> arr[i]; sort(arr+1, arr+n+1); int took[n+1]; vi vec; for(int sec=2; sec<=n; sec++){ vec.clear(); vec.pb(arr[1]); vec.pb(arr[sec]); memset(took, 0, sizeof(took)); took[1] = took[sec] = 1; int next = 2*arr[sec] - arr[1]; int ptr=sec, woo=sec; while(ptr<n){ ptr++; if(arr[ptr]<next) continue; else if(arr[ptr]==next){ vec.pb(arr[ptr]); took[ptr]=1; woo = ptr; next = next + arr[sec] - arr[1]; } else{ break; } } int flag=0; jump: int dif=-1, las=0; for(int i=1; i<=n; i++){ if(took[i]) continue; if(las==0){ las = arr[i]; continue; } if(dif==-1){ dif = arr[i]-las; las = arr[i]; continue; } if(arr[i] != las+dif){ flag++; break; } las = arr[i]; } if(flag==1){ took[woo] = 0; goto jump; } else if(flag==2) continue; if(vec.size()==n){ cout << "1\n" << arr[1] << endl; cout << n-1 << endl; for(int i=2; i<=n; i++) cout << arr[i] << " "; return; } cout << vec.size() << endl; for(auto i:vec) cout << i << " "; cout << endl << n-vec.size() << endl; for(int i=1; i<=n; i++) if(!took[i]) cout << arr[i] << " "; return; } cout << -1 << endl; } signed main(){ ios_base::sync_with_stdio(false);cin.tie(0); #ifdef Local freopen("in","r",stdin); freopen("out","w",stdout); #endif int t=1; //cin >> t; while(t--) solve(); }

Compilation message (stderr)

drvca.cpp: In function 'void solve()':
drvca.cpp:83:22: warning: comparison of integer expressions of different signedness: 'std::vector<long long int>::size_type' {aka 'long unsigned int'} and 'long long int' [-Wsign-compare]
   83 |         if(vec.size()==n){
      |            ~~~~~~~~~~^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...