제출 #1292901

#제출 시각아이디문제언어결과실행 시간메모리
1292901binminh01Sumtree (INOI20_sumtree)C++20
0 / 100
50 ms13144 KiB
#include<bits/stdc++.h> using namespace std; #define ll long long #define double long double #define sz(a) (int)a.size() #define all(a) (a).begin(), (a).end() #define rall(a) (a).rbegin(), (a).rend() #define pb push_back #define eb emplace_back #define open(s) freopen(s, "r", stdin) #define write(s) freopen(s, "w", stdout) using pii = pair<int, int>; using pll = pair<ll, ll>; typedef vector<int> vi; typedef vector<vi> vvi; typedef vector<ll> vll; typedef vector<vll> vvll; typedef vector<double> vdo; typedef vector<vdo> vvdo; typedef vector<string> vs; typedef vector<pii> vpair; typedef vector<vpair> vvpair; typedef vector<bool> vb; typedef vector<vb> vvb; typedef vector<char> vc; typedef vector<vc> vvc; typedef priority_queue<int> pq; typedef priority_queue<int, vi, greater<int>> pqg; typedef priority_queue<ll> pqll; typedef priority_queue<ll, vll, greater<ll>> pqgll; #define For(i, a, b) for (auto i = (a); i < (b); ++i) #define FOR(i, a, b) for (auto i = (a); i <= (b); ++i) #define Fore(i, a, b) for (auto i = (a); i >= (b); --i) #define trav(i, a) for (auto &i: a) constexpr int mod = (int)1e9 + 7; constexpr int N = 200005; inline int add(int x, const int &y) {x+=y; return x < mod ? x: x - mod;} inline int sub(int x, const int &y) {x-=y; return x >= 0 ? x: x + mod;} inline int mul(const int &x, const int &y) {return 1ll*x*y % mod;} inline int power(int a, int b) { int x = 1; for (; b; b>>=1) { if (b & 1) x = mul(x, a); a = mul(a, a); } return x; } int fact[N], invf[N]; inline int C(int k, int n) { return k >= 0 && k <= n ? mul(fact[n], mul(invf[k], invf[n - k])): 0; } int n, m, a[N], p[N]; vi g[N]; int main() { if (fopen("sumtree.inp", "r")) freopen("sumtree.inp", "r", stdin), freopen("sumtree.out", "w", stdout); ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL); fact[0] = 1; For(i,1,N) fact[i] = mul(fact[i - 1], i); invf[N - 1] = power(fact[N - 1], mod - 2); Fore(i,N-2,0) invf[i] = mul(invf[i + 1], i + 1); cin >> n >> a[1]; For(i,1,n){ int u, v; cin >> u >> v; g[u].pb(v), g[v].pb(u); } cout << C(n - 1, a[1] + n - 1) << '\n'; int q; cin >> q; if (!q) return 0; }

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

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