이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAX = 2e6 + 50;
const int INF = 0x3f3f3f3f;
ll n, k, ans;
vector<ll> v;
bool check(int j){
vector<ll> aux;
for(int i = 0; i < v.size(); i++){
if(i == j) continue;
aux.push_back(v[i]);
}
ll sum = aux[0] + aux[aux.size() - 1];
for(int l = 1, r = aux.size() - 2; l < r; l++, r--)
if(aux[l] + aux[r] != sum) return false;
return true;
}
void bt(int i, int chosen, vector<ll> aux){
if(chosen > n || i > n + k) return;
if(i == n + k){
if(chosen == n){
ll sum = aux[0] + aux[aux.size() - 1];
bool isAns = true;
for(int l = 1, r = aux.size() - 2; l < r; l++, r--)
if(aux[l] + aux[r] != sum){ isAns = false; break; }
if(isAns){
for(auto x : aux)
cout << x << ' ';
cout << '\n';
exit(0);
}
}
return;
}
vector<ll> sla = aux;
sla.push_back(v[i]);
bt(i + 1, chosen + 1, sla);
bt(i + 1, chosen, aux);
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cin >> n >> k;
for(int i = 0; i < n + k; i++){
ll x; cin >> x;
v.push_back(x);
}
if(n + k <= 18){
vector<ll> trash;
bt(0, 0, trash);
return 0;
}
for(int i = 0; i < v.size(); i++)
if(check(i)){ ans = i; break;}
for(int i = 0; i < v.size(); i++){
if(i == ans) continue;
cout << v[i] << ' ';
}
cout << '\n';
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
tabletennis.cpp: In function 'bool check(int)':
tabletennis.cpp:14:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
14 | for(int i = 0; i < v.size(); i++){
| ~~^~~~~~~~~~
tabletennis.cpp: In function 'int main()':
tabletennis.cpp:75:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
75 | for(int i = 0; i < v.size(); i++)
| ~~^~~~~~~~~~
tabletennis.cpp:78:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
78 | for(int i = 0; i < v.size(); i++){
| ~~^~~~~~~~~~
# | 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... |