Submission #418062

# Submission time Handle Problem Language Result Execution time Memory
418062 2021-06-05T01:49:46 Z JerryLiu06 Bootfall (IZhO17_bootfall) C++17
0 / 100
7 ms 1356 KB
#include <bits/stdc++.h>
 
using namespace std;
 
using ll = long long;
using ld = long double;
using db = double;
using str = string;
 
using pi = pair<int, int>;
using pl = pair<ll, ll>;
using pd = pair<db, db>;
 
using vi = vector<int>;
using vb = vector<bool>;
using vl = vector<ll>;
using vd = vector<db>;
using vs = vector<str>;
using vpi = vector<pi>;
using vpl = vector<pl>;
using vpd = vector<pd>;
 
#define mp make_pair
#define f first
#define s second
 
#define sz(x) (int)(x).size()
#define bg(x) begin(x)
#define all(x) bg(x), end(x)
#define sor(x) sort(all(x))
#define ft front()
#define bk back()
#define pb push_back
#define pf push_front
 
#define lb lower_bound
#define ub upper_bound
 
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)
#define EACH(a,x) for (auto& a: x)
 
const int MOD = 1e9 + 7;
const int MX = 510;
const ll INF = 1e18;

int N, A[MX], tot; int DP[MX * MX]; bitset<MX * MX> ans;

void ADD(int val) {
    tot += val; ROF(i, val, MX * MX) {
        DP[i] += DP[i - val]; if (DP[i] > MOD) DP[i] -= MOD;
    }
}
void DEL(int val) {
    tot -= val; FOR(i, val, MX * MX) {
        DP[i] -= DP[i - val]; if (DP[i] < 0) DP[i] += MOD;
    }
}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    
    ans.flip(); cin >> N; DP[0] = 1; F0R(i, N) cin >> A[i], ADD(A[i]);

    F0R(i, N) {
        DEL(A[i]); bitset<MX * MX> cur;

        F0R(j, tot / 2 + 1) if (DP[j]) cur[tot - 2 * j] = 1; ADD(A[i]); ans &= cur;
    }
    vi res; FOR(i, 1, MX * MX) if (ans[i]) res.pb(i); cout << sz(res) << "\n"; EACH(i, res) cout << i << " ";
}

Compilation message

bootfall.cpp: In function 'int main()':
bootfall.cpp:39:20: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   39 | #define FOR(i,a,b) for (int i = (a); i < (b); ++i)
      |                    ^~~
bootfall.cpp:40:18: note: in expansion of macro 'FOR'
   40 | #define F0R(i,a) FOR(i,0,a)
      |                  ^~~
bootfall.cpp:70:9: note: in expansion of macro 'F0R'
   70 |         F0R(j, tot / 2 + 1) if (DP[j]) cur[tot - 2 * j] = 1; ADD(A[i]); ans &= cur;
      |         ^~~
bootfall.cpp:70:62: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   70 |         F0R(j, tot / 2 + 1) if (DP[j]) cur[tot - 2 * j] = 1; ADD(A[i]); ans &= cur;
      |                                                              ^~~
# Verdict Execution time Memory Grader output
1 Correct 7 ms 1356 KB Output is correct
2 Correct 7 ms 1276 KB Output is correct
3 Incorrect 6 ms 1356 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 7 ms 1356 KB Output is correct
2 Correct 7 ms 1276 KB Output is correct
3 Incorrect 6 ms 1356 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 7 ms 1356 KB Output is correct
2 Correct 7 ms 1276 KB Output is correct
3 Incorrect 6 ms 1356 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 7 ms 1356 KB Output is correct
2 Correct 7 ms 1276 KB Output is correct
3 Incorrect 6 ms 1356 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 7 ms 1356 KB Output is correct
2 Correct 7 ms 1276 KB Output is correct
3 Incorrect 6 ms 1356 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 7 ms 1356 KB Output is correct
2 Correct 7 ms 1276 KB Output is correct
3 Incorrect 6 ms 1356 KB Output isn't correct
4 Halted 0 ms 0 KB -