Submission #1292956

#TimeUsernameProblemLanguageResultExecution timeMemory
1292956BuiDucManh123Sumtree (INOI20_sumtree)C++20
10 / 100
100 ms22032 KiB
#include <bits/stdc++.h>
#define fi first
#define se second
#define ll long long
#define pii pair<int, int>
#define pb push_back
#define taskname ""
const int mod = 1e9+7;
using namespace std;
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
#define int ll
const int N = 6e5;
int gt[N + 5], fgt[N + 5];
ll mu(ll a, ll b){
    ll res = 1;
    while(b){
        if(b & 1){
            res = res * a % mod;
         }
         a = a * a % mod;
         b >>= 1;
    }
    return res;
}
ll C(ll n, ll k){
    if(k < 0 || k > n) return 0;
    return gt[n] * fgt[n - k] % mod * fgt[k] % mod;
}
vector<int> g[N + 5];
void solve(){
    gt[0] = 1;
    for(int i = 1; i <= N; i++){
        gt[i] = gt[i - 1] * i % mod;
    }
    fgt[N] = mu(gt[N], mod - 2);
    for(int i = N - 1; i >= 0; i--){
        fgt[i] = fgt[i + 1] * (i + 1) % mod;
    }
    int n, r;
    cin >> n >> r;
    for(int i = 1; i < n; i++){
        int u, v;
        cin >> u >> v;
        g[u].pb(v);
        g[v].pb(u);
    }
    int q;
    cin >> q;
    cout << C(n + r - 1, n - 1);
}
signed main() {
    if (fopen(taskname".inp","r")) {
        freopen(taskname".inp","r",stdin);
        freopen(taskname".out","w",stdout);
    }
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int test = 1;
    //cin >> test;
    while(test--){
        solve();
    }
    return 0;
}


Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:53:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   53 |         freopen(taskname".inp","r",stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:54:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   54 |         freopen(taskname".out","w",stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
#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...