結果
| 問題 |
No.2281 K → K-1 01 Flip
|
| コンテスト | |
| ユーザー |
miscalc
|
| 提出日時 | 2023-04-19 01:06:35 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 692 bytes |
| コンパイル時間 | 1,993 ms |
| コンパイル使用メモリ | 195,164 KB |
| 最終ジャッジ日時 | 2025-02-12 10:05:15 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | RE * 1 |
| other | RE * 56 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main()
{
ll N, K, L;
string S;
cin >> N >> K >> L >> S;
if (K == 1)
return 0;
// 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)
return N;
int x = count(S.begin(), S.end(), '0'), y = N - x;
while (true)
{
if (x < y)
swap(x, y);
if (x < K)
break;
int z = x / K;
x -= z * K;
y += z * (K - 1);
}
cout << x + y << endl;
}
miscalc