Submission #706029

# Submission time Handle Problem Language Result Execution time Memory
706029 2023-03-05T18:51:34 Z Boomyday Bootfall (IZhO17_bootfall) C++17
13 / 100
1000 ms 412 KB
#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using ld = long double;
using db = double;
using str = string; // yay python!

using ii = 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 vii = vector<ii>;
using vpl = vector<pl>;
using vpd = vector<pd>;

#define tcT template<class T
#define tcTU tcT, class U

tcT> using V = vector<T>;
tcT, size_t SZ> using AR = array<T,SZ>;
tcT> using PR = pair<T,T>;

// pairs
#define mp make_pair
#define f first
#define s second



#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 trav(a,x) for (auto& a: x)

#define len(x) int((x).size())
#define bg(x) begin(x)
#define all(x) bg(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define sor(x) sort(all(x))
#define rsz resize
#define ins insert
#define ft front()
#define bk back()
#define pb push_back
#define eb emplace_back
#define pf push_front

const int MOD = 1e9+7; // 998244353;
const int MX = 2e5+5;
const ll INF = 1e18; // not too close to LLONG_MAX
const ld PI = acos((ld)-1);
const int dx[4] = {1,0,-1,0}, dy[4] = {0,1,0,-1}; // for every grid problem!!


vi vals;

bool is_solvable(){
    int sm = 0;
    trav(i, vals) sm += i;
    //cout << sm << endl;
    if(sm%2) return 0;
    
    sm/=2;
    bool dp[vals.size()+1][sm+1]; // PLAYER, SUM
    
    FOR(i, 0, vals.size()+1) dp[i][0] = true;
    FOR(i,1, sm+1) dp[0][i] = 0;

    FOR(player, 1, vals.size()+1){
        FOR(score,1, sm+1){
            dp[player][score] = dp[player-1][score];
            if(score-vals[player-1]>=0)
            dp[player][score] = (dp[player][score] || dp[player-1][score-vals[player-1]]);
            //cout << player << " " << score << " " << dp[player][score] << endl;
        }
    }
    return dp[vals.size()][sm];
}

int main(){
    int N;
    cin >> N;
    vals.resize(N);
    vi nums(N); 
    //vi st;
    F0R(i, nums.size()) cin >> nums[i];

    vi myNums;
    FOR(i, 1, 1000) myNums.pb(i);
    F0R(i, N) vals[i] = nums[i];
    if (!is_solvable()){
        cout << 0;
        return 0;
    }
    F0R(round, N){
        vi myNewNums;
        F0R(i, N) vals[i] = nums[i];
        trav(num, myNums){
            vals[round] = num;
            if(is_solvable()){
                myNewNums.pb(num);
            }
        }
        myNums = myNewNums;
    }
    cout << myNums.size() << endl;
    trav(i, myNums) cout << i << " ";
    cout <<endl;
    
    
    


}

Compilation message

bootfall.cpp: In function 'bool is_solvable()':
bootfall.cpp:37:40: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   37 | #define FOR(i,a,b) for (int i = (a); i < (b); ++i)
      |                                        ^
bootfall.cpp:74:5: note: in expansion of macro 'FOR'
   74 |     FOR(i, 0, vals.size()+1) dp[i][0] = true;
      |     ^~~
bootfall.cpp:37:40: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   37 | #define FOR(i,a,b) for (int i = (a); i < (b); ++i)
      |                                        ^
