답안 #950118

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
950118 2024-03-20T05:32:57 Z Pragmatism Bootfall (IZhO17_bootfall) C++17
13 / 100
1000 ms 596 KB
//Bismillahir-Rahmanir-Rahim

#include <bits/stdc++.h>
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O1,O2,O3,Ofast,unroll-loops")
#pragma GCC target("sse,sse2,sse3,sse4,sse4.1,sse4.2,popcnt,avx,avx2")

#define pb push_back
#define pii pair <int, int>
#define pll pair <long long, long long>
#define pld pair <long double, long double>
#define ll long long
#define ld long double
#define x first
#define y second
#define all(v) v.begin(),v.end()
#define sz(s) (int)s.size()
#define skip continue
#define bpop(x) (ll)__builtin_popcountll(x)

using namespace std;

const int N = 5e2 + 7;
const int W = 1e4 + 7;
const int maxA = 1e5 + 7;
const int inf = 1e9 + 7;
const ll INF = 2e18 + 7;
const int MOD = 998244353;
const ld eps = 1e-9;

pii dir[] = {{0, 1}, {1, 0}, {0, -1}, {-1, 0}};

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//clock_t start = clock();

#define int short

int n, a[N], dp[W];
void add(int x) {
    for (int w = W - 1;w >= 0;w--) {
        if (w + x < W)dp[w + x] += dp[w];
    }
    dp[x]++;
}
void del(int x) {
    dp[x]--;
    for (int w = x;w < W;w++)dp[w] -= dp[w - x];
}
bool check(int Tima) {
    for (int w = 0;w < W;w++)dp[w] = 0;
    int sum = 0;
    for (int i = 1;i <= n;i++)add(a[i]), sum += a[i];
    if (sum % 2 == 1 || !dp[sum / 2])return 0;
    add(Tima), sum += Tima;
    for (int i = 1;i <= n;i++) {
        sum -= a[i], del(a[i]);
        if (sum % 2 == 1 || !dp[sum / 2])return 0;
        sum += a[i], add(a[i]);
    }
    return 1;
}
void solve() {
    cin >> n;
    for (int i = 1;i <= n;i++)cin >> a[i];
    for (int i = 1;i <= n;i++) {
        if (a[i] % 2 != a[1] % 2)cout << 0, exit(0);
    }
    int chet = a[1] % 2;
    vector <int> ans;
    for (int Tima = chet;Tima <= 5555;Tima += 2) {
        if (check(Tima))ans.pb(Tima);
    }
    cout << sz(ans) << '\n';
    for (auto Tima : ans)cout << Tima << ' ';
}
signed main() {
    //srand(time(NULL));
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    //freopen("subsequence.in", "r", stdin);
    //freopen("subsequence.out", "w", stdout);
    int test = 1;
    //cin >> test;
    for (int t = 1;t <= test;t++) {
        //cout << "Case " << t << ": ";
        solve();
    }
    return 0;
}

Compilation message

bootfall.cpp:4: warning: ignoring '#pragma comment ' [-Wunknown-pragmas]
    4 | #pragma comment(linker, "/stack:200000000")
      |
