Submission #503689

#TimeUsernameProblemLanguageResultExecution timeMemory
503689andrei_boacaToys (CEOI18_toy)C++17
79 / 100
2512 ms44388 KiB
#include <bits/stdc++.h> #pragma GCC optimize("O3") using namespace std; int n; set<int> sol; vector<int> v; queue<vector<int>> coada; map<vector<int>,int> vuse; unordered_map<int,int> use; int main() { cin>>n; vector<int> a; a.push_back(n); coada.push(a); vuse[a]=1; while(!coada.empty()) { v=coada.front(); vuse[v]=1; coada.pop(); int suma=0; for(int i:v) suma+=(i-1); sol.insert(suma); for(int i=0;i<v.size();i++) { for(int d=2;d*d<=v[i];d++) if(v[i]%d==0) { int y=v[i]/d; int x=d; int s=suma-(v[i]-1)+(x-1)+(y-1); if(use[s]<10) { sol.insert(s); vector<int> aux; for(int j=0;j<v.size();j++) if(j!=i) aux.push_back(v[j]); aux.push_back(x); aux.push_back(y); sort(aux.begin(),aux.end()); if(!vuse[aux]) { vuse[aux]=1; use[s]++; coada.push(aux); } } } } } cout<<sol.size()<<'\n'; for(auto i:sol) cout<<i<<' '; return 0; }

Compilation message (stderr)

toy.cpp: In function 'int main()':
toy.cpp:26:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |         for(int i=0;i<v.size();i++)
      |                     ~^~~~~~~~~
toy.cpp:38:38: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |                         for(int j=0;j<v.size();j++)
      |                                     ~^~~~~~~~~
#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...