Submission #333125

# Submission time Handle Problem Language Result Execution time Memory
333125 2020-12-04T17:10:56 Z mohamedsobhi777 Bootfall (IZhO17_bootfall) C++14
28 / 100
1000 ms 1260 KB
//stupid solution 1
#include <bits/stdc++.h>

#pragma GCC optimize("-Ofast")
//#pragma GCC optimize("trapv")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.2,popcnt,abm,mmx,avx2,tune=native")
#pragma GCC optimize("-ffast-math")
#pragma GCC optimize("-funroll-loops")

#define vi vector<int>
#define vii vector<pair<int, int>>
#define pii pair<int, int>
#define pll pair<ll, ll>
#define loop(_) for (int __ = 0; __ < (_); ++__)
#define forn(i, n) for (int i = 0; i < n; ++i)

using namespace std;
using ll = long long;
using ld = long double;

const int N = 500 + 7;
const int NN = N * N;
const ll mod = 1e9 + 7;
const ll inf = 2e18;

auto ra = [] {char *p = new char ; delete p ; return ll(p) ; };
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count() * (ra() | 1));

int n;

bitset<NN> eval(vi v)
{
        bitset<NN> ret;
        ret[0] = 1;
        for (auto u : v)
                ret = (ret | (ret << u));
        return ret;
}

