Submission #523594

#TimeUsernameProblemLanguageResultExecution timeMemory
523594DeepessonToys (CEOI18_toy)C++17
59 / 100
5097 ms125824 KiB
#include <bits/stdc++.h> std::vector<int> divisores; std::map<int,bool> respostas; typedef std::array<int,30> arr; std::map<arr,bool> foi; void processa(arr tem){ if(foi[tem])return; foi[tem]=true; { int s=0; for(auto&x:tem)if(x)s+=x-1; respostas[s]=true; } for(int i=0;i!=tem.size();++i){ if(i&&tem[i]==(tem[i-1]))continue; if(!tem[i])break; for(int j = i+1;j<tem.size();++j){ if(j!=(i+1)&&tem[j]==tem[j-1])continue; if(!tem[j])break; arr prox={}; int add=(tem[i]*tem[j]); int cur=0; for(int k=0;k!=tem.size();++k){ if(k==i||k==j)continue; if(!tem[k])continue; if(tem[k]>=add&&(add!=-1)){ prox[cur]=add; ++cur; add=-1; } prox[cur]=(tem[k]); ++cur; } if(add!=-1){ prox[cur]=add; ++cur; } processa(prox); } } } void achar_divisores(long long x){ for(int i=2;i!=1000000;++i){ if(!(x%i)){ while(!(x%i)){ divisores.push_back(i); x/=i; } } } if(x>1)divisores.push_back(x); } int main() { std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout.tie(0); long long N; std::cin>>N; achar_divisores(N); arr x = {}; for(int i=0;i!=divisores.size();++i)x[i]=divisores[i]; processa(x); std::cout<<respostas.size()<<"\n"; for(auto&x:respostas)std::cout<<x.first<<" "; std::cout<<"\n"; }

Compilation message (stderr)

toy.cpp: In function 'void processa(arr)':
toy.cpp:17:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::array<int, 30>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   17 |         for(int j = i+1;j<tem.size();++j){
      |                         ~^~~~~~~~~~~
toy.cpp: In function 'int main()':
toy.cpp:62:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   62 |     for(int i=0;i!=divisores.size();++i)x[i]=divisores[i];
      |                 ~^~~~~~~~~~~~~~~~~~
#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...