제출 #538919

#제출 시각아이디문제언어결과실행 시간메모리
538919ryangohcaToys (CEOI18_toy)C++17
100 / 100
2129 ms8756 KiB
#include <bits/stdc++.h>
//#define int long long
#define pii pair<int, int>
#define ti3 tuple<int, int, int>
#define ti4 tuple<int, int, int, int>
// This is like my secret account; yes it's like that  ~ Baek Jiheon, Feel Good (Secret Code)
using namespace std;
map<pii, int> off;
unordered_set<int> *dfs(int x, int s){
    unordered_set<int> * curr_set = new unordered_set<int>();
    curr_set->insert(x-1);
    off[{x, s}] = 0;
    for (int i = s; i*i<=x; i++){
        if (x%i != 0) continue;
        unordered_set<int> *child = dfs(x/i, i);
        if (child->size() <= curr_set->size()){
            int x1 = off[{x/i, i}];
            int p = off[{x, s}];
            for (auto j : *child){
                curr_set->insert(j + x1 + i-1 - p);
            }
            delete child;
        } else {
            swap(child, curr_set);
            swap(off[{x, s}], off[{x/i, i}]);
            off[{x, s}] += i - 1;
            int x1 = off[{x/i, i}];
            int p = off[{x, s}];
            for (auto j : *child){
                curr_set->insert(j + x1 - p);
            }
            delete child;
        }
    }
    return curr_set;
}
main(){
    int x; cin >> x;
    unordered_set<int> *ans = dfs(x, 2);
    vector<int> ot;
    int x2 = off[{x, 2}];
    for (auto i : *ans){
        ot.push_back(i + x2);
    }
    sort(ot.begin(), ot.end());
    cout << ot.size() << '\n';
    for (auto i : ot) cout << i << ' ';
}

컴파일 시 표준 에러 (stderr) 메시지

toy.cpp:37:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   37 | main(){
      | ^~~~
#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...