Submission #835778

# Submission time Handle Problem Language Result Execution time Memory
835778 2023-08-23T19:50:06 Z MohamedAliSaidane Sumtree (INOI20_sumtree) C++14
10 / 100
80 ms 18568 KB
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;

#define pb push_back
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()


ll MOD = 1e9 + 7;
ll mod(ll x, ll m = MOD){return (x + m)%m;}
const int nax= 2e5 + 5;
const int rax= 6e5 + 5;
ll fact[ rax];
ll binpow(ll a, ll b, ll m= MOD)
{
    ll res = 1ll;
    while(b)
    {
        if(b & 1)
            res = mod(res * 1ll * a);
        a = mod(a * 1ll * a);
        b /= 2ll;
    }
    return res;
}
ll inv(ll x, ll m = MOD)
{
    return binpow(x, m - 2ll, m);
}
ll C(int a, int b)
{
    return mod(fact[a] * inv(mod(fact[a - b] * fact[b])));
}
ll formula(int s, int k)
{
    return C(s + k, k);
}

int n, r;
vector<int> adj[nax];

void solve()
{
    cin >> n >> r;
    for(int i =1; i < n; i++)
    {
        int a, b;
        cin >> a >> b;
        adj[a].pb(b);
        adj[b].pb(a);
    }
    cout << formula(r, n - 1);
    int q; cin >> q;
    while(q--)
    {
        int t; cin >> t;
        if(t == 1)
        {

        }
        else
        {

        }
    }
}
int32_t main()
{
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    fact[0] = 1ll;
    for(int i = 1; i < rax; i++)
        fact[i] = mod(fact[i - 1] * 1ll * i);
    int tt = 1;
    while(tt--)
        solve();
}
# Verdict Execution time Memory Grader output
1 Correct 59 ms 15928 KB Output is correct
2 Correct 57 ms 18352 KB Output is correct
3 Correct 76 ms 18344 KB Output is correct
4 Correct 80 ms 18424 KB Output is correct
5 Correct 57 ms 18400 KB Output is correct
6 Correct 9 ms 9728 KB Output is correct
7 Correct 9 ms 9708 KB Output is correct
8 Correct 10 ms 9732 KB Output is correct
9 Correct 63 ms 18568 KB Output is correct
10 Correct 61 ms 18500 KB Output is correct
11 Correct 76 ms 18492 KB Output is correct
12 Correct 56 ms 18124 KB Output is correct
13 Correct 51 ms 17532 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 8 ms 9684 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 61 ms 15980 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 71 ms 16116 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 59 ms 15928 KB Output is correct
2 Correct 57 ms 18352 KB Output is correct
3 Correct 76 ms 18344 KB Output is correct
4 Correct 80 ms 18424 KB Output is correct
5 Correct 57 ms 18400 KB Output is correct
6 Correct 9 ms 9728 KB Output is correct
7 Correct 9 ms 9708 KB Output is correct
8 Correct 10 ms 9732 KB Output is correct
9 Correct 63 ms 18568 KB Output is correct
10 Correct 61 ms 18500 KB Output is correct
11 Correct 76 ms 18492 KB Output is correct
12 Correct 56 ms 18124 KB Output is correct
13 Correct 51 ms 17532 KB Output is correct
14 Incorrect 8 ms 9684 KB Output isn't correct
15 Halted 0 ms 0 KB -