제출 #1029266

#제출 시각아이디문제언어결과실행 시간메모리
1029266berrTable Tennis (info1cup20_tabletennis)C++17
100 / 100
516 ms5336 KiB
#include <bits/stdc++.h> using namespace std; void f(){ #ifndef ONLINE_JUDGE freopen("in.txt", "r", stdin); freopen("out.txt", "w", stdout); #endif } signed main(){ ios_base::sync_with_stdio(false); cin.tie(0); // f(); srand(time(0)); int n, k; cin >>n >> k; vector<int> a(n+k); for(auto &i: a) cin >> i; vector<int> vis(n+k); int ans=0; vector<int> gh; auto check=[&](int val, int type){ int p=n+k-1; int all=0; for(int i=0; i<p&&i<n+k&&all<n/2; i++){ while(p>0&&a[i]+a[p]>val) p--; if(i<p&&a[i]+a[p]==val){ all++; if(type){ gh.push_back(a[i]); gh.push_back(a[p]); } } } if(all==n/2) return 1; return 0; }; if(k<20){ for(int i=0; i<=20&&i<n+k&&ans==0; i++){ for(int j=0; j<=20&&j<n+k-1&&ans==0; j++){ if(check(a[i]+a[n+k-j-1], 0)){ ans=a[i]+a[n+k-j-1]; } } } } while(ans==0){ int val=rand()%(3*k); if(vis[val]) continue; int j=k+val; vis[val]=1; for(int l=0; l<=j; l++){ if( check(a[val]+a[n+k-l-1], 0)){ ans=a[val]+a[n+k-l-1]; } } } check(ans, 1); sort(gh.begin(), gh.end()); for(auto i: gh) cout<<i<<" "; }

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

tabletennis.cpp: In function 'void f()':
tabletennis.cpp:6:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    6 |  freopen("in.txt", "r", stdin);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
tabletennis.cpp:7:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    7 |  freopen("out.txt", "w", stdout);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
#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...