제출 #36065

#제출 시각아이디문제언어결과실행 시간메모리
36065UncleGrandpa925Bootfall (IZhO17_bootfall)C++14
0 / 100
0 ms3972 KiB
/*input 4 1 3 1 5 */ #include <bits/stdc++.h> using namespace std; #define sp ' ' #define endl '\n' #define fi first #define se second #define mp make_pair #define N 505 #define bit(x,y) ((x>>y)&1LL) #define na(x) (#x) << ":" << x ostream& operator << (ostream &os, vector<int>&x) { for (int i = 0; i < x.size(); i++) os << x[i] << sp; return os; } ostream& operator << (ostream &os, pair<int, int> x) { cout << x.fi << sp << x.se << sp; return os; } ostream& operator << (ostream &os, vector<pair<int, int> >&x) { for (int i = 0; i < x.size(); i++) os << x[i] << endl; return os; } const int mod = 1e9 + 7; int n; int a[N]; int f[250005]; int sum = 0; int mark[250005]; vector<int> order; bool used[N]; void add(int x) { for (int i = sum; i >= 0; i--) { f[i + x] += f[i]; if (f[i + x] >= mod) f[i + x] -= mod; } sum += x; } void sub(int x) { for (int i = 0; i <= sum; i++) { f[i + x] += (mod - f[i]); if (f[i + x] >= mod) f[i + x] -= mod; } sum -= x; } signed main() { scanf("%d", &n); f[0] = 1; for (int i = 1; i <= n; i++) scanf("%d", &a[i]), add(a[i]); if (sum % 2 || f[sum / 2] == 0) { printf("0\n"); return 0; } for (int i = 1; i <= n; i++) { if (used[a[i]]) continue; used[a[i]] = true; sub(a[i]); int sta = 1; if (sum % 2 == 0) sta++; for (int j = sta; j <= sum; j += 2) { if (f[(sum + j) / 2 - j]) mark[j]++; } add(a[i]); } for (int i = 1; i <= sum; i++) if (mark[i] == n) order.push_back(i); printf("%d\n", order.size()); for (int i = 0; i < order.size(); i++) { printf("%d ", order[i]); } }

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

bootfall.cpp: In function 'std::ostream& operator<<(std::ostream&, std::vector<int>&)':
bootfall.cpp:16:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (int i = 0; i < x.size(); i++) os << x[i] << sp;
                    ^
bootfall.cpp: In function 'std::ostream& operator<<(std::ostream&, std::vector<std::pair<int, int> >&)':
bootfall.cpp:24:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (int i = 0; i < x.size(); i++) os << x[i] << endl;
                    ^
bootfall.cpp: In function 'int main()':
bootfall.cpp:73:29: 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", order.size());
                             ^
bootfall.cpp:74:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (int i = 0; i < order.size(); i++) {
                    ^
bootfall.cpp:54:17: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &n);
                 ^
bootfall.cpp:56:60: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]), add(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...