# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
687663 | dragusanu_rares | Table Tennis (info1cup20_tabletennis) | C++14 | 3106 ms | 331368 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <iostream>
#include <algorithm>
#include <unordered_map>
#include <vector>
using namespace std;
long long v[150405];
long long sol[150405];
unordered_map <long long,long long> f;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int n,k,suma;
cin>>n>>k;
for(int i=1;i<=n+k;i++)
{
cin>>v[i];
f[v[i]]+=1;
}
if (n + k <= 18) {///Vlad e prea bun
for (int mask = 1; mask < (1 << (n + k)); mask++) {
if (__builtin_popcount(mask) == n) {
vector<int> pos;
for (int bit = 0; bit < n + k; bit++) {
if (mask & (1 << bit)) pos.push_back(v[bit + 1]);
}
bool ok = 1;
for (int i = 1; i < (n / 2); i++) {
if (pos[i] + pos[n - i - 1] != pos[0] + pos[n - 1]) {
ok = false;
}
}
if (ok) {
for (auto &it : pos) {
cout << it << " ";
}
return 0;
}
}
}
}
else if(k==1) {///macar 20 de puncte
///cazul in care nu eliminam nici 1, nici n+k
///sort(v+1,v+k+n);
suma=v[1]+v[n+k];
int eliminat,cnteliminat=0;
///cout<<"suma="<<suma<<"\n";
for(int i=2;i<n+k;i++)
{
if(f[suma-v[i]]==0||v[i]*2==suma)
{
cnteliminat++;
///cout<<"nu merge "<<v[i]<<"\n";
eliminat=v[i];
}
}
if(cnteliminat==1)
{
for(int i=1;i<=n+k;i++)
{
if(f[suma-v[i]]==1&&v[i]*2!=suma)
cout<<v[i]<<" ";
}
}
else
{
///eliminam pe primul numar
cnteliminat=0;
suma=v[2]+v[n+k];
for(int i=2;i<n+k;i++)
{
if(f[suma-v[i]]==0||v[i]*2==suma)
{
cnteliminat++;
///cout<<"nu merge "<<v[i]<<"\n";
eliminat=v[i];
}
}
if(cnteliminat==0)
{
for(int i=2;i<=n+k;i++)
cout<<v[i]<<" ";
}
else
{
for(int i=1;i<n+k;i++)
cout<<v[i]<<" ";
}
}
return 0;
}
///cout<<"n^3\n";
int cntok=0,ok=0;
for (int i = 1; i <= k+1; i++) {
for (int j = i + n-1; j <=n+k; j++) {
suma=v[i]+v[j];
cntok = 0;
for(int l=i;l<=j;l++)
{
if(f[suma-v[l]]==1&&v[l]*2!=suma)
{
cntok++;
}
}
if(cntok>=n)
{
cntok=0;
for(int l=i;l<=j;l++)
{
if(f[suma-v[l]]==1&&v[l]*2!=suma&&cntok<n)
{
///cout<<v[i]<<" "<<suma-v[i]<<" ";
sol[cntok]=v[l];
sol[cntok+1]=suma-v[l];
ok=1;
cntok+=2;
}
}
sort(sol,sol+n);
for(int l=0;l<n;l++)
cout<<sol[l]<<" ";
}
if(ok==1)
break;
}
if(ok==1)
break;
}
return 0;
}
컴파일 시 표준 에러 (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... |