Submission #1008308

#TimeUsernameProblemLanguageResultExecution timeMemory
1008308AlmontherBootfall (IZhO17_bootfall)C++98
28 / 100
1068 ms79192 KiB
#include <bits/stdc++.h> #define suiii ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); #define ll long long #define co cout<< #pragma GCC optimize("O3,Ofast,unroll-loops") #pragma GCC target("avx2,sse3,sse4,avx") using namespace std; //stuff int vis[275][270*270+5]; int arr[275]; int skipped; int ans=0; int n,wholesum=0; int mp[275*275+5]; int sum=0; void rec(int x){ if(vis[x][sum]||ans) return; if(skipped==x){ rec(x+1); return; } if(x==n+1){ if(sum==wholesum-sum) ans=1; return; } vis[x][sum]=1; if(x==n){ ll k=wholesum-sum; mp[abs(sum-k)]++; return; } sum+=arr[x]; rec(x+1); sum-=arr[x]; rec(x+1); } void solve(){ cin>>n; for(int i=0;i<n;i++){ cin>>arr[i]; wholesum+=arr[i]; } skipped=n; rec(0); if(ans==0){ co 0; return; } ans=0; vector<int>answers; for(int i=0;i<n;i++){ memset(vis,0,sizeof(vis)); wholesum-=arr[i]; skipped=i; rec(0); wholesum+=arr[i]; } for(int i=1;i<=275*275;i++){ if(mp[i]/2==n) answers.push_back(i); } co answers.size()<<'\n'; for(auto i:answers) co i<<' '; } int main() { suiii int t=1; // cin>>t; while(t--){ solve(); } return 0; }
#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...