# 결과 실행 시간 메모리 Grader output
1 Correct 117 ms 344 KB Output is correct
2 Correct 105 ms 448 KB Output is correct
3 Correct 41 ms 344 KB Output is correct
4 Correct 60 ms 344 KB Output is correct
5 Correct 159 ms 444 KB Output is correct
6 Correct 112 ms 596 KB Output is correct
7 Correct 81 ms 344 KB Output is correct
8 Correct 155 ms 344 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 117 ms 344 KB Output is correct
2 Correct 105 ms 448 KB Output is correct
3 Correct 41 ms 344 KB Output is correct
4 Correct 60 ms 344 KB Output is correct
5 Correct 159 ms 444 KB Output is correct
6 Correct 112 ms 596 KB Output is correct
7 Correct 81 ms 344 KB Output is correct
8 Correct 155 ms 344 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 351 ms 456 KB Output is correct
11 Correct 397 ms 348 KB Output is correct
12 Correct 347 ms 596 KB Output is correct
13 Correct 0 ms 344 KB Output is correct
14 Correct 365 ms 348 KB Output is correct
15 Correct 364 ms 448 KB Output is correct
16 Correct 386 ms 344 KB Output is correct
17 Correct 227 ms 344 KB Output is correct
18 Correct 335 ms 448 KB Output is correct
19 Correct 326 ms 448 KB Output is correct
20 Correct 346 ms 448 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 117 ms 344 KB Output is correct
2 Correct 105 ms 448 KB Output is correct
3 Correct 41 ms 344 KB Output is correct
4 Correct 60 ms 344 KB Output is correct
5 Correct 159 ms 444 KB Output is correct
6 Correct 112 ms 596 KB Output is correct
7 Correct 81 ms 344 KB Output is correct
8 Correct 155 ms 344 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 351 ms 456 KB Output is correct
11 Correct 397 ms 348 KB Output is correct
12 Correct 347 ms 596 KB Output is correct
13 Correct 0 ms 344 KB Output is correct
14 Correct 365 ms 348 KB Output is correct
15 Correct 364 ms 448 KB Output is correct
16 Correct 386 ms 344 KB Output is correct
17 Correct 227 ms 344 KB Output is correct
18 Correct 335 ms 448 KB Output is correct
19 Correct 326 ms 448 KB Output is correct
20 Correct 346 ms 448 KB Output is correct
21 Execution timed out 1065 ms 596 KB Time limit exceeded
22 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 117 ms 344 KB Output is correct
2 Correct 105 ms 448 KB Output is correct
3 Correct 41 ms 344 KB Output is correct
4 Correct 60 ms 344 KB Output is correct
5 Correct 159 ms 444 KB Output is correct
6 Correct 112 ms 596 KB Output is correct
7 Correct 81 ms 344 KB Output is correct
8 Correct 155 ms 344 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 351 ms 456 KB Output is correct
11 Correct 397 ms 348 KB Output is correct
12 Correct 347 ms 596 KB Output is correct
13 Correct 0 ms 344 KB Output is correct
14 Correct 365 ms 348 KB Output is correct
15 Correct 364 ms 448 KB Output is correct
16 Correct 386 ms 344 KB Output is correct
17 Correct 227 ms 344 KB Output is correct
18 Correct 335 ms 448 KB Output is correct
19 Correct 326 ms 448 KB Output is correct
20 Correct 346 ms 448 KB Output is correct
21 Execution timed out 1065 ms 596 KB Time limit exceeded
22 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 117 ms 344 KB Output is correct
2 Correct 105 ms 448 KB Output is correct
3 Correct 41 ms 344 KB Output is correct
4 Correct 60 ms 344 KB Output is correct
5 Correct 159 ms 444 KB Output is correct
6 Correct 112 ms 596 KB Output is correct
7 Correct 81 ms 344 KB Output is correct
8 Correct 155 ms 344 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 351 ms 456 KB Output is correct
11 Correct 397 ms 348 KB Output is correct
12 Correct 347 ms 596 KB Output is correct
13 Correct 0 ms 344 KB Output is correct
14 Correct 365 ms 348 KB Output is correct
15 Correct 364 ms 448 KB Output is correct
16 Correct 386 ms 344 KB Output is correct
17 Correct 227 ms 344 KB Output is correct
18 Correct 335 ms 448 KB Output is correct
19 Correct 326 ms 448 KB Output is correct
20 Correct 346 ms 448 KB Output is correct
21 Execution timed out 1065 ms 596 KB Time limit exceeded
22 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 117 ms 344 KB Output is correct
2 Correct 105 ms 448 KB Output is correct
3 Correct 41 ms 344 KB Output is correct
4 Correct 60 ms 344 KB Output is correct
5 Correct 159 ms 444 KB Output is correct
6 Correct 112 ms 596 KB Output is correct
7 Correct 81 ms 344 KB Output is correct
8 Correct 155 ms 344 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 351 ms 456 KB Output is correct
11 Correct 397 ms 348 KB Output is correct
12 Correct 347 ms 596 KB Output is correct
13 Correct 0 ms 344 KB Output is correct
14 Correct 365 ms 348 KB Output is correct
15 Correct 364 ms 448 KB Output is correct
16 Correct 386 ms 344 KB Output is correct
17 Correct 227 ms 344 KB Output is correct
18 Correct 335 ms 448 KB Output is correct
19 Correct 326 ms 448 KB Output is correct
20 Correct 346 ms 448 KB Output is correct
21 Execution timed out 1065 ms 596 KB Time limit exceeded
22 Halted 0 ms 0 KB -