# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
685913 | ReLice | Table Tennis (info1cup20_tabletennis) | C++14 | 3086 ms | 18100 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
#define ll long long
#define pb push_back
#define pob pop_back
#define sz size()
#define fr first
#define sc second
#define all(x) x.begin(),x.end()
void start(){
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
}
const ll N = 5e4+10;
const ll mod=1e9+7;
const ll inf=1e10;
map<ll,ll> mp;
vector <ll> ans;
vector <ll> v;
ll n,k;
bool flag=false;
void go(ll ind, ll u){
if(flag) return;
if(u==0){
ll l=0,r=n-1,b=ans[0]+ans[n-1];
while(l<r){
if(ans[l]+ans[r]!=b) return;
l++;
r--;
}
flag=true;
return;
}
if(ind==n+k) return;
ans.pb(v[ind]);
go(ind+1,u-1);
if(flag) return;
ans.pob();
go(ind+1,u);
if(flag) return;
}
void solve(){
ll i,j;
ll m,b,x=0,y=0,c=0,sum=0;
cin>>n>>k;
for(i=0;i<n+k;i++){
cin>>b;
v.pb(b);
mp[b]=i+1;
sum+=b;
}if(k==1){
b=sum-(n/2)*(v[0]+v[n]);
x=v[0]+v[n];
if(mp[b]>=0){
ll l=0,r=n+k-1;
bool flag=true;
while(l<r){
if(l==mp[b]-1)l++;
if(r==mp[b]-1)r--;
if(v[l]+v[r]!=x) {
flag=false;
break;
}
l++;
r--;
}
if(flag){
for(i=0;i<n+k;i++){
if(i==mp[b]-1)continue;
cout<<v[i]<<' ';
}
cout<<endl;
return;
}
}
b=sum-(n/2)*(v[1]+v[n]);
x=v[1]+v[n];
if(mp[b]==1){
ll l=1,r=n+k-1;
bool flag=true;
while(l<r){
if(v[l]+v[r]!=x) {
flag=false;
break;
}
l++;
r--;
}
if(flag){
for(i=1;i<n+k;i++){
if(i==mp[b]-1)continue;
cout<<v[i]<<' ';
}
cout<<endl;
return;
}
}
b=sum-(n/2)*(v[0]+v[n-1]);
x=v[0]+v[n-1];
if(mp[b]==n+k){
ll l=0,r=n+k-2;
bool flag=true;
while(l<r){
if(v[l]+v[r]!=x) {
flag=false;
break;
}
l++;
r--;
}
if(flag){
for(i=0;i<n+k;i++){
if(i==mp[b]-1)continue;
cout<<v[i]<<' ';
}
cout<<endl;
return;
}
}
}
else{
go(0,n);
for(auto i : ans) cout<<i<<' ';
cout<<endl;
}
}
main(){
//fre("");
start();
ll t=1;
//cin>>t;
while(t--)solve();
}
컴파일 시 표준 에러 (stderr) 메시지
# | 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... |