Submission #667635

# Submission time Handle Problem Language Result Execution time Memory
667635 2022-12-01T20:29:56 Z Hacv16 Table Tennis (info1cup20_tabletennis) C++17
20 / 100
3000 ms 5132 KB
#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;
}

Compilation message

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
1 Correct 1 ms 340 KB Output is correct
2 Correct 7 ms 368 KB Output is correct
3 Correct 8 ms 372 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1061 ms 1032 KB Output is correct
2 Correct 27 ms 4512 KB Output is correct
3 Execution timed out 3068 ms 5096 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3070 ms 5132 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 324 KB Output does not have symmetry property
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output does not have symmetry property
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output does not have symmetry property
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 340 KB Output does not have symmetry property
2 Halted 0 ms 0 KB -