# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
845925 | samekkk | Table Tennis (info1cup20_tabletennis) | C++14 | 3078 ms | 4812 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(a,b) for (int a = 0; a < (b); ++a)
#define pb push_back
#define all(t) t.begin(), t.end()
const int max_N = 160005;
int n = 0, k = 0;
int A[max_N];
vector<int> V;
vector<int> wyn;
inline bool czy_pasuje(int val1, int val2)
{
if (val1 == val2) return false;
wyn = vector<int>();
wyn.pb(val1), wyn.pb(val2);
if (n == 2) return true;
vector<int> vect;
rep(i,n+k) if (A[i] != val1 and A[i] != val2) vect.pb(A[i]);
//for (auto x : vect) cout << x << " ";
//cout << endl;
int sum = val1 + val2, lewy_wsk = 0, prawy_wsk = vect.size()-1;
while(lewy_wsk < prawy_wsk)
{
if(vect[lewy_wsk] == val1 or vect[lewy_wsk] == val2) ++lewy_wsk;
if(vect[prawy_wsk] == val1 or vect[prawy_wsk] == val2) --prawy_wsk;
if(vect[lewy_wsk] == val1 or vect[lewy_wsk] == val2 or vect[prawy_wsk] == val1 or vect[prawy_wsk] == val2) continue;
//cout << "lewy wsk: " << lewy_wsk << " prawy wsk: " << prawy_wsk << " lewy val: " << vect[lewy_wsk] << " prawy val: " << vect[prawy_wsk] << endl;
if (vect[lewy_wsk] + vect[prawy_wsk] == sum)
{
wyn.pb(vect[lewy_wsk]), wyn.pb(vect[prawy_wsk]);
if (n == wyn.size()) return true;
++lewy_wsk, --prawy_wsk;
}
else if (vect[lewy_wsk] + vect[prawy_wsk] > sum) --prawy_wsk;
else ++lewy_wsk;
}
return false;
}
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin >> n >> k;
rep(i,n+k) cin >> A[i];
rep(i,k) V.pb(A[i]);
for (int i = n; i < n+k; ++i) V.pb(A[i]);
rep(i,V.size())
{
for (int j = i+1; j < V.size(); ++j)
{
if (czy_pasuje(V[i],V[j]) == true)
{
//cout << "Vi: " << V[i] << " Vj: " << V[j] << endl;
sort(all(wyn));
for (auto v : wyn) cout << v << ' ';
cout << '\n';
return 0;
}
}
}
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... |