제출 #1128100

#제출 시각아이디문제언어결과실행 시간메모리
1128100BilAktauAlmansurBootfall (IZhO17_bootfall)C++20
65 / 100
1035 ms1704 KiB
#include <bits/stdc++.h> #pragma optimize("g", on) #pragma GCC optimize ("inline") #pragma GCC optimize ("Ofast") #pragma GCC optimize ("unroll-loops") #pragma GCC optimize ("03") #pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,avx2,mmx,fma,avx,tune=native") void Freopen () { #ifndef ONLINE_JUDGE freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif } using namespace std; #define fi first #define se second // #define int long long const int N = 250000 + 7, M = 250000; short int n, a[507]; bitset<N> us; signed main() { // freopen("duty.in", "r", stdin); // freopen("duty.out", "w", stdout); ios_base::sync_with_stdio(false); cin.tie(NULL); // cout.tie(NULL); // Freopen(); cin>>n; for(short int i = 1; i <= n; i++) { cin>>a[i]; } sort(a + 1, a + 1 + n); int need = accumulate(a + 1, a + 1 + n, 0); for(int i = 1; i <= need; i++)us[i] = 1; if(need % 2 == 1) { cout << "0\n"; return 0 ; } need /= 2; bitset<M> st; st[0] = 1; for(short int i = 1; i <= n; i++)st |= (st << a[i]); if(!st[need]) { cout << "0\n"; return 0; } need *= 2; for(int j = 1; j <= n; j++) { st.reset(); st[0] = 1; for(int i = 1; i <= n; i++) { if(i == j)continue; st |= (st << a[i]); } int s = 1; if(a[1] % 2 == 0)s ++; for(int i = s; i <= need; i += 2) { if(!us[i])continue; int W = need + i - a[j]; if(W % 2 == 1) { us[i] = 0; continue; } if(!st[W / 2]) { us[i] = 0; } } } vector<int> ans; int s = 1; if(a[1] % 2 == 0)s ++; for(int i = s; i <= need; i += 2)if(us[i])ans.push_back(i); cout << ans.size() << '\n'; for(auto j : ans)cout << j << ' '; cout << '\n'; } /* please AC */

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

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