제출 #1128249

#제출 시각아이디문제언어결과실행 시간메모리
1128249_TemirhanBootfall (IZhO17_bootfall)C++20
100 / 100
773 ms4084 KiB
#include <bits/stdc++.h> using namespace std; #define int long long #define pb push_back #define sz(x) x.size() #define F first #define S second #define nl '\n' void Tima() { #ifndef ONLINE_JUDGE freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif } const int N = 500 * 500 + 1; const int inf = 1e12; const int mod = 1e9 + 7; signed main() { // Tima(); ios_base::sync_with_stdio(0); cin.tie(0); int n; cin >>n; int a[n + 1], sum = 0; for( int i = 1; i <= n; ++i ) { cin >>a[i]; sum += a[i]; } vector< int >dp(N, 0); dp[0] = 1; for( int i = 1; i <= n; ++i ) for( int w = N - 1; w >= a[i]; --w ) dp[w] = (dp[w] + dp[w - a[i]]) % mod; if( (sum & 1) || !dp[sum / 2] ) { cout <<0; return 0; } vector< bool >ch(N, 1); for( int i = 1; i <= n; ++i ) { for( int w = a[i]; w < N; ++w ) dp[w] = (dp[w] - dp[w - a[i]] + mod) % mod; for( int s = 1; s < N; ++s ) if( (sum - a[i] + s) % 2 == 1 || !dp[(sum - a[i] + s) / 2] ) ch[s] = false; for( int w = N - 1; w >= a[i]; --w ) dp[w] = (dp[w] + dp[w - a[i]]) % mod; } vector< int >ans; for( int i = 1; i < N; ++i ) if( ch[i] ) ans.pb( i ); cout <<sz(ans) <<nl; for( int i: ans ) cout <<i <<' '; }

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

bootfall.cpp: In function 'void Tima()':
bootfall.cpp:15:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |     freopen("input.txt", "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
bootfall.cpp:16:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 |     freopen("output.txt", "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...