Submission #675116

#TimeUsernameProblemLanguageResultExecution timeMemory
675116anhduc2701Table Tennis (info1cup20_tabletennis)C++17
100 / 100
493 ms10824 KiB
/* #pragma GCC optimize("Ofast") #pragma GCC target("avx,avx2,fma") #pragma GCC optimize("unroll-loops") */ #include<bits/stdc++.h> #define all(x) x.begin(), x.end() #define len(x) ll(x.size()) #define eb emplace_back #define PI 3.14159265359 #define fi first #define se second #define mp make_pair #define pb push_back #define MIN(v) *min_element(all(v)) #define MAX(v) *max_element(all(v)) #define BIT(x,i) (1&((x)>>(i))) #define MASK(x) (1LL<<(x)) #define task "tnc" using namespace std; typedef long long ll; const ll INF=1e18; const int maxn=1e6+5; const int mod=1e9+7; const int mo=998244353; using pi=pair<ll,ll>; using vi=vector<ll>; using pii=pair<pair<ll,ll>,ll>; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); int a[200005]; map<int,int>z; signed main() { cin.tie(0),cout.tie(0)->sync_with_stdio(0); //freopen(task".inp" , "r" , stdin); //freopen(task".out" , "w" , stdout); int n,k; cin>>n>>k; for(int i=1;i<=n+k;i++){ cin>>a[i]; } int cap=n/2; for(int i=1;i<=k+1;i++){ for(int j=n+k;j>=max(n,i+1);j--){ int l=i+1; int r=j; int tong=a[i]+a[j]; vector<pair<int,int>>ans; ans.pb({a[i],a[j]}); if(z[tong]==0){ z[tong]=1; while(l<r && (cap-ans.size())*2<=(r-l+1)){ if(a[l]+a[r]==tong){ ans.pb({a[l],a[r]}); l++; } else if(a[l]+a[r]>tong){ r--; } else if(a[l]+a[r]<tong){ l++; } } if(ans.size()==n/2){ vector<int>sz; for(auto v:ans){ sz.pb(v.fi); sz.pb(v.se); } sort(sz.begin(),sz.end()); for(auto v:sz){ cout<<v<<" "; } return 0; } } } } return 0; }

Compilation message (stderr)

tabletennis.cpp: In function 'int main()':
tabletennis.cpp:53:39: warning: comparison of integer expressions of different signedness: 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   53 |        while(l<r && (cap-ans.size())*2<=(r-l+1)){
      |                     ~~~~~~~~~~~~~~~~~~^~~~~~~~~
tabletennis.cpp:65:21: warning: comparison of integer expressions of different signedness: 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   65 |        if(ans.size()==n/2){
      |           ~~~~~~~~~~^~~~~
#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...