Submission #124464

# Submission time Handle Problem Language Result Execution time Memory
124464 2019-07-03T11:25:09 Z youssefbou62 Toys (CEOI18_toy) C++14
0 / 100
2 ms 376 KB
#include <bits/stdc++.h>

using namespace std;

#define mp make_pair
#define fi first
#define se second
#define all(v) v.begin(), v.end()
#define allarr(a) a, a + n
#define ll long long
#define ull unsigned long long
#define pb push_back
#define fastio                        \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL)
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef pair<int, pi> trp;
typedef vector<pi> vpi;
typedef vector<pll> vpll;
ll _abs(ll x) { return (x > 0 ? x : -x); }
/*
vector<int> ans;
set <pi> dp ; 
int N;
void solve(int n, int x)
{
    
    if (x >= N)return ; 
    if (dp.find({n,x})!=dp.end())
            return;
    dp.insert({n,x}); 
    if (n == 1)
    {
        ans.pb(x);
        return;
    }

    for (int i = 1; i * i <= n; i++)
    {
        if (n % i == 0)
        {
            if (i != 1)
                solve(n / i, x + i - 1);
            solve(i, x + n / i - 1);
        }
    }
}


int main()
{
    scanf("%d",&N) ;
    solve(N, 0);
    sort(all(ans)); 
    cout << ans.size() << endl; 
    for (int i : ans)
        printf("%d ",i) ; 
    
}
*/
map<int,set<int>> dp ; 
void add  ( set<int>& s , set<int> t , int edge ){
    for(int i : t )s.insert(i + edge ) ; 
}
set<int> dfs (int n ){
    if( n == 1 ){
        return {0} ; 
    }
    if( dp.count(n) )return dp[n]; 
    set<int> sum ; 
    for (int i = 1; i * i <= n; i++){
        if( n % i == 0 ){
            if( i!= 1 )
            add( sum , dfs ( n / i) , i - 1 ) ; 
            add ( sum , dfs( i ) , n/i - 1  ); 
        }
    }  
    return dp[n] = sum ; 
}

int main(){
    int N ; 
    scanf("%d",&N) ; 
    set <int> ans ; 
    dfs(N) ;  
    printf("%d\n",dp[N].size()) ; 
    for(int i : dp[N] )printf("%d ",i) ; 
 }

Compilation message

toy.cpp: In function 'int main()':
toy.cpp:88:31: warning: format '%d' expects argument of type 'int', but argument 2 has type 'std::set<int>::size_type {aka long unsigned int}' [-Wformat=]
     printf("%d\n",dp[N].size()) ; 
                   ~~~~~~~~~~~~^
toy.cpp:85:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d",&N) ; 
     ~~~~~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -