Submission #180273

# Submission time Handle Problem Language Result Execution time Memory
180273 2020-01-08T14:20:49 Z Nightmar Bootfall (IZhO17_bootfall) C++17
0 / 100
1000 ms 384 KB
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstdlib>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <iomanip>
#include <unordered_map>

#define SWS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define pb push_back
#define ppb pop_back
#define ft first
#define sd second
#define readf freopen("input.txt", "r", stdin)
#define writef freopen("output.txt", "w", stdout)
#define files readf; writef

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;

const int Z = 999;
const int N = (int)1e6 + 228;
const int INF = (int)1e9 + 5;
const int MOD = (int)1e9 + 7;

int main() {
	SWS;
	srand(time(0));
	//files;
    int n, sum = 0;
    cin >> n;
    vector<int> a(n + 2);
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        sum += a[i];
    }
    vector<int> ans;
    for (a[n + 1] = 0; a[n + 1] <= sum; a[n + 1]++) {
        bool flag = true;
        //cout << a[n + 1] << endl;
        for (int i = 1; i <= n + 1; i++) {
            vector<int> v;
            v.pb(0);
            int cur_sum = 0;
            for (int j = 1; j < i; j++) {
                v.pb(a[j]);
                cur_sum += a[j];
            }
            for (int j = i + 1; j <= n + 1; j++) {
                v.pb(a[j]);
                cur_sum += a[j];
            }
            vector<vector<bool> > f(n + 1, vector<bool> (cur_sum + 1, false));
            f[0][0] = true;
            for (int j = 1; j <= n; j++) {
                for (int q = 0; q <= cur_sum; q++) {
                    f[j][q] = f[j - 1][q];
                    if (q - v[j] >= 0 && f[j - 1][q - v[j]]) f[j][q] = true;
                }
            }
            /*if (a[n + 1] == 3) {
                cout << "DEBUG : " << cur_sum << endl;
                cout << "V : ";
                for (int j = 1; j <= n; j++) {
                    cout << v[j] << ' ';
                }
                cout << endl;
                for (int j = 1; j <= n; j++) {
                    for (int q = 0; q <= cur_sum; q++) {
                        cout << f[j][q] << ' ';
                    }
                    cout << endl;
                }
            }*/
            bool nf = false;
            for (int j = 1; j <= n; j++) {
                if (cur_sum % 2 == 0 && f[j][cur_sum / 2]) nf = true;
            }
            flag &= nf;
        }
        if (flag) {
            ans.pb(a[n + 1]);
        }
    }
    cout << ans.size() << "\n";
    for (int i : ans) {
        cout << i << ' ';
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 60 ms 380 KB Output is correct
5 Correct 805 ms 384 KB Output is correct
6 Correct 19 ms 376 KB Output is correct
7 Correct 25 ms 376 KB Output is correct
8 Execution timed out 1062 ms 380 KB Time limit exceeded
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 60 ms 380 KB Output is correct
5 Correct 805 ms 384 KB Output is correct
6 Correct 19 ms 376 KB Output is correct
7 Correct 25 ms 376 KB Output is correct
8 Execution timed out 1062 ms 380 KB Time limit exceeded
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 60 ms 380 KB Output is correct
5 Correct 805 ms 384 KB Output is correct
6 Correct 19 ms 376 KB Output is correct
7 Correct 25 ms 376 KB Output is correct
8 Execution timed out 1062 ms 380 KB Time limit exceeded
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 60 ms 380 KB Output is correct
5 Correct 805 ms 384 KB Output is correct
6 Correct 19 ms 376 KB Output is correct
7 Correct 25 ms 376 KB Output is correct
8 Execution timed out 1062 ms 380 KB Time limit exceeded
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 60 ms 380 KB Output is correct
5 Correct 805 ms 384 KB Output is correct
6 Correct 19 ms 376 KB Output is correct
7 Correct 25 ms 376 KB Output is correct
8 Execution timed out 1062 ms 380 KB Time limit exceeded
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 60 ms 380 KB Output is correct
5 Correct 805 ms 384 KB Output is correct
6 Correct 19 ms 376 KB Output is correct
7 Correct 25 ms 376 KB Output is correct
8 Execution timed out 1062 ms 380 KB Time limit exceeded
9 Halted 0 ms 0 KB -