結果
問題 | No.2281 K → K-1 01 Flip |
ユーザー | SSRS |
提出日時 | 2023-04-21 22:19:41 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,289 bytes |
コンパイル時間 | 1,560 ms |
コンパイル使用メモリ | 172,080 KB |
実行使用メモリ | 11,776 KB |
最終ジャッジ日時 | 2024-04-24 08:25:39 |
合計ジャッジ時間 | 23,312 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
5,248 KB |
testcase_01 | AC | 50 ms
8,192 KB |
testcase_02 | AC | 408 ms
7,424 KB |
testcase_03 | AC | 469 ms
10,880 KB |
testcase_04 | AC | 110 ms
5,504 KB |
testcase_05 | AC | 189 ms
8,192 KB |
testcase_06 | WA | - |
testcase_07 | AC | 107 ms
11,008 KB |
testcase_08 | AC | 282 ms
11,008 KB |
testcase_09 | WA | - |
testcase_10 | AC | 338 ms
5,760 KB |
testcase_11 | WA | - |
testcase_12 | AC | 114 ms
10,368 KB |
testcase_13 | AC | 424 ms
5,632 KB |
testcase_14 | AC | 227 ms
8,320 KB |
testcase_15 | AC | 110 ms
5,376 KB |
testcase_16 | AC | 457 ms
7,552 KB |
testcase_17 | AC | 483 ms
8,320 KB |
testcase_18 | AC | 451 ms
6,912 KB |
testcase_19 | AC | 197 ms
9,984 KB |
testcase_20 | AC | 126 ms
5,376 KB |
testcase_21 | WA | - |
testcase_22 | WA | - |
testcase_23 | WA | - |
testcase_24 | WA | - |
testcase_25 | WA | - |
testcase_26 | WA | - |
testcase_27 | WA | - |
testcase_28 | WA | - |
testcase_29 | AC | 7 ms
5,376 KB |
testcase_30 | WA | - |
testcase_31 | WA | - |
testcase_32 | WA | - |
testcase_33 | WA | - |
testcase_34 | WA | - |
testcase_35 | WA | - |
testcase_36 | WA | - |
testcase_37 | WA | - |
testcase_38 | WA | - |
testcase_39 | WA | - |
testcase_40 | WA | - |
testcase_41 | WA | - |
testcase_42 | WA | - |
testcase_43 | WA | - |
testcase_44 | WA | - |
testcase_45 | WA | - |
testcase_46 | WA | - |
testcase_47 | WA | - |
testcase_48 | WA | - |
testcase_49 | WA | - |
testcase_50 | WA | - |
testcase_51 | WA | - |
testcase_52 | WA | - |
testcase_53 | WA | - |
testcase_54 | WA | - |
testcase_55 | WA | - |
testcase_56 | WA | - |
ソースコード
#include <bits/stdc++.h> #include <atcoder/segtree> using namespace std; int op(int x, int y){ return max(x, y); } int e(){ return 0; } int main(){ int N, Q; cin >> N >> Q; string S; cin >> S; vector<int> sum(N + 1); sum[0] = 0; for (int i = 0; i < N; i++){ if (S[i] == '0'){ sum[i + 1] = sum[i] + 1; } else { sum[i + 1] = sum[i] - 1; } } set<int> st; st.insert(0); st.insert(N); for (int i = 1; i < N; i++){ if (S[i] != S[i - 1]){ st.insert(i); } } vector<int> c(N, 1); for (int i = 1; i < N; i++){ if (S[i] == S[i - 1]){ c[i] = c[i - 1] + 1; } else { c[i] = 1; } } atcoder::segtree<int, op, e> ST(c); for (int i = 0; i < Q; i++){ int L, R, K; cin >> L >> R >> K; L--; auto itr = st.lower_bound(L); if (*itr >= R){ cout << min(R - L, K - 1) << endl; } else { bool ok = false; if (*itr - L >= K){ ok = true; } if (ST.prod(*itr, R) >= K){ ok = true; } if (!ok){ cout << R - L << endl; } else { int s = sum[R] - sum[L]; s %= K * 2 - 1; s += K * 2 - 1; s %= K * 2 - 1; s = min(s, K * 2 - 1 - s); cout << K * 2 - 2 - s << endl; } } } }