結果
問題 | No.2735 Demarcation |
ユーザー | 👑 emthrm |
提出日時 | 2024-04-20 03:02:26 |
言語 | C++23 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 204 ms / 1,500 ms |
コード長 | 1,820 bytes |
コンパイル時間 | 3,368 ms |
コンパイル使用メモリ | 285,328 KB |
実行使用メモリ | 11,080 KB |
最終ジャッジ日時 | 2024-04-20 03:02:35 |
合計ジャッジ時間 | 7,954 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
6,812 KB |
testcase_01 | AC | 2 ms
6,944 KB |
testcase_02 | AC | 3 ms
6,940 KB |
testcase_03 | AC | 2 ms
6,944 KB |
testcase_04 | AC | 55 ms
11,080 KB |
testcase_05 | AC | 43 ms
6,940 KB |
testcase_06 | AC | 97 ms
9,568 KB |
testcase_07 | AC | 204 ms
10,424 KB |
testcase_08 | AC | 145 ms
10,272 KB |
testcase_09 | AC | 107 ms
6,940 KB |
testcase_10 | AC | 117 ms
7,168 KB |
testcase_11 | AC | 24 ms
6,940 KB |
testcase_12 | AC | 30 ms
6,944 KB |
testcase_13 | AC | 45 ms
6,944 KB |
testcase_14 | AC | 167 ms
8,576 KB |
testcase_15 | AC | 89 ms
6,940 KB |
testcase_16 | AC | 100 ms
9,532 KB |
testcase_17 | AC | 106 ms
6,944 KB |
testcase_18 | AC | 41 ms
6,940 KB |
testcase_19 | AC | 154 ms
10,636 KB |
testcase_20 | AC | 189 ms
9,788 KB |
testcase_21 | AC | 59 ms
8,512 KB |
testcase_22 | AC | 93 ms
10,540 KB |
testcase_23 | AC | 31 ms
6,940 KB |
testcase_24 | AC | 49 ms
7,040 KB |
testcase_25 | AC | 73 ms
9,124 KB |
testcase_26 | AC | 67 ms
8,820 KB |
testcase_27 | AC | 58 ms
7,808 KB |
testcase_28 | AC | 95 ms
11,020 KB |
testcase_29 | AC | 97 ms
10,972 KB |
ソースコード
#include <bits/stdc++.h> using namespace std; #define FOR(i,m,n) for(int i=(m);i<(n);++i) #define REP(i,n) FOR(i,0,n) using ll = long long; constexpr int INF = 0x3f3f3f3f; constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL; constexpr double EPS = 1e-8; constexpr int MOD = 998244353; // constexpr int MOD = 1000000007; constexpr int DY4[]{1, 0, -1, 0}, DX4[]{0, -1, 0, 1}; constexpr int DY8[]{1, 1, 0, -1, -1, -1, 0, 1}; constexpr int DX8[]{0, -1, -1, -1, 0, 1, 1, 1}; template <typename T, typename U> inline bool chmax(T& a, U b) { return a < b ? (a = b, true) : false; } template <typename T, typename U> inline bool chmin(T& a, U b) { return a > b ? (a = b, true) : false; } struct IOSetup { IOSetup() { std::cin.tie(nullptr); std::ios_base::sync_with_stdio(false); std::cout << fixed << setprecision(20); } } iosetup; int main() { constexpr int L = 87; int n; cin >> n; vector<int> x(n); for (int& x_i : x) cin >> x_i; vector<int> v(n, 0); FOR(i, 1, n) v[i] = v[i - 1] + (x[i] == x[i - 1]); int q; cin >> q; while (q--) { int l, r; ll s; cin >> l >> r >> s; --l; --r; if (r - l <= 60 && (1LL << (r - l)) <= s) { cout << "-1\n"; } else if (const int adj = v[r] - v[l]; adj > 60 || (1LL << adj) > s) { cout << 0 << '\n'; } else if (r - l + 1 > L) { cout << 1 << '\n'; } else { int ans = 1; for (; ; ++ans) { vector<__int128> dp(r - l + 2, 0); dp[0] = 1; map<int, int> num; for (int i = l, j = l; i <= r; ++i) { ++num[x[i]]; for (; num.size() > ans + 1; ++j) { if (--num[x[j]] == 0) num.erase(x[j]); } FOR(x, j, i + 1) dp[i - l + 1] += dp[x - l]; } if (dp[r - l + 1] > s) break; } cout << ans << '\n'; } } return 0; }