Submission #685223

#TimeUsernameProblemLanguageResultExecution timeMemory
685223tolbiBootfall (IZhO17_bootfall)C++17
28 / 100
634 ms262144 KiB
#pragma optimize("Bismillahirrahmanirrahim") //█▀█─█──█──█▀█─█─█ //█▄█─█──█──█▄█─█■█ //█─█─█▄─█▄─█─█─█─█ //Allahuekber //ahmet23 orz... //FatihSultanMehmedHan //YavuzSultanSelimHan //AbdulhamidHan //Sani buyuk Osman Pasa Plevneden cikmam diyor. #define author tolbi #include<bits/stdc++.h> #define endl '\n' #define deci(x) int x;cin>>x; #define decstr(x) string x;cin>>x; #define vint(x) vector<int> x #define cinarr(x) for (auto &it : x) cin>>it; #define coutarr(x) for (auto &it : x) cout<<it<<" ";cout<<endl; #define sortarr(x) sort(x.begin(), x.end()) #define sortrarr(x) sort(x.rbegin(), x.rend()) #define revarr(x) reverse(x.begin(), x.end()) #define tol(bi) (1LL<<((int)(bi))) #define INF LONG_LONG_MAX using namespace std; mt19937 ayahya(chrono::high_resolution_clock().now().time_since_epoch().count()); const int MOD = 1e9+7; int32_t main(){ int T=1; int tno=0; if (!T) cin>>T; while (T-(tno++)){ deci(n); vint(arr(n)); cinarr(arr); int somma = 0; for (int i = 0; i < n; i++) somma+=arr[i]; vector<vector<vector<bitset<512>>>> dp(n+1,vector<vector<bitset<512>>>(somma+1,vector<bitset<512>>(2))); vector<vector<vector<bool>>> vis(n+1,vector<vector<bool>>(somma+1,vector<bool>(2,false))); bitset<512> dolu; for (int i = 0; i < n; i++){ dolu[i]=true; } auto f = [&](int node, int crr, int flag, auto rec)->bitset<512>{ crr=abs(crr); bitset<512> rval; if (node==0){ if (crr==0 && flag) return dolu; return rval; } if (crr>somma) return rval; if (vis[node][crr][flag]) return dp[node][crr][flag]; vis[node][crr][flag]=true; if (flag){ rval = (rec(node-1,crr+arr[node-1],flag,rec)|rec(node-1,crr-arr[node-1],flag,rec)); } else { bitset<512> kk = rval; kk[node-1]=true; rval|=rec(node-1,crr-arr[node-1],flag,rec); rval|=rec(node-1,crr+arr[node-1],flag,rec); kk&=rec(node-1,crr,1,rec); rval|=kk; } return dp[node][crr][flag]=rval; }; if (f(n,0,1,f).count()==0){ cout<<0<<endl; continue; } vector<int> say; for (int i = 1; i < somma; i++){ if (f(n,i,0,f).count()==n){ say.push_back(i); } } cout<<say.size()<<endl; coutarr(say); } }

Compilation message (stderr)

bootfall.cpp:1: warning: ignoring '#pragma optimize ' [-Wunknown-pragmas]
    1 | #pragma optimize("Bismillahirrahmanirrahim")
      | 
bootfall.cpp: In function 'int32_t main()':
bootfall.cpp:71:26: warning: comparison of integer expressions of different signedness: 'std::size_t' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   71 |    if (f(n,i,0,f).count()==n){
      |        ~~~~~~~~~~~~~~~~~~^~~
#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...