結果
問題 | No.2281 K → K-1 01 Flip |
ユーザー |
![]() |
提出日時 | 2023-04-19 01:16:55 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
RE
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 714 bytes |
コンパイル時間 | 1,904 ms |
コンパイル使用メモリ | 194,500 KB |
最終ジャッジ日時 | 2025-02-12 10:05:29 |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | RE * 1 |
other | WA * 42 RE * 14 |
ソースコード
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { ll N, K, L; string S; cin >> N >> K >> L >> S; // 1 回は操作できるか判定 string T = S + S; bool ok = false; { int len = 1; for (int i = 1; i < min(L * N, 2 * N); i++) { if (T.at(i - 1) == T.at(i)) len++; else len = 1; if (len >= K) ok = true; } } if (!ok) { cout << L * N << endl; return 0; } ll x = count(S.begin(), S.end(), '0'), y = N - x; x *= L, y *= L; while (true) { if (x < y) swap(x, y); if (x < K) break; ll z = x / K; x -= z * K; y += z * (K - 1); } cout << x + y << endl; }