답안 #333128

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
333128 2020-12-04T17:17:14 Z mohamedsobhi777 Bootfall (IZhO17_bootfall) C++14
65 / 100
1000 ms 1648 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 = 400 + 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 ret[NN];

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;
        for (int i = 0; i < n; ++i)
        {
                int x = a[i];
                a[i] = 0;
                bitset<NN> bts = eval(a);
                int sm = sum - x;
                for (int j = 0; j <= sm; ++j)
                {
                        if (bts[j])
                        {
                                if (2 * j != sm)
                                        ret[abs(j - (sm - j))]++;
                        }
                }
                a[i] = x;
        }

        int sz = 0;
        for (int u = 1; u < NN; ++u)
        {
                if (ret[u] == 2 * n)
                        ans.push_back(u);
        }
        cout << (int)ans.size() << "\n";
        for (auto u : ans)
                cout << u << " ";
        return 0;
}

Compilation message

bootfall.cpp: In function 'int main()':
bootfall.cpp:78:13: warning: unused variable 'sz' [-Wunused-variable]
   78 |         int sz = 0;
      |             ^~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 2 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 2 ms 364 KB Output is correct
9 Correct 2 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 2 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 2 ms 364 KB Output is correct
9 Correct 2 ms 364 KB Output is correct
10 Correct 7 ms 364 KB Output is correct
11 Correct 7 ms 364 KB Output is correct
12 Correct 7 ms 492 KB Output is correct
13 Correct 5 ms 364 KB Output is correct
14 Correct 6 ms 364 KB Output is correct
15 Correct 6 ms 364 KB Output is correct
16 Correct 9 ms 364 KB Output is correct
17 Correct 3 ms 364 KB Output is correct
18 Correct 5 ms 364 KB Output is correct
19 Correct 5 ms 364 KB Output is correct
20 Correct 7 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 2 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 2 ms 364 KB Output is correct
9 Correct 2 ms 364 KB Output is correct
10 Correct 7 ms 364 KB Output is correct
11 Correct 7 ms 364 KB Output is correct
12 Correct 7 ms 492 KB Output is correct
13 Correct 5 ms 364 KB Output is correct
14 Correct 6 ms 364 KB Output is correct
15 Correct 6 ms 364 KB Output is correct
16 Correct 9 ms 364 KB Output is correct
17 Correct 3 ms 364 KB Output is correct
18 Correct 5 ms 364 KB Output is correct
19 Correct 5 ms 364 KB Output is correct
20 Correct 7 ms 364 KB Output is correct
21 Correct 28 ms 492 KB Output is correct
22 Correct 37 ms 492 KB Output is correct
23 Correct 17 ms 492 KB Output is correct
24 Correct 60 ms 492 KB Output is correct
25 Correct 60 ms 492 KB Output is correct
26 Correct 68 ms 492 KB Output is correct
27 Correct 69 ms 492 KB Output is correct
28 Correct 70 ms 492 KB Output is correct
29 Correct 68 ms 492 KB Output is correct
30 Correct 66 ms 492 KB Output is correct
31 Correct 69 ms 492 KB Output is correct
32 Correct 67 ms 492 KB Output is correct
33 Correct 67 ms 620 KB Output is correct
34 Correct 67 ms 492 KB Output is correct
35 Correct 80 ms 492 KB Output is correct
36 Correct 67 ms 492 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 2 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 2 ms 364 KB Output is correct
9 Correct 2 ms 364 KB Output is correct
10 Correct 7 ms 364 KB Output is correct
11 Correct 7 ms 364 KB Output is correct
12 Correct 7 ms 492 KB Output is correct
13 Correct 5 ms 364 KB Output is correct
14 Correct 6 ms 364 KB Output is correct
15 Correct 6 ms 364 KB Output is correct
16 Correct 9 ms 364 KB Output is correct
17 Correct 3 ms 364 KB Output is correct
18 Correct 5 ms 364 KB Output is correct
19 Correct 5 ms 364 KB Output is correct
20 Correct 7 ms 364 KB Output is correct
21 Correct 28 ms 492 KB Output is correct
22 Correct 37 ms 492 KB Output is correct
23 Correct 17 ms 492 KB Output is correct
24 Correct 60 ms 492 KB Output is correct
25 Correct 60 ms 492 KB Output is correct
26 Correct 68 ms 492 KB Output is correct
27 Correct 69 ms 492 KB Output is correct
28 Correct 70 ms 492 KB Output is correct
29 Correct 68 ms 492 KB Output is correct
30 Correct 66 ms 492 KB Output is correct
31 Correct 69 ms 492 KB Output is correct
32 Correct 67 ms 492 KB Output is correct
33 Correct 67 ms 620 KB Output is correct
34 Correct 67 ms 492 KB Output is correct
35 Correct 80 ms 492 KB Output is correct
36 Correct 67 ms 492 KB Output is correct
37 Correct 271 ms 620 KB Output is correct
38 Correct 269 ms 680 KB Output is correct
39 Correct 410 ms 620 KB Output is correct
40 Correct 494 ms 748 KB Output is correct
41 Correct 483 ms 748 KB Output is correct
42 Correct 422 ms 748 KB Output is correct
43 Correct 416 ms 1004 KB Output is correct
44 Correct 423 ms 1004 KB Output is correct
45 Correct 438 ms 1260 KB Output is correct
46 Correct 483 ms 620 KB Output is correct
47 Correct 423 ms 732 KB Output is correct
48 Correct 434 ms 1004 KB Output is correct
49 Correct 428 ms 748 KB Output is correct
50 Correct 425 ms 732 KB Output is correct
51 Correct 2 ms 364 KB Output is correct
52 Correct 503 ms 1132 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 2 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 2 ms 364 KB Output is correct
9 Correct 2 ms 364 KB Output is correct
10 Correct 7 ms 364 KB Output is correct
11 Correct 7 ms 364 KB Output is correct
12 Correct 7 ms 492 KB Output is correct
13 Correct 5 ms 364 KB Output is correct
14 Correct 6 ms 364 KB Output is correct
15 Correct 6 ms 364 KB Output is correct
16 Correct 9 ms 364 KB Output is correct
17 Correct 3 ms 364 KB Output is correct
18 Correct 5 ms 364 KB Output is correct
19 Correct 5 ms 364 KB Output is correct
20 Correct 7 ms 364 KB Output is correct
21 Correct 28 ms 492 KB Output is correct
22 Correct 37 ms 492 KB Output is correct
23 Correct 17 ms 492 KB Output is correct
24 Correct 60 ms 492 KB Output is correct
25 Correct 60 ms 492 KB Output is correct
26 Correct 68 ms 492 KB Output is correct
27 Correct 69 ms 492 KB Output is correct
28 Correct 70 ms 492 KB Output is correct
29 Correct 68 ms 492 KB Output is correct
30 Correct 66 ms 492 KB Output is correct
31 Correct 69 ms 492 KB Output is correct
32 Correct 67 ms 492 KB Output is correct
33 Correct 67 ms 620 KB Output is correct
34 Correct 67 ms 492 KB Output is correct
35 Correct 80 ms 492 KB Output is correct
36 Correct 67 ms 492 KB Output is correct
37 Correct 271 ms 620 KB Output is correct
38 Correct 269 ms 680 KB Output is correct
39 Correct 410 ms 620 KB Output is correct
40 Correct 494 ms 748 KB Output is correct
41 Correct 483 ms 748 KB Output is correct
42 Correct 422 ms 748 KB Output is correct
43 Correct 416 ms 1004 KB Output is correct
44 Correct 423 ms 1004 KB Output is correct
45 Correct 438 ms 1260 KB Output is correct
46 Correct 483 ms 620 KB Output is correct
47 Correct 423 ms 732 KB Output is correct
48 Correct 434 ms 1004 KB Output is correct
49 Correct 428 ms 748 KB Output is correct
50 Correct 425 ms 732 KB Output is correct
51 Correct 2 ms 364 KB Output is correct
52 Correct 503 ms 1132 KB Output is correct
53 Correct 606 ms 916 KB Output is correct
54 Correct 831 ms 1132 KB Output is correct
55 Correct 848 ms 1432 KB Output is correct
56 Correct 636 ms 1132 KB Output is correct
57 Correct 846 ms 1648 KB Output is correct
58 Correct 828 ms 1132 KB Output is correct
59 Correct 852 ms 1264 KB Output is correct
60 Correct 3 ms 364 KB Output is correct
61 Correct 862 ms 1392 KB Output is correct
62 Correct 706 ms 1372 KB Output is correct
63 Correct 712 ms 1520 KB Output is correct
64 Correct 685 ms 1520 KB Output is correct
65 Correct 658 ms 620 KB Output is correct
66 Correct 637 ms 748 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 2 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 2 ms 364 KB Output is correct
9 Correct 2 ms 364 KB Output is correct
10 Correct 7 ms 364 KB Output is correct
11 Correct 7 ms 364 KB Output is correct
12 Correct 7 ms 492 KB Output is correct
13 Correct 5 ms 364 KB Output is correct
14 Correct 6 ms 364 KB Output is correct
15 Correct 6 ms 364 KB Output is correct
16 Correct 9 ms 364 KB Output is correct
17 Correct 3 ms 364 KB Output is correct
18 Correct 5 ms 364 KB Output is correct
19 Correct 5 ms 364 KB Output is correct
20 Correct 7 ms 364 KB Output is correct
21 Correct 28 ms 492 KB Output is correct
22 Correct 37 ms 492 KB Output is correct
23 Correct 17 ms 492 KB Output is correct
24 Correct 60 ms 492 KB Output is correct
25 Correct 60 ms 492 KB Output is correct
26 Correct 68 ms 492 KB Output is correct
27 Correct 69 ms 492 KB Output is correct
28 Correct 70 ms 492 KB Output is correct
29 Correct 68 ms 492 KB Output is correct
30 Correct 66 ms 492 KB Output is correct
31 Correct 69 ms 492 KB Output is correct
32 Correct 67 ms 492 KB Output is correct
33 Correct 67 ms 620 KB Output is correct
34 Correct 67 ms 492 KB Output is correct
35 Correct 80 ms 492 KB Output is correct
36 Correct 67 ms 492 KB Output is correct
37 Correct 271 ms 620 KB Output is correct
38 Correct 269 ms 680 KB Output is correct
39 Correct 410 ms 620 KB Output is correct
40 Correct 494 ms 748 KB Output is correct
41 Correct 483 ms 748 KB Output is correct
42 Correct 422 ms 748 KB Output is correct
43 Correct 416 ms 1004 KB Output is correct
44 Correct 423 ms 1004 KB Output is correct
45 Correct 438 ms 1260 KB Output is correct
46 Correct 483 ms 620 KB Output is correct
47 Correct 423 ms 732 KB Output is correct
48 Correct 434 ms 1004 KB Output is correct
49 Correct 428 ms 748 KB Output is correct
50 Correct 425 ms 732 KB Output is correct
51 Correct 2 ms 364 KB Output is correct
52 Correct 503 ms 1132 KB Output is correct
53 Correct 606 ms 916 KB Output is correct
54 Correct 831 ms 1132 KB Output is correct
55 Correct 848 ms 1432 KB Output is correct
56 Correct 636 ms 1132 KB Output is correct
57 Correct 846 ms 1648 KB Output is correct
58 Correct 828 ms 1132 KB Output is correct
59 Correct 852 ms 1264 KB Output is correct
60 Correct 3 ms 364 KB Output is correct
61 Correct 862 ms 1392 KB Output is correct
62 Correct 706 ms 1372 KB Output is correct
63 Correct 712 ms 1520 KB Output is correct
64 Correct 685 ms 1520 KB Output is correct
65 Correct 658 ms 620 KB Output is correct
66 Correct 637 ms 748 KB Output is correct
67 Execution timed out 1087 ms 748 KB Time limit exceeded
68 Halted 0 ms 0 KB -