제출 #1280166

#제출 시각아이디문제언어결과실행 시간메모리
1280166KhanhDangBootfall (IZhO17_bootfall)C++17
0 / 100
1 ms572 KiB
#include<bits/stdc++.h>
using namespace std;
#define     ll long long
#define    pll pair<ll, ll>
#define    pii pair<int, int>
#define     fi first
#define     se second
#define all(v) (v).begin(), (v).end()
#define Unique(v) sort(all(v)); (v).erase(unique(all(v)), (v).end());
const int N = 505;
const int mod = 22071997;

int n, a[N], sum;
ll cnt[N * N];

int c[N * N];

void add(int x) {
    for (int i = sum; i >= x; i--)
        (cnt[i] += cnt[i - x]) %= mod;
}

void del(int x) {
    for (int i = x; i <= sum; i++)
        (cnt[i] += mod - cnt[i - x]) %= mod;
}

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    #define task "task"
    if (fopen(task".inp", "r")) {
        freopen(task".inp", "r", stdin);
        freopen(task".out", "w", stdout);
    }
    if (fopen("task.inp", "r")) {
        freopen("task.inp", "r", stdin);
        freopen("task.out", "w", stdout);
    }

    cin>>n;
    for (int i = 1; i <= n; i++)
        cin>>a[i], sum += a[i];

    cnt[0] = 1;

    for (int i = 1; i <= n; i++)
        add(a[i]);

    if (sum & 1 || !cnt[sum >> 1]) return cout<<0, 0;

    for (int i = 1; i <= n; i++) {
        del(a[i]);

        for (int ss = 1; ss * 2 < sum - a[i]; ss++)
            if (cnt[ss]) c[sum - a[i] - ss - ss]++;

        add(a[i]);
    }

    int ans = 0;

    for (int i = 1; i <= sum; i++)
        if (c[i] == n) ans++;

    cout<<ans<<'\n';

    for (int i = 1; i <= sum; i++)
        if (c[i] == n) cout<<i<<' ';

    cerr<<setprecision(3)<<fixed<<"Time elapsed: "<< 1.0 * clock() / CLOCKS_PER_SEC <<"s\n";
}

컴파일 시 표준 에러 (stderr) 메시지

bootfall.cpp: In function 'int main()':
bootfall.cpp:33:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   33 |         freopen(task".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
bootfall.cpp:34:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   34 |         freopen(task".out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
bootfall.cpp:37:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   37 |         freopen("task.inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
bootfall.cpp:38:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   38 |         freopen("task.out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...