Submission #1008299

#TimeUsernameProblemLanguageResultExecution timeMemory
1008299AlmontherBootfall (IZhO17_bootfall)C++98
28 / 100
1014 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]; ll skipped; int ans=0; int n,wholesum=0; map<int,int>mp; ll 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(auto i:mp){ if(i.first<1) continue; if(i.second/2==n) answers.push_back(i.first); } 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...