Submission #36945

#TimeUsernameProblemLanguageResultExecution timeMemory
36945nickyrioBootfall (IZhO17_bootfall)C++14
28 / 100
1000 ms169104 KiB
#include <bits/stdc++.h> #define FOR(i, a, b) for (int i = a; i<= b; ++i) #define FORD(i, a, b) for (int i = a; i>=b; --i) #define REP(i, a) for (int i = 0; i<a; ++i) #define N 555 #define pp pair<int, int> #define bit(S, i) (((S) >> i) & 1) #define IO cin.tie(NULL);cout.tie(NULL); #define taskname "BOOTFALL" using namespace std; int n, a[N]; bool dp[N][N * N]; vector<int> res; int main() { // freopen(taskname".inp","r",stdin); // freopen(taskname".out","w",stdout); IO; scanf("%d", &n); int all = 0; FOR(i, 1, n) scanf("%d", &a[i]); FOR(i, 1, n) all += a[i]; FOR(banned, 0, n) { dp[banned][0] = true; FOR(i, 1, n) if (i != banned) { FORD(S, all, a[i]) { if (dp[banned][S - a[i]]) { dp[banned][S] = true; } } } // FOR(S, 0, all) if (dp[banned][S]) cerr << S << ' '; cerr << endl; } FOR(value, 1, all) { bool ok = true; if (all % 2 != 0 || dp[0][all / 2] == false) continue; FOR(i, 1, n) { if ((all + value - a[i]) % 2 == 1 || all - a[i] < value) { ok = false; break; } else { int newMid = (all - a[i] + value) / 2; if (dp[i][newMid - value] == false) { ok = false; break; } } } if (ok) res.push_back(value); } printf("%d\n", res.size()); for (int value : res) printf("%d ", value); }

Compilation message (stderr)

bootfall.cpp: In function 'int main()':
bootfall.cpp:51:30: warning: format '%d' expects argument of type 'int', but argument 2 has type 'std::vector<int>::size_type {aka long unsigned int}' [-Wformat=]
     printf("%d\n", res.size());
                              ^
bootfall.cpp:20:20: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &n);
                    ^
bootfall.cpp:22:36: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     FOR(i, 1, n) scanf("%d", &a[i]);
                                    ^
#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...