Submission #877464

# Submission time Handle Problem Language Result Execution time Memory
877464 2023-11-23T08:55:27 Z prince Bootfall (IZhO17_bootfall) C++17
0 / 100
0 ms 348 KB
#include "bits/stdc++.h"

using namespace std;
using ll = long long;
ll rec(int n,vector<int>&vec,int sum1,int sum2){
    if(n==0){
        return abs(sum1-sum2);
    }
    int a=rec(n-1,vec,sum1+vec[n-1],sum2);
    int b=rec(n-1,vec,sum1,sum2+vec[n-1]);
    return min(a,b);
}
void solve(){
    int n;cin>>n;
    vector<int>vec(n);
    set<int>st;
    sort(vec.begin(),vec.end());
    if(n%2&&vec[0]==vec[vec.size()-1]){
        cout<<0;
        return;
    }
    for(auto &x:vec)cin>>x;
    for(ll i=0;i<n;i++){
        for(ll j=1;j<=2e2;j++){
            bool check=1;
            for(ll k=0;k<n;k++){
                ll l=vec[k];
                vec[k]=j;
                //cout<<l<<" ";
                ll ans=rec(n,vec,0,0);
                vec[k]=l;
                if(ans!=0){
                    check=0;
                    break;
                }
            }
            if(check){
                //cout<<j<<" ";
                st.insert(j);
            }
        }
    }
    cout<<st.size()<<endl;
    for(auto &x:st)cout<<x<<" ";
}
signed main() {
    cin.tie(0)->sync_with_stdio(false);
#ifdef prince
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int q = 1;
    // cin >> q;
    while (q--) {
        solve();
        cout << '\n';
    }
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Incorrect 0 ms 348 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Incorrect 0 ms 348 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Incorrect 0 ms 348 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Incorrect 0 ms 348 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Incorrect 0 ms 348 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Incorrect 0 ms 348 KB Output isn't correct
5 Halted 0 ms 0 KB -