Submission #687663

#TimeUsernameProblemLanguageResultExecution timeMemory
687663dragusanu_raresTable Tennis (info1cup20_tabletennis)C++14
72 / 100
3106 ms331368 KiB
#include <iostream> #include <algorithm> #include <unordered_map> #include <vector> using namespace std; long long v[150405]; long long sol[150405]; unordered_map <long long,long long> f; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int n,k,suma; cin>>n>>k; for(int i=1;i<=n+k;i++) { cin>>v[i]; f[v[i]]+=1; } if (n + k <= 18) {///Vlad e prea bun for (int mask = 1; mask < (1 << (n + k)); mask++) { if (__builtin_popcount(mask) == n) { vector<int> pos; for (int bit = 0; bit < n + k; bit++) { if (mask & (1 << bit)) pos.push_back(v[bit + 1]); } bool ok = 1; for (int i = 1; i < (n / 2); i++) { if (pos[i] + pos[n - i - 1] != pos[0] + pos[n - 1]) { ok = false; } } if (ok) { for (auto &it : pos) { cout << it << " "; } return 0; } } } } else if(k==1) {///macar 20 de puncte ///cazul in care nu eliminam nici 1, nici n+k ///sort(v+1,v+k+n); suma=v[1]+v[n+k]; int eliminat,cnteliminat=0; ///cout<<"suma="<<suma<<"\n"; for(int i=2;i<n+k;i++) { if(f[suma-v[i]]==0||v[i]*2==suma) { cnteliminat++; ///cout<<"nu merge "<<v[i]<<"\n"; eliminat=v[i]; } } if(cnteliminat==1) { for(int i=1;i<=n+k;i++) { if(f[suma-v[i]]==1&&v[i]*2!=suma) cout<<v[i]<<" "; } } else { ///eliminam pe primul numar cnteliminat=0; suma=v[2]+v[n+k]; for(int i=2;i<n+k;i++) { if(f[suma-v[i]]==0||v[i]*2==suma) { cnteliminat++; ///cout<<"nu merge "<<v[i]<<"\n"; eliminat=v[i]; } } if(cnteliminat==0) { for(int i=2;i<=n+k;i++) cout<<v[i]<<" "; } else { for(int i=1;i<n+k;i++) cout<<v[i]<<" "; } } return 0; } ///cout<<"n^3\n"; int cntok=0,ok=0; for (int i = 1; i <= k+1; i++) { for (int j = i + n-1; j <=n+k; j++) { suma=v[i]+v[j]; cntok = 0; for(int l=i;l<=j;l++) { if(f[suma-v[l]]==1&&v[l]*2!=suma) { cntok++; } } if(cntok>=n) { cntok=0; for(int l=i;l<=j;l++) { if(f[suma-v[l]]==1&&v[l]*2!=suma&&cntok<n) { ///cout<<v[i]<<" "<<suma-v[i]<<" "; sol[cntok]=v[l]; sol[cntok+1]=suma-v[l]; ok=1; cntok+=2; } } sort(sol,sol+n); for(int l=0;l<n;l++) cout<<sol[l]<<" "; } if(ok==1) break; } if(ok==1) break; } return 0; }

Compilation message (stderr)

tabletennis.cpp: In function 'int main()':
tabletennis.cpp:50:13: warning: variable 'eliminat' set but not used [-Wunused-but-set-variable]
   50 |         int eliminat,cnteliminat=0;
      |             ^~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...