結果
問題 | No.916 Encounter On A Tree |
ユーザー | a |
提出日時 | 2019-10-26 00:22:05 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 4,483 bytes |
コンパイル時間 | 1,533 ms |
コンパイル使用メモリ | 169,052 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-09-13 11:20:29 |
合計ジャッジ時間 | 3,238 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | WA | - |
testcase_01 | AC | 2 ms
6,944 KB |
testcase_02 | AC | 2 ms
6,940 KB |
testcase_03 | AC | 8 ms
6,944 KB |
testcase_04 | AC | 2 ms
6,940 KB |
testcase_05 | AC | 8 ms
6,940 KB |
testcase_06 | WA | - |
testcase_07 | AC | 8 ms
6,940 KB |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | AC | 1 ms
6,944 KB |
testcase_11 | WA | - |
testcase_12 | AC | 2 ms
6,944 KB |
testcase_13 | WA | - |
testcase_14 | AC | 2 ms
6,940 KB |
testcase_15 | WA | - |
testcase_16 | AC | 2 ms
6,944 KB |
testcase_17 | AC | 8 ms
6,944 KB |
testcase_18 | AC | 2 ms
6,940 KB |
testcase_19 | AC | 8 ms
6,940 KB |
testcase_20 | WA | - |
testcase_21 | AC | 8 ms
6,944 KB |
testcase_22 | AC | 1 ms
6,944 KB |
testcase_23 | AC | 8 ms
6,940 KB |
testcase_24 | AC | 2 ms
6,940 KB |
testcase_25 | AC | 8 ms
6,944 KB |
testcase_26 | AC | 2 ms
6,940 KB |
testcase_27 | AC | 5 ms
6,940 KB |
testcase_28 | AC | 2 ms
6,940 KB |
testcase_29 | AC | 8 ms
6,944 KB |
testcase_30 | AC | 2 ms
6,940 KB |
testcase_31 | AC | 2 ms
6,944 KB |
testcase_32 | AC | 2 ms
6,940 KB |
testcase_33 | AC | 1 ms
6,944 KB |
testcase_34 | AC | 3 ms
6,940 KB |
testcase_35 | AC | 3 ms
6,944 KB |
testcase_36 | WA | - |
testcase_37 | AC | 8 ms
6,944 KB |
testcase_38 | AC | 3 ms
6,940 KB |
testcase_39 | AC | 2 ms
6,944 KB |
testcase_40 | WA | - |
testcase_41 | WA | - |
testcase_42 | AC | 2 ms
6,944 KB |
testcase_43 | AC | 2 ms
6,944 KB |
testcase_44 | AC | 2 ms
6,940 KB |
testcase_45 | AC | 3 ms
6,940 KB |
testcase_46 | AC | 2 ms
6,940 KB |
testcase_47 | WA | - |
testcase_48 | AC | 2 ms
6,940 KB |
testcase_49 | WA | - |
testcase_50 | AC | 2 ms
6,944 KB |
testcase_51 | WA | - |
testcase_52 | AC | 2 ms
6,944 KB |
testcase_53 | WA | - |
testcase_54 | AC | 2 ms
6,940 KB |
testcase_55 | AC | 2 ms
6,944 KB |
testcase_56 | AC | 2 ms
6,940 KB |
testcase_57 | AC | 2 ms
6,940 KB |
testcase_58 | WA | - |
testcase_59 | AC | 2 ms
6,944 KB |
testcase_60 | AC | 2 ms
6,940 KB |
ソースコード
//#define _GLIBCXX_DEBUG #include "bits/stdc++.h" using namespace std; //------------------------------- Libraries --------------------------------// template <int p> struct Modint { int value; Modint() : value(0) {} Modint(long x) : value(x >= 0 ? x % p : (p + x % p) % p) {} inline Modint &operator+=(const Modint &b) { if ((this->value += b.value) >= p) this->value -= p; return (*this); } inline Modint &operator-=(const Modint &b) { if ((this->value += p - b.value) >= p) this->value -= p; return (*this); } inline Modint &operator*=(const Modint &b) { this->value = (int)((1LL * this->value * b.value) % p); return (*this); } inline Modint &operator/=(const Modint &b) { (*this) *= b.inverse(); return (*this); } Modint operator+(const Modint &b) const { return Modint(*this) += b; } Modint operator-(const Modint &b) const { return Modint(*this) -= b; } Modint operator*(const Modint &b) const { return Modint(*this) *= b; } Modint operator/(const Modint &b) const { return Modint(*this) /= b; } inline Modint &operator++(int) { return (*this) += 1; } inline Modint &operator--(int) { return (*this) -= 1; } inline bool operator==(const Modint &b) const { return this->value == b.value; } inline bool operator!=(const Modint &b) const { return this->value != b.value; } inline bool operator<(const Modint &b) const { return this->value < b.value; } inline bool operator<=(const Modint &b) const { return this->value <= b.value; } inline bool operator>(const Modint &b) const { return this->value > b.value; } inline bool operator>=(const Modint &b) const { return this->value >= b.value; } // requires that "this->value and p are co-prime" // a_i * v + a_(i+1) * p = r_i // r_i = r_(i+1) * q_(i+1) * r_(i+2) // q == 1 (i > 1) // reference: https://atcoder.jp/contests/agc026/submissions/2845729 // (line:93) inline Modint inverse() const { assert(this->value != 0); int r0 = p, r1 = this->value, a0 = 0, a1 = 1; while (r1) { int q = r0 / r1; r0 -= q * r1; swap(r0, r1); a0 -= q * a1; swap(a0, a1); } return Modint(a0); } friend istream &operator>>(istream &is, Modint<p> &a) { long t; is >> t; a = Modint<p>(t); return is; } friend ostream &operator<<(ostream &os, const Modint<p> &a) { return os << a.value; } }; const int MOD = 1e9 + 7; using Int = Modint<MOD>; //------------------------------- Type Names -------------------------------// using i64 = int_fast64_t; using seika = string; //akari : 1D, yukari : 2D, maki : 3D vector template <class kizuna> using akari = vector<kizuna>; template <class yuzuki> using yukari = akari<akari<yuzuki>>; template <class tsurumaki> using maki = akari<yukari<tsurumaki>>; //akane : ascending order, aoi : decending order template <class kotonoha> using akane = priority_queue<kotonoha, akari<kotonoha>, greater<kotonoha>>; template <class kotonoha> using aoi = priority_queue<kotonoha>; //------------------------------- Dubug Functions ---------------------------// inline void print() { cout << endl; } template <typename First, typename... Rest> void print(const First &first, const Rest &... rest) { cout << first << ' '; print(rest...); } //------------------------------- Solver ------------------------------------// void solve() { int d, l, r, k; cin >> d >> l >> r >> k; l = log(l) / log(2) + 1; r = log(r) / log(2) + 1; int p = 1; //print(l, r); while (l + r - 2 * p > k) { p++; } if (l + r - 2 * p != k) { cout << 0 << endl; return; } l -= p - 1; r -= p - 1; //print(p, l, r); Int ans = 1; for (int x = 1; x <= d; x++) { int c = 1 << (x - 1); if (l + p - 1 == x) c--; if (r + p - 1 == x) c--; for (int y = 1; y <= c; y++) ans *= Int(y); } ans *= max(1, (1 << (r - 2))); ans *= max(1, (1 << (l - 2))); ans *= max(1, (1 << (p - 1 + (l != 1)))); cout << ans << endl; } int main() { solve(); return 0; }