bootfall.cpp:77:5: note: in expansion of macro 'FOR'
   77 |     FOR(player, 1, vals.size()+1){
      |     ^~~
bootfall.cpp: In function 'int main()':
bootfall.cpp:37:40: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   37 | #define FOR(i,a,b) for (int i = (a); i < (b); ++i)
      |                                        ^
bootfall.cpp:38:18: note: in expansion of macro 'FOR'
   38 | #define F0R(i,a) FOR(i,0,a)
      |                  ^~~
bootfall.cpp:94:5: note: in expansion of macro 'F0R'
   94 |     F0R(i, nums.size()) cin >> nums[i];
      |     ^~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 2 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 2 ms 212 KB Output is correct
5 Correct 26 ms 300 KB Output is correct
6 Correct 2 ms 212 KB Output is correct
7 Correct 2 ms 212 KB Output is correct
8 Correct 39 ms 212 KB Output is correct
9 Correct 4 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 2 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 2 ms 212 KB Output is correct
5 Correct 26 ms 300 KB Output is correct
6 Correct 2 ms 212 KB Output is correct
7 Correct 2 ms 212 KB Output is correct
8 Correct 39 ms 212 KB Output is correct
9 Correct 4 ms 212 KB Output is correct
10 Correct 16 ms 300 KB Output is correct
11 Correct 29 ms 304 KB Output is correct
12 Correct 10 ms 316 KB Output is correct
13 Correct 6 ms 212 KB Output is correct
14 Correct 32 ms 212 KB Output is correct
15 Correct 20 ms 212 KB Output is correct
16 Correct 28 ms 324 KB Output is correct
17 Correct 9 ms 212 KB Output is correct
18 Correct 19 ms 212 KB Output is correct
19 Correct 16 ms 300 KB Output is correct
20 Correct 16 ms 320 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 2 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 2 ms 212 KB Output is correct
5 Correct 26 ms 300 KB Output is correct
6 Correct 2 ms 212 KB Output is correct
7 Correct 2 ms 212 KB Output is correct
8 Correct 39 ms 212 KB Output is correct
9 Correct 4 ms 212 KB Output is correct
10 Correct 16 ms 300 KB Output is correct
11 Correct 29 ms 304 KB Output is correct
12 Correct 10 ms 316 KB Output is correct
13 Correct 6 ms 212 KB Output is correct
14 Correct 32 ms 212 KB Output is correct
15 Correct 20 ms 212 KB Output is correct
16 Correct 28 ms 324 KB Output is correct
17 Correct 9 ms 212 KB Output is correct
18 Correct 19 ms 212 KB Output is correct
19 Correct 16 ms 300 KB Output is correct
20 Correct 16 ms 320 KB Output is correct
21 Execution timed out 1082 ms 412 KB Time limit exceeded
22 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 2 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 2 ms 212 KB Output is correct
5 Correct 26 ms 300 KB Output is correct
6 Correct 2 ms 212 KB Output is correct
7 Correct 2 ms 212 KB Output is correct
8 Correct 39 ms 212 KB Output is correct
9 Correct 4 ms 212 KB Output is correct
10 Correct 16 ms 300 KB Output is correct
11 Correct 29 ms 304 KB Output is correct
12 Correct 10 ms 316 KB Output is correct
13 Correct 6 ms 212 KB Output is correct
14 Correct 32 ms 212 KB Output is correct
15 Correct 20 ms 212 KB Output is correct
16 Correct 28 ms 324 KB Output is correct
17 Correct 9 ms 212 KB Output is correct
18 Correct 19 ms 212 KB Output is correct
19 Correct 16 ms 300 KB Output is correct
20 Correct 16 ms 320 KB Output is correct
21 Execution timed out 1082 ms 412 KB Time limit exceeded
22 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 2 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 2 ms 212 KB Output is correct
5 Correct 26 ms 300 KB Output is correct
6 Correct 2 ms 212 KB Output is correct
7 Correct 2 ms 212 KB Output is correct
8 Correct 39 ms 212 KB Output is correct
9 Correct 4 ms 212 KB Output is correct
10 Correct 16 ms 300 KB Output is correct
11 Correct 29 ms 304 KB Output is correct
12 Correct 10 ms 316 KB Output is correct
13 Correct 6 ms 212 KB Output is correct
14 Correct 32 ms 212 KB Output is correct
15 Correct 20 ms 212 KB Output is correct
16 Correct 28 ms 324 KB Output is correct
17 Correct 9 ms 212 KB Output is correct
18 Correct 19 ms 212 KB Output is correct
19 Correct 16 ms 300 KB Output is correct
20 Correct 16 ms 320 KB Output is correct
21 Execution timed out 1082 ms 412 KB Time limit exceeded
22 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 2 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 2 ms 212 KB Output is correct
5 Correct 26 ms 300 KB Output is correct
6 Correct 2 ms 212 KB Output is correct
7 Correct 2 ms 212 KB Output is correct
8 Correct 39 ms 212 KB Output is correct
9 Correct 4 ms 212 KB Output is correct
10 Correct 16 ms 300 KB Output is correct
11 Correct 29 ms 304 KB Output is correct
12 Correct 10 ms 316 KB Output is correct
13 Correct 6 ms 212 KB Output is correct
14 Correct 32 ms 212 KB Output is correct
15 Correct 20 ms 212 KB Output is correct
16 Correct 28 ms 324 KB Output is correct
17 Correct 9 ms 212 KB Output is correct
18 Correct 19 ms 212 KB Output is correct
19 Correct 16 ms 300 KB Output is correct
20 Correct 16 ms 320 KB Output is correct
21 Execution timed out 1082 ms 412 KB Time limit exceeded
22 Halted 0 ms 0 KB -