Submission #667716

#TimeUsernameProblemLanguageResultExecution timeMemory
667716definitelynotmeeTable Tennis (info1cup20_tabletennis)C++98
Compilation error
0 ms0 KiB
#include<bits/stdc++.h> using namespace std; #define ff first #define ss second #define all(x) x.begin(), x.end() using ll = long long; using pii = pair<int,int>; using pll = pair<ll,ll>; template<typename T> using matrix = vector<vector<T>>; int main(){ cin.tie(0)->sync_with_stdio(0); int n, k; cin >> n >> k; vector<int> v(n+k); for(int i = 0; i < n+k; i++) cin >> v[i]; map<int,int> sums; int minmid = max(0,(n+k)/2-k/2-3), maxmid = min(n+k-1,(n+k)/2+k/2+3); for(int offset = -k/2-2; offset <= k/2+2; offset++){ for(int i = 0; i < n+k; i++){ int y = n+k-i-1; y+=offset; if(offset >= 0 && offset < n+k) sums[v[i]+v[y]]++; } } pair<int,int> opt = {-1,0}; for(pii i : sums) opt = max(opt,{i.ss,i.ff}); auto findans =[&](int sum){ int p1 = 0, p2 = n+k-1; vector<int> resp; while(p1 < p2){ if(v[p1] + v[p2] > sum){ p2--; continue; } if(v[p1] + v[p2] < sum){ p1++; continue; } resp.push_back(v[p1]), resp.push_back(v[p2]); p1++, p2--; } sort(all(resp)); for(int i = 0; i < n; i++) cout << resp[i] << ' '; cout << '\n'; }; for(pii i : sums) if(i.ss < opt.ss/2) continue; int sum = i.ff; int resp = 0; int p1 = 0, p2 = n+k-1; while(p1 < p2){ if(v[p1] + v[p2] > sum){ p2--; continue; } if(v[p1] + v[p2] < sum){ p1++; continue; } p1++, p2--; resp++; } //cout << sum << ' ' << resp << '\n'; if(resp >= n/2){ findans(sum); return 0; } //} //exit(1); }

Compilation message (stderr)

tabletennis.cpp: In function 'int main()':
tabletennis.cpp:64:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   64 |     for(pii i : sums)
      |     ^~~
tabletennis.cpp:67:9: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   67 |         int sum = i.ff;
      |         ^~~
tabletennis.cpp:67:19: error: 'i' was not declared in this scope
   67 |         int sum = i.ff;
      |                   ^
tabletennis.cpp:24:9: warning: unused variable 'minmid' [-Wunused-variable]
   24 |     int minmid = max(0,(n+k)/2-k/2-3), maxmid = min(n+k-1,(n+k)/2+k/2+3);
      |         ^~~~~~
tabletennis.cpp:24:40: warning: unused variable 'maxmid' [-Wunused-variable]
   24 |     int minmid = max(0,(n+k)/2-k/2-3), maxmid = min(n+k-1,(n+k)/2+k/2+3);
      |                                        ^~~~~~