Submission #237715

# Submission time Handle Problem Language Result Execution time Memory
237715 2020-06-08T12:35:29 Z Nucleist Toys (CEOI18_toy) C++14
0 / 100
4 ms 384 KB
#include <bits/stdc++.h> 
using namespace std; 
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define flash ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define debug(x) cerr << " - " << #x << ": " << x << endl;
#define debugs(x, y) cerr << " - " << #x << ": " << x << " " << #y << ": " << y << endl;
#define all(x) (x).begin(),(x).end()
#define sz(x) (ll)x.size()
#define ll long long
#define INF 1000000000
#define MOD 1000000007
#define pb push_back
#define ve vector<ll>
#define dos pair<ll,ll>
#define vedos vector<dos>
#define rand mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define EPS 0.000001
struct greateri
{
    template<class T>
    bool operator()(T const &a, T const &b) const { return a > b; }
};
void setIO(string s) {
  ios_base::sync_with_stdio(0); cin.tie(0); 
  freopen((s+".in").c_str(),"r",stdin);
  freopen((s+".out").c_str(),"w",stdout);
}
struct HASH{
  size_t operator()(const pair<int,int>&x)const{
    return hash<long long>()(((long long)x.first)^(((long long)x.second)<<32));
  }
};
unordered_map<ll,ve>kol;
unordered_map<ll,vector<ll>>dp;
ve fact;
ll t;
vector<ll> rec(ll n){
  if(dp.find(n)!=dp.end())return dp[n];
  ve cur; 
  if(n==1)return cur;
  cur.pb(n-1);
  for(auto it:fact){
    ve now;
    if(!(n%it)){
      now=rec(n/it);
      for(auto it1:now){
        cur.pb(it1+it-1);
      }
    }
  }
  sort(cur.begin(),cur.end());
  auto last = unique(cur.begin(),cur.end());
  cur.erase(last,cur.end());
  return dp[n]=cur;
}
int main()
{
  flash;
  ll n;
  cin>>n;
  t=n;
  set<ll> div;
  for (int i = 1; i <= sqrt(n); ++i)
  {
    if(!(n%i)){
      div.insert(i),div.insert(n/i);
    }
  }
  div.erase(1);
  for(auto it:div){
    fact.pb(it);
  }
  ve ans=rec(n);
  cout<<ans.size()<<'\n';
  for(auto it:ans)cout<<it<<" ";
  return 0;
}
//code the AC sol !
// BS/queue/map

Compilation message

toy.cpp:4:0: warning: ignoring #pragma GCC optimization [-Wunknown-pragmas]
 #pragma GCC optimization ("O3")
 
toy.cpp:5:0: warning: ignoring #pragma GCC optimization [-Wunknown-pragmas]
 #pragma GCC optimization ("unroll-loops")
 
toy.cpp: In function 'void setIO(std::__cxx11::string)':
toy.cpp:27:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   freopen((s+".in").c_str(),"r",stdin);
   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
toy.cpp:28:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   freopen((s+".out").c_str(),"w",stdout);
   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -