Submission #825315

#TimeUsernameProblemLanguageResultExecution timeMemory
825315alex_2008Toys (CEOI18_toy)C++14
79 / 100
5070 ms70120 KiB
#include <iostream> #include <unordered_map> #include <unordered_set> #include <algorithm> #include <vector> #include <set> using namespace std; const int NN = 2e3 + 10; int main() { int n; cin >> n; if (n == 1) { cout << "1\n"; cout << "0\n"; return 0; } vector <int> v; int j; for (int i = 1; i * i <= n; i++) { if (n % i == 0) v.push_back(i); if (i * i < n) j = i; } for (int i = j; i >= 1; i--) { if (n % i == 0) { v.push_back(n / i); } } unordered_map <int, int> mp, yp; int N = (int)v.size(); for (int i = 1; i <= (int)v.size(); i++) { mp[i] = v[i - 1]; yp[v[i - 1]] = i; } vector<unordered_set<int>> ans(N + 1); ans[1] = {0}; for (int i = 1; i < N; i++) { for (auto it : ans[i]) { for (int j = 2; j <= N - i + 1; j++) { if (yp[mp[i] * mp[j]]) { ans[yp[mp[i] * mp[j]]].insert(it + mp[j] - 1); } } } } vector <int> vv(ans[N].begin(), ans[N].end()); sort(vv.begin(), vv.end()); cout << (int)vv.size() << "\n"; for (auto it : vv) { cout << it << " "; } }

Compilation message (stderr)

toy.cpp: In function 'int main()':
toy.cpp:18:6: warning: 'j' may be used uninitialized in this function [-Wmaybe-uninitialized]
   18 |  int 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...