이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
/*
#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;
}
컴파일 시 표준 에러 (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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |