Submission #635441

# Submission time Handle Problem Language Result Execution time Memory
635441 2022-08-26T09:16:39 Z MohammadAghil Sumtree (INOI20_sumtree) C++17
10 / 100
222 ms 26632 KB
#include <bits/stdc++.h>
//#pragma GCC optimize ("Ofast,unroll-loops")
//#pragma GCC target ("avx2")
using namespace std;

typedef long long ll;
typedef pair<int, int> pp;

#define rep(i,l,r) for(int i = (l); i < (r); i++)
#define per(i,r,l) for(int i = (r); i >= (l); i--)
#define all(x) begin(x), end(x)
#define sz(x) (int)x.size()
#define pb push_back
#define ff first
#define ss second

void dbg(){
    cerr << endl;
}
template<typename Head, typename... Tail> void dbg(Head h, Tail... t){
    cerr << " " << h << ",";
    dbg(t...);
}
#define er(...) cerr << __LINE__ << " <" << #__VA_ARGS__ << ">:", dbg(__VA_ARGS__)

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

void IOS(){
    cin.tie(0) -> sync_with_stdio(0);
//    #ifndef ONLINE_JUDGE
//        freopen("inp.txt", "r", stdin);
//        freopen("out.txt", "w", stdout);
//    #endif
}

const ll mod = 1e9 + 7, maxn = 5e5 + 5, maxm = 20, inf = ll(1e9) + 5;

ll pw(ll a, ll b){
    if(!b) return 1;
    ll k = pw(a, b>>1ll);
    return  k*k%mod*(b&1ll?a:1ll)%mod;
}

vector<int> adj[maxn];
ll fac[maxn], inv[maxn];

ll C(int n, int r){
    if(r < 0 || r > n) return 0;
    return fac[n]*inv[r]%mod*inv[n-r]%mod;
}

int main(){ IOS();
    fac[0] = inv[0] = 1;

    rep(i,1,maxn){
        fac[i] = fac[i-1]*i%mod;
        inv[i] = pw(fac[i], mod-2);
    }

    int n, r; cin >> n >> r;

    rep(i,1,n){
        int u, v; cin >> u >> v; u--, v--;
        adj[u].pb(v), adj[v].pb(u);
    }
    int q; cin >> q;
    cout << C(r + n - 1, n - 1) << '\n';
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 200 ms 26240 KB Output is correct
2 Correct 210 ms 26256 KB Output is correct
3 Correct 204 ms 26316 KB Output is correct
4 Correct 206 ms 26364 KB Output is correct
5 Correct 219 ms 26256 KB Output is correct
6 Correct 110 ms 19936 KB Output is correct
7 Correct 118 ms 19932 KB Output is correct
8 Correct 111 ms 19896 KB Output is correct
9 Correct 204 ms 26424 KB Output is correct
10 Correct 205 ms 26420 KB Output is correct
11 Correct 196 ms 26632 KB Output is correct
12 Correct 215 ms 26204 KB Output is correct
13 Correct 185 ms 25740 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 113 ms 19868 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 222 ms 26336 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 214 ms 26496 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 200 ms 26240 KB Output is correct
2 Correct 210 ms 26256 KB Output is correct
3 Correct 204 ms 26316 KB Output is correct
4 Correct 206 ms 26364 KB Output is correct
5 Correct 219 ms 26256 KB Output is correct
6 Correct 110 ms 19936 KB Output is correct
7 Correct 118 ms 19932 KB Output is correct
8 Correct 111 ms 19896 KB Output is correct
9 Correct 204 ms 26424 KB Output is correct
10 Correct 205 ms 26420 KB Output is correct
11 Correct 196 ms 26632 KB Output is correct
12 Correct 215 ms 26204 KB Output is correct
13 Correct 185 ms 25740 KB Output is correct
14 Incorrect 113 ms 19868 KB Output isn't correct
15 Halted 0 ms 0 KB -