# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
491617 | 2021-12-03T14:15:34 Z | n3rm1n | Table Tennis (info1cup20_tabletennis) | C++17 | 50 ms | 4408 KB |
#include<bits/stdc++.h> #define endl '\n' using namespace std; const int MAXN=150505; void speed() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); } int n,k; long long a[MAXN]; void read() { cin>>n>>k; for(int i=1;i<=n+k;i++) cin>>a[i]; } bool check1(int idx) { int i=1,j=n+k; if(i==idx)i++; if(j==idx)j--; long long sum=a[i]+a[j]; i++; j--; while(i<j) { if(i==idx)i++; if(j==idx)j--; if(a[i]+a[j]!=sum)return false; i++; j--; } return true; } void solve_st1() { for(int i=1;i<=n+k;i++) { if(check1(i)==true) { for(int j=1;j<i;j++) cout<<a[j]<<" "; for(int j=i+1;j<=n+k;j++) cout<<a[j]<<" "; cout<<endl; } } } bool used[MAXN]; bool found=false; void check() { vector<long long>v; for(int i=1;i<=n+k;i++) { if(used[i]==1)v.push_back(a[i]); } int i=0; int j=v.size()-1; long long sum=v[i]+v[j]; i++; j--; while(i<=j) { if(sum!=v[i]+v[j])return; i++; j--; } for(int i=0;i<v.size();i++) { cout<<v[i]<<" "; } cout<<endl; found=true; } void gen(int pos,int cntused) { if(pos>n+k) { if(cntused==n&&found==false)check(); return; } used[pos]=1; gen(pos+1,cntused+1); used[pos]=0; gen(pos+1,cntused); } void solve_st2() { /// the unwanted a[] is in the end if(check1(n+k)==true) { for(int i=1;i<n+k;i++) cout<<a[i]<<" "; cout<<endl; return; } /// the unwanted a[] is in the beggining if(check1(1)==true) { for(int i=2;i<=n+k;i++) cout<<a[i]<<" "; cout<<endl; return; } int i=2,j=n+k-1; long long sum=a[1]+a[n+k]; int pos1=0,pos2=0; while(i<j) { if(a[i]+a[j]!=sum) { pos1=i; pos2=j; break; } i++; j--; } if(pos1!=0&&check1(pos1)==true) { for(int i=1;i<pos1;i++) cout<<a[i]<<" "; for(int i=pos1+1;i<=n+k;i++) cout<<a[i]<<" "; cout<<endl; return; } if(pos2!=0&&check1(pos2)==true) { for(int i=1;i<pos2;i++) cout<<a[i]<<" "; for(int i=pos2+1;i<=n+k;i++) cout<<a[i]<<" "; cout<<endl; return; } for(int i=1;i<=(n+k)/2;i++) cout<<a[i]<<" "; for(int i=(n+k)/2+2;i<=n+k;i++) cout<<a[i]<<" "; cout<<endl; } int main() { speed(); read(); /*if(k==1&&n<=2000) { solve_st1(); return 0; }*/ if(k==1) { solve_st2(); return 0; } if(n+k<=18) { gen(1,0); return 0; } return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 332 KB | Output is correct |
2 | Correct | 1 ms | 332 KB | Output is correct |
3 | Correct | 1 ms | 332 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 588 KB | Output is correct |
2 | Correct | 33 ms | 4400 KB | Output is correct |
3 | Correct | 29 ms | 4372 KB | Output is correct |
4 | Correct | 50 ms | 4408 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 14 ms | 1460 KB | Unexpected end of file - int32 expected |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 204 KB | Unexpected end of file - int32 expected |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 204 KB | Output is correct |
2 | Correct | 2 ms | 204 KB | Output is correct |
3 | Correct | 2 ms | 204 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 204 KB | Unexpected end of file - int32 expected |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 204 KB | Unexpected end of file - int32 expected |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 204 KB | Unexpected end of file - int32 expected |
2 | Halted | 0 ms | 0 KB | - |