QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#499515 | #6726. Turn It Off | pagohia | TL | 0ms | 3700kb | C++14 | 1.0kb | 2024-07-31 15:11:04 | 2024-07-31 15:11:05 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
const int N = 2e5+10;
const int M = 5e4 + 10;
typedef long long ll;
typedef double db;
typedef pair<int, int>pii;
typedef pair<long, long>pll;
int dx[4] = { 0, 1, 0, -1 }, dy[4] = { 1, 0, -1, 0 };
inline long long read()
{
long long w = 1;
long long q = 0;
char ch = ' ';
while (ch != '-' && (ch < '0' || ch>'9')) ch = getchar();
if (ch == '-') w = -1, ch = getchar();
while (ch >= '0' && ch <= '9')
q = q * 10 + ch - '0', ch = getchar();
return w * q;
}
string s;
int L, k, len;
bool f()
{
int cnt = 0;
for (int i = 0; i < len; i++)
{
if (s[i] == '1')
{
i += (L - 1);
cnt++;
if (cnt > k)
return 1;
}
}
return 0;
}
void solve()
{
cin >> len >> k;
cin >> s;
L = len / k + 1;
if (len % k == 0)
{
L--;
}
while (L >= 1)
{
if (f())
break;
L--;
}
cout << ++L << endl;
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int tcase = 1;
cin >> tcase;
while (tcase--)
solve();
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3700kb
input:
2 10 4 0101011111 3 1 010
output:
3 1
result:
ok 2 number(s): "3 1"
Test #2:
score: -100
Time Limit Exceeded
input:
1109 47 36 11101110101001111110101101100001000011101001011 6 5 100010 35 26 00011111000000101010011010100101111 71 45 11101001000111011101101000000000010001100100110000001000011011001011000 32 23 00000100011110010101000110010110 36 30 110110000000000011010001100011111100 21 8 010000011010011101100 9...
output:
1 1 1 1 1 1 2 4 10 2 2 3 3 1 2 1 1 1 1 2 2 2 6 7 1 1 1 1 1 1 1 3 1 1 2 3 1 1 3 1 1 6 1 1 5 1 1 3 10 19 1 1 1 4 1 1 2 1 2 1 1 2 1 1 60 17 3 3 2 2 1 1 4 1 1 1 1 1 2 2 1 3 5 2 1 1 4 2 1 1 3 1 1 1 1 1 5 2 3 1 2 1 1 1 1 2 1 1 2 1 1 81 1 4 1 1 1 2 1 44 1 5 2 3 1 1 1 2 1 8 1 1 3 1 1 2 1 46 1 1 1 1 1 1 1 1 ...