結果
問題 | No.916 Encounter On A Tree |
ユーザー | yakamoto |
提出日時 | 2019-10-29 01:05:48 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 3,672 bytes |
コンパイル時間 | 1,553 ms |
コンパイル使用メモリ | 169,540 KB |
実行使用メモリ | 19,712 KB |
最終ジャッジ日時 | 2024-09-14 21:22:00 |
合計ジャッジ時間 | 3,924 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
5,248 KB |
testcase_01 | AC | 2 ms
5,376 KB |
testcase_02 | AC | 1 ms
5,376 KB |
testcase_03 | AC | 49 ms
19,584 KB |
testcase_04 | AC | 2 ms
5,376 KB |
testcase_05 | WA | - |
testcase_06 | AC | 2 ms
5,376 KB |
testcase_07 | AC | 49 ms
19,584 KB |
testcase_08 | AC | 7 ms
5,376 KB |
testcase_09 | AC | 13 ms
7,296 KB |
testcase_10 | AC | 2 ms
5,376 KB |
testcase_11 | AC | 2 ms
5,376 KB |
testcase_12 | AC | 2 ms
5,376 KB |
testcase_13 | AC | 49 ms
19,584 KB |
testcase_14 | AC | 2 ms
5,376 KB |
testcase_15 | AC | 49 ms
19,712 KB |
testcase_16 | AC | 2 ms
5,376 KB |
testcase_17 | WA | - |
testcase_18 | AC | 2 ms
5,376 KB |
testcase_19 | AC | 49 ms
19,584 KB |
testcase_20 | AC | 2 ms
5,376 KB |
testcase_21 | WA | - |
testcase_22 | AC | 2 ms
5,376 KB |
testcase_23 | WA | - |
testcase_24 | AC | 2 ms
5,376 KB |
testcase_25 | AC | 49 ms
19,584 KB |
testcase_26 | AC | 2 ms
5,376 KB |
testcase_27 | AC | 25 ms
11,392 KB |
testcase_28 | AC | 2 ms
5,376 KB |
testcase_29 | WA | - |
testcase_30 | AC | 2 ms
5,376 KB |
testcase_31 | AC | 2 ms
5,376 KB |
testcase_32 | AC | 2 ms
5,376 KB |
testcase_33 | AC | 2 ms
5,376 KB |
testcase_34 | AC | 13 ms
7,296 KB |
testcase_35 | AC | 8 ms
5,376 KB |
testcase_36 | AC | 48 ms
19,584 KB |
testcase_37 | WA | - |
testcase_38 | WA | - |
testcase_39 | AC | 2 ms
5,376 KB |
testcase_40 | AC | 49 ms
19,584 KB |
testcase_41 | AC | 2 ms
5,376 KB |
testcase_42 | AC | 2 ms
5,376 KB |
testcase_43 | AC | 1 ms
5,376 KB |
testcase_44 | AC | 2 ms
5,376 KB |
testcase_45 | AC | 8 ms
5,376 KB |
testcase_46 | AC | 2 ms
5,376 KB |
testcase_47 | AC | 2 ms
5,376 KB |
testcase_48 | AC | 2 ms
5,376 KB |
testcase_49 | AC | 2 ms
5,376 KB |
testcase_50 | AC | 2 ms
5,376 KB |
testcase_51 | AC | 2 ms
5,376 KB |
testcase_52 | WA | - |
testcase_53 | AC | 2 ms
5,376 KB |
testcase_54 | AC | 2 ms
5,376 KB |
testcase_55 | AC | 2 ms
5,376 KB |
testcase_56 | WA | - |
testcase_57 | WA | - |
testcase_58 | AC | 2 ms
5,376 KB |
testcase_59 | WA | - |
testcase_60 | WA | - |
ソースコード
/** * code generated by JHelper * More info: https://github.com/AlexeyDmitriev/JHelper * @author */ #include <iostream> #include <fstream> #ifndef SOLUTION_COMMON_H #include <bits/stdc++.h> using namespace std; using ll = long long; using PI = pair<int, int>; template<class T> using V = vector<T>; using VI = V<int>; #define _1 first #define _2 second #ifdef MY_DEBUG # define DEBUG(x) x #else # define DEBUG(x) #endif template<class A, class B> std::ostream & operator <<(ostream &os, const pair<A, B> &p) { os << "(" << p._1 << "," << p._2 << ")"; return os; } template<class T> inline void debug(T &A) { DEBUG( for (const auto &a : A) { cerr << a << " "; } cerr << '\n'; ) } template<class T, class Func> inline void debug_with_format(T &A, Func f) { DEBUG( for (const auto &a : A) { cerr << f(a) << " "; } cerr << '\n'; ) } template<class T> inline void debug_dim2(T &A) { DEBUG( for (const auto &as : A) { debug(as); } ) } template<typename ... Args> inline void debug(const char *format, Args const &... args) { DEBUG( fprintf(stderr, format, args ...); cerr << '\n'; ) } template<typename ... Args> string format(const string &fmt, Args ... args) { size_t len = snprintf(nullptr, 0, fmt.c_str(), args ...); vector<char> buf(len + 1); snprintf(&buf[0], len + 1, fmt.c_str(), args ...); return string(&buf[0], &buf[0] + len); } template<class T1, class T2> string fmtP(pair<T1, T2> a) { stringstream ss; ss << "(" << a._1 << "," << a._2 << ")"; return ss.str(); } #define SOLUTION_COMMON_H #endif //SOLUTION_COMMON_H class Comb { public: int MOD; V<ll> F, I; Comb(int N, int MOD): MOD(MOD), F(N + 1), I(N + 1) { F[0] = 1; for (int i = 1; i <= N; ++i) { F[i] = F[i - 1] * i % MOD; } I[N] = pow_mod(F[N], MOD - 2, MOD); for (int i = N - 1; i >= 0; --i) { I[i] = I[i + 1] * (i + 1) % MOD; } } static ll pow_mod(ll x, int k, int MOD) { ll res = k >= 2 ? pow_mod(x * x % MOD, k / 2, MOD) : 1ll; if (k&1) res = res * x % MOD; return res; }; ll operator()(int n, int k) { if (k < 0 || k > n) return 0ll; return F[n] * I[n - k] % MOD * I[k] % MOD; }; ll rev(int x) { return F[x - 1] * I[x] % MOD; } }; const int MOD = 1000000007; class A { public: void solve(std::istream& in, std::ostream& out) { int d, l, r, k; in >> d >> l >> r >> k; int dl = 31 - __builtin_clz(l); int dr = 31 - __builtin_clz(r); int turn = k - (dr - dl); if (turn < 0 || turn % 2 == 1) { out << 0; return; } int dRt = dl - turn / 2; if (dRt < 0) { out << 0; return; } debug("%d %d %d", dRt, dl, dr); Comb comb(1 << d, MOD); ll selectRt = 1 << dRt; ll selectLR; if (dl == dRt) { selectLR = 1ll << dr - dRt; } else if (dl == dr) { selectLR = (1ll << max(0, dl - dRt - 1)) * (1ll << max(0, dr - dRt - 1)) % MOD * 2 % MOD; } else { // dl < dr selectLR = (1ll << max(0, dl - dRt - 1)) * (1ll << max(0, dr - dRt - 1)) % MOD; } debug("selects %d %d", selectRt, selectLR); ll remain = 1ll; for (int i = 0; i < d; ++i) { int cnt = 1 << i; if (i == dl) cnt--; if (i == dr) cnt--; debug("cnt:%d", cnt); remain = remain * comb.F[cnt] % MOD; } debug("remain:%d", remain); ll ans = selectRt * selectLR % MOD * remain % MOD; out << ans; } }; int main() { A solver; std::istream& in(std::cin); std::ostream& out(std::cout); solver.solve(in, out); return 0; }