Submission #584976

#TimeUsernameProblemLanguageResultExecution timeMemory
584976krit3379Toys (CEOI18_toy)C++17
59 / 100
5035 ms78100 KiB
#include<bits/stdc++.h> using namespace std; #pragma GCC optimize("O3,unroll-loops") #pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt") #define N 100005 vector<int> p; map<vector<int>,int> mp; set<int> ans; void bfs(vector<int> &v){ if(!mp.count(v))mp[v]; else return ; for(int i=0;i<v.size();i++){ for(int j=i+1;j<v.size();j++){ vector<int> temp=v; temp[i]*=temp[j]; temp[j]=temp.back(); temp.pop_back(); sort(temp.begin(),temp.end()); bfs(temp); } } } int main(){ int n,i,sum; scanf("%d",&n); for(i=2;i<=1e5;i++)while(n%i==0)n/=i,p.push_back(i); if(n>1)p.push_back(i); bfs(p); for(auto [arr,y]:mp){ sum=0; for(auto x:arr)sum+=x-1; ans.insert(sum); } printf("%d\n",ans.size()); for(auto x:ans)printf("%d ",x); return 0; }

Compilation message (stderr)

toy.cpp: In function 'void bfs(std::vector<int>&)':
toy.cpp:14:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   14 |     for(int i=0;i<v.size();i++){
      |                 ~^~~~~~~~~
toy.cpp:15:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   15 |         for(int j=i+1;j<v.size();j++){
      |                       ~^~~~~~~~~
toy.cpp: In function 'int main()':
toy.cpp:37:14: warning: format '%d' expects argument of type 'int', but argument 2 has type 'std::set<int>::size_type' {aka 'long unsigned int'} [-Wformat=]
   37 |     printf("%d\n",ans.size());
      |             ~^    ~~~~~~~~~~
      |              |            |
      |              int          std::set<int>::size_type {aka long unsigned int}
      |             %ld
toy.cpp:28:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   28 |     scanf("%d",&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...