int main()
{
        ios_base::sync_with_stdio(0);
        cin.tie(0);
        //freopen("in.in", "r", stdin);
        cin >> n;
        vi a(n), ans;

        int sum = 0;
        for (auto &u : a)
                cin >> u;
        sum = accumulate(a.begin(), a.end(), 0);

        bitset<NN> bs = eval(a);
        if (sum & 1 || !bs[sum / 2])
                return cout << 0, 0;

        set<int> st;
        map<int, int> ret;
        for (int i = 0; i < n; ++i)
        {
                int x = a[i];
                a[i] = 0;
                bitset<NN> bts = eval(a);
                for (int j = 0; j <= accumulate(a.begin(), a.end(), 0); ++j)
                {
                        if (bts[j])
                        {
                                if (j != accumulate(a.begin(), a.end(), 0) - j)
                                {
                                        ret[abs(j - (accumulate(a.begin(), a.end(), 0) - j))]++;
                                }
                        }
                }
                a[i] = x;
        }

        int sz = 0;
        for (auto u : ret)
                if (u.second == 2 * n)
                        ++sz;
        cout << sz << "\n";
        for (auto u : ret)
                if (u.second == n * 2)
                        cout << u.first << " ";
        return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 492 KB Output is correct
2 Correct 1 ms 492 KB Output is correct
3 Correct 1 ms 512 KB Output is correct
4 Correct 1 ms 492 KB Output is correct
5 Correct 3 ms 492 KB Output is correct
6 Correct 2 ms 492 KB Output is correct
7 Correct 1 ms 492 KB Output is correct
8 Correct 3 ms 508 KB Output is correct
9 Correct 2 ms 512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 492 KB Output is correct
2 Correct 1 ms 492 KB Output is correct
3 Correct 1 ms 512 KB Output is correct
4 Correct 1 ms 492 KB Output is correct
5 Correct 3 ms 492 KB Output is correct
6 Correct 2 ms 492 KB Output is correct
7 Correct 1 ms 492 KB Output is correct
8 Correct 3 ms 508 KB Output is correct
9 Correct 2 ms 512 KB Output is correct
10 Correct 10 ms 492 KB Output is correct
11 Correct 10 ms 492 KB Output is correct
12 Correct 10 ms 492 KB Output is correct
13 Correct 8 ms 512 KB Output is correct
14 Correct 9 ms 492 KB Output is correct
15 Correct 9 ms 492 KB Output is correct
16 Correct 10 ms 492 KB Output is correct
17 Correct 4 ms 492 KB Output is correct
18 Correct 7 ms 492 KB Output is correct
19 Correct 8 ms 492 KB Output is correct
20 Correct 10 ms 484 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 492 KB Output is correct
2 Correct 1 ms 492 KB Output is correct
3 Correct 1 ms 512 KB Output is correct
4 Correct 1 ms 492 KB Output is correct
5 Correct 3 ms 492 KB Output is correct
6 Correct 2 ms 492 KB Output is correct
7 Correct 1 ms 492 KB Output is correct
8 Correct 3 ms 508 KB Output is correct
9 Correct 2 ms 512 KB Output is correct
10 Correct 10 ms 492 KB Output is correct
11 Correct 10 ms 492 KB Output is correct
12 Correct 10 ms 492 KB Output is correct
13 Correct 8 ms 512 KB Output is correct
14 Correct 9 ms 492 KB Output is correct
15 Correct 9 ms 492 KB Output is correct
16 Correct 10 ms 492 KB Output is correct
17 Correct 4 ms 492 KB Output is correct
18 Correct 7 ms 492 KB Output is correct
19 Correct 8 ms 492 KB Output is correct
20 Correct 10 ms 484 KB Output is correct
21 Correct 55 ms 596 KB Output is correct
22 Correct 74 ms 620 KB Output is correct
23 Correct 33 ms 492 KB Output is correct
24 Correct 127 ms 620 KB Output is correct
25 Correct 156 ms 620 KB Output is correct
26 Correct 175 ms 748 KB Output is correct
27 Correct 142 ms 620 KB Output is correct
28 Correct 137 ms 620 KB Output is correct
29 Correct 153 ms 696 KB Output is correct
30 Correct 150 ms 748 KB Output is correct
31 Correct 169 ms 620 KB Output is correct
32 Correct 144 ms 748 KB Output is correct
33 Correct 114 ms 492 KB Output is correct
34 Correct 114 ms 492 KB Output is correct
35 Correct 144 ms 620 KB Output is correct
36 Correct 143 ms 620 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 492 KB Output is correct
2 Correct 1 ms 492 KB Output is correct
3 Correct 1 ms 512 KB Output is correct
4 Correct 1 ms 492 KB Output is correct
5 Correct 3 ms 492 KB Output is correct
6 Correct 2 ms 492 KB Output is correct
7 Correct 1 ms 492 KB Output is correct
8 Correct 3 ms 508 KB Output is correct
9 Correct 2 ms 512 KB Output is correct
10 Correct 10 ms 492 KB Output is correct
11 Correct 10 ms 492 KB Output is correct
12 Correct 10 ms 492 KB Output is correct
13 Correct 8 ms 512 KB Output is correct
14 Correct 9 ms 492 KB Output is correct
15 Correct 9 ms 492 KB Output is correct
16 Correct 10 ms 492 KB Output is correct
17 Correct 4 ms 492 KB Output is correct
18 Correct 7 ms 492 KB Output is correct
19 Correct 8 ms 492 KB Output is correct
20 Correct 10 ms 484 KB Output is correct
21 Correct 55 ms 596 KB Output is correct
22 Correct 74 ms 620 KB Output is correct
23 Correct 33 ms 492 KB Output is correct
24 Correct 127 ms 620 KB Output is correct
25 Correct 156 ms 620 KB Output is correct
26 Correct 175 ms 748 KB Output is correct
27 Correct 142 ms 620 KB Output is correct
28 Correct 137 ms 620 KB Output is correct
29 Correct 153 ms 696 KB Output is correct
30 Correct 150 ms 748 KB Output is correct
31 Correct 169 ms 620 KB Output is correct
32 Correct 144 ms 748 KB Output is correct
33 Correct 114 ms 492 KB Output is correct
34 Correct 114 ms 492 KB Output is correct
35 Correct 144 ms 620 KB Output is correct
36 Correct 143 ms 620 KB Output is correct
37 Correct 816 ms 976 KB Output is correct
38 Correct 834 ms 1004 KB Output is correct
39 Correct 988 ms 492 KB Output is correct
40 Execution timed out 1053 ms 1260 KB Time limit exceeded
41 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 492 KB Output is correct
2 Correct 1 ms 492 KB Output is correct
3 Correct 1 ms 512 KB Output is correct
4 Correct 1 ms 492 KB Output is correct
5 Correct 3 ms 492 KB Output is correct
6 Correct 2 ms 492 KB Output is correct
7 Correct 1 ms 492 KB Output is correct
8 Correct 3 ms 508 KB Output is correct
9 Correct 2 ms 512 KB Output is correct
10 Correct 10 ms 492 KB Output is correct
11 Correct 10 ms 492 KB Output is correct
12 Correct 10 ms 492 KB Output is correct
13 Correct 8 ms 512 KB Output is correct
14 Correct 9 ms 492 KB Output is correct
15 Correct 9 ms 492 KB Output is correct
16 Correct 10 ms 492 KB Output is correct
17 Correct 4 ms 492 KB Output is correct
18 Correct 7 ms 492 KB Output is correct
19 Correct 8 ms 492 KB Output is correct
20 Correct 10 ms 484 KB Output is correct
21 Correct 55 ms 596 KB Output is correct
22 Correct 74 ms 620 KB Output is correct
23 Correct 33 ms 492 KB Output is correct
24 Correct 127 ms 620 KB Output is correct
25 Correct 156 ms 620 KB Output is correct
26 Correct 175 ms 748 KB Output is correct
27 Correct 142 ms 620 KB Output is correct
28 Correct 137 ms 620 KB Output is correct
29 Correct 153 ms 696 KB Output is correct
30 Correct 150 ms 748 KB Output is correct
31 Correct 169 ms 620 KB Output is correct
32 Correct 144 ms 748 KB Output is correct
33 Correct 114 ms 492 KB Output is correct
34 Correct 114 ms 492 KB Output is correct
35 Correct 144 ms 620 KB Output is correct
36 Correct 143 ms 620 KB Output is correct
37 Correct 816 ms 976 KB Output is correct
38 Correct 834 ms 1004 KB Output is correct
39 Correct 988 ms 492 KB Output is correct
40 Execution timed out 1053 ms 1260 KB Time limit exceeded
41 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 492 KB Output is correct
2 Correct 1 ms 492 KB Output is correct
3 Correct 1 ms 512 KB Output is correct
4 Correct 1 ms 492 KB Output is correct
5 Correct 3 ms 492 KB Output is correct
6 Correct 2 ms 492 KB Output is correct
7 Correct 1 ms 492 KB Output is correct
8 Correct 3 ms 508 KB Output is correct
9 Correct 2 ms 512 KB Output is correct
10 Correct 10 ms 492 KB Output is correct
11 Correct 10 ms 492 KB Output is correct
12 Correct 10 ms 492 KB Output is correct
13 Correct 8 ms 512 KB Output is correct
14 Correct 9 ms 492 KB Output is correct
15 Correct 9 ms 492 KB Output is correct
16 Correct 10 ms 492 KB Output is correct
17 Correct 4 ms 492 KB Output is correct
18 Correct 7 ms 492 KB Output is correct
19 Correct 8 ms 492 KB Output is correct
20 Correct 10 ms 484 KB Output is correct
21 Correct 55 ms 596 KB Output is correct
22 Correct 74 ms 620 KB Output is correct
23 Correct 33 ms 492 KB Output is correct
24 Correct 127 ms 620 KB Output is correct
25 Correct 156 ms 620 KB Output is correct
26 Correct 175 ms 748 KB Output is correct
27 Correct 142 ms 620 KB Output is correct
28 Correct 137 ms 620 KB Output is correct
29 Correct 153 ms 696 KB Output is correct
30 Correct 150 ms 748 KB Output is correct
31 Correct 169 ms 620 KB Output is correct
32 Correct 144 ms 748 KB Output is correct
33 Correct 114 ms 492 KB Output is correct
34 Correct 114 ms 492 KB Output is correct
35 Correct 144 ms 620 KB Output is correct
36 Correct 143 ms 620 KB Output is correct
37 Correct 816 ms 976 KB Output is correct
38 Correct 834 ms 1004 KB Output is correct
39 Correct 988 ms 492 KB Output is correct
40 Execution timed out 1053 ms 1260 KB Time limit exceeded
41 Halted 0 ms 0 KB -