이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
bool solve(vector<ll>v)
{
int l = 0 , r=v.size()-1;
if(v[l]==-1)
l++;
if(v[r]==-1)
r--;
ll newmid, mid=(v[l]+v[r])/2;
l++;
r--;
while(l<r)
{
if(v[l]==-1)
l++;
if(v[r]==-1)
r--;
newmid=(v[l]+v[r])>>1;
l++;
r--;
if(mid!=newmid)
return false;
}
return true;
}
int main()
{
ll n , k ;
cin >> n >> k;
//cout << n << " " << k << "\n";
vector<ll>v;
ll x , y;
for(int i = 0 ; i < n+k ; i++)
{
cin>> x;
v.push_back(x*2);
}
if(k==1)
{
for(int i = 0 ; i < n+k ; i++)
{
x=v[i];
v[i]=-1;
if(solve(v))
{
//cout << "yes\n";
break;
}
else v[i]=x;
//cout << "no\n";
}
for(int i = 0 ; i < n+k ; i++)
{
if(v[i]!=-1)
{
cout << v[i]/2 << " ";
}
}
return 0;
}
if(k==2)
{
for(int i = 0 ; i < n+k ; i++)
{
for(int j = i+1 ; j < n+k ; j++)
{
x=v[i];
v[i]=-1;
y=v[j];
v[j]=-1;
if(solve(v))
{
break;
}
else
{
v[i]=x;
v[j]=y;
}
}
}
for(int i = 0 ; i < n+k ; i++)
{
if(v[i]!=-1)
{
cout << v[i]/2 << " ";
}
}
return 0;
}
return 0;
}
# | 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... |