Submission #575103

#TimeUsernameProblemLanguageResultExecution timeMemory
575103MohammadAghilBootfall (IZhO17_bootfall)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> // #pragma GCC optimize ("Ofast,unroll-loops") // #pragma GCC target ("avx2") using namespace std; typedef long long ll; typedef pair<int, int> pp; #define er(args ...) cerr << __LINE__ << ": ", err(new istringstream(string(#args)), args), cerr << endl #define per(i,r,l) for(int i = (r); i >= (l); i--) #define rep(i,l,r) for(int i = (l); i < (r); i++) #define all(x) x.begin(), x.end() #define sz(x) (int)(x).size() #define pb push_back #define ss second #define ff first void err(istringstream *iss){}template<typename T,typename ...Args> void err(istringstream *iss,const T &_val, const Args&...args){string _name;*iss>>_name;if(_name.back()==',')_name.pop_back();cerr<<_name<<" = "<<_val<<", ",err(iss,args...);} mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); const ll mod = 1e9 + 7, maxn = 1e3+5, lg = 20, inf = ll(1e9) + 5; ll pw(ll a,ll b,ll md=mod){if(!b)return 1;ll k=pw(a,b>>1ll);return k*k%md*(b&1ll?a:1)%md;} int dp[maxn][maxn*maxn]; int main(){ cin.tie(0) -> sync_with_stdio(0); int n; cin >> n; vector<int> a(n); int sum = 0; rep(i,0,n) cin >> a[i], sum += a[i]; dp[n][0] = 1; rep(i,0,n) per(j,sum,a[i]) dp[n][j] += dp[n][j-a[i]], dp[n][j] -= dp[n][j]<mod?0:mod; rep(k,0,n){ rep(i,0,sum+1) dp[k][i] = dp[n][i]; rep(j,a[k],sum+1) dp[k][j] -= dp[k][j-a[k]], dp[k][j] += dp[k][j]<0?mod:0; } // rep(k,0,n+1) rep(i,0,sum) er(k, i, dp[k][i]); if((sum&1) || !dp[n][sum>>1]) return cout << "0\n", 0; rep(i,0,n) if(a[i]%2 != a[0]%2) return cout << "0\n", 0; vector<int> ans; rep(i,1,sum+1) if(i%2 == a[0]%2){ bool ok = true; rep(j,0,n){ int t = (sum - a[j] + i)>>1; if(t > sum || !dp[j][t]) { ok = false; break; } } if(ok) ans.pb(i); } cout << sz(ans) << '\n'; for(int c: ans) cout << c << ' '; if(sz(ans)) cout << '\n'; return 0; }

Compilation message (stderr)

/tmp/ccnti5zl.o: in function `main':
bootfall.cpp:(.text.startup+0x27): relocation truncated to fit: R_X86_64_PC32 against symbol `std::cin' defined in .bss._ZSt3cin section in /usr/lib/gcc/x86_64-linux-gnu/10/libstdc++.a(globals_io.o)
bootfall.cpp:(.text.startup+0x3c): relocation truncated to fit: R_X86_64_PC32 against symbol `std::cin' defined in .bss._ZSt3cin section in /usr/lib/gcc/x86_64-linux-gnu/10/libstdc++.a(globals_io.o)
bootfall.cpp:(.text.startup+0xd5): relocation truncated to fit: R_X86_64_PC32 against symbol `std::cin' defined in .bss._ZSt3cin section in /usr/lib/gcc/x86_64-linux-gnu/10/libstdc++.a(globals_io.o)
bootfall.cpp:(.text.startup+0x2ef): relocation truncated to fit: R_X86_64_PC32 against symbol `std::cout' defined in .bss._ZSt4cout section in /usr/lib/gcc/x86_64-linux-gnu/10/libstdc++.a(globals_io.o)
bootfall.cpp:(.text.startup+0x44b): relocation truncated to fit: R_X86_64_PC32 against symbol `std::cout' defined in .bss._ZSt4cout section in /usr/lib/gcc/x86_64-linux-gnu/10/libstdc++.a(globals_io.o)
bootfall.cpp:(.text.startup+0x48d): relocation truncated to fit: R_X86_64_PC32 against symbol `std::cout' defined in .bss._ZSt4cout section in /usr/lib/gcc/x86_64-linux-gnu/10/libstdc++.a(globals_io.o)
bootfall.cpp:(.text.startup+0x4d8): relocation truncated to fit: R_X86_64_PC32 against symbol `std::cout' defined in .bss._ZSt4cout section in /usr/lib/gcc/x86_64-linux-gnu/10/libstdc++.a(globals_io.o)
/tmp/ccnti5zl.o: in function `_GLOBAL__sub_I__Z3errPNSt7__cxx1119basic_istringstreamIcSt11char_traitsIcESaIcEEE':
bootfall.cpp:(.text.startup+0x53b): relocation truncated to fit: R_X86_64_PC32 against `.bss'
bootfall.cpp:(.text.startup+0x555): relocation truncated to fit: R_X86_64_PC32 against `.bss'
bootfall.cpp:(.text.startup+0x566): relocation truncated to fit: R_X86_64_PC32 against symbol `rng' defined in .bss section in /tmp/ccnti5zl.o
bootfall.cpp:(.text.startup+0x578): additional relocation overflows omitted from the output
/usr/bin/ld: failed to convert GOTPCREL relocation; relink with --no-relax
collect2: error: ld returned 1 exit status