제출 #423651

#제출 시각아이디문제언어결과실행 시간메모리
423651errorgornTable Tennis (info1cup20_tabletennis)C++17
100 / 100
2883 ms355308 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define ii pair<ll,ll> #define fi first #define se second #define endl '\n' #define puf push_front #define pof pop_front #define pub push_back #define pob pop_back #define rep(x,s,e) for (auto x=s;x!=e;x++) #define all(x) (x).begin(),(x).end() #define sz(x) (int) (x).size() mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); int n,k; int arr[160005]; ll cnt[30000005]; int ba[30000005]; uint __hash(int x){ x^=(x<<17); x^=(x>>13); x+=35094808; x^=(x<<6); return x; } int main(){ cin.tie(0); cout.tie(0); cin.sync_with_stdio(false); cin>>n>>k; rep(x,0,n+k) cin>>arr[x]; int l=n,r=n+k+k; rep(x,0,n+k){ l--,r--; if (r<x) break; int a=max(x+1,l),b=min(r,n+k)+1; rep(y,a,b){ int hh=__hash(arr[x]+arr[y])%30000000; cnt[hh]++; ba[hh]=arr[x]+arr[y]; } } int val; rep(x,0,30000000) if (cnt[x]>=n/2){ val=ba[x]; break; } vector<int> ans; r=n+k-1; rep(x,0,n+k){ while (arr[x]+arr[r]>val) r--; if (arr[x]+arr[r]==val){ ans.pub(arr[x]); ans.pub(arr[r]); r--; if (sz(ans)==n) break; } } sort(all(ans)); for (auto &it:ans) cout<<it<<" "; cout<<endl; }

컴파일 시 표준 에러 (stderr) 메시지

tabletennis.cpp: In function 'int main()':
tabletennis.cpp:79:2: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   79 |  for (auto &it:ans) cout<<it<<" "; cout<<endl;
      |  ^~~
tabletennis.cpp:79:36: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   79 |  for (auto &it:ans) cout<<it<<" "; cout<<endl;
      |                                    ^~~~
tabletennis.cpp:67:23: warning: 'val' may be used uninitialized in this function [-Wmaybe-uninitialized]
   67 |   while (arr[x]+arr[r]>val) r--;
      |          ~~~~~~~~~~~~~^~~~
#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...