QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#500538#6726. Turn It OffziripoWA 30ms4052kbC++20656b2024-08-01 14:18:212024-08-01 14:18:21

Judging History

你现在查看的是最新测评结果

  • [2024-08-01 14:18:21]
  • 评测
  • 测评结果:WA
  • 用时:30ms
  • 内存:4052kb
  • [2024-08-01 14:18:21]
  • 提交

answer

#include<bits/stdc++.h>
#define int long long
using namespace std;

bool check(string s, int mid, int m) {
	int n = 0, i = 0;
	while (i < s.size() && s[i] != '1')i++;
	for (; i < s.size();) {
		n++;
		i += mid;
		while (i < s.size() && s[i] != '1')i++;
	}
	return n > m;
}

signed main() {
	int t; cin >> t;
	for (int i = 0; i < t; i++) {
		int n, m; scanf("%lld%lld", &n, &m);
		string s; cin >> s;
		if (s.find('1') == -1) {
			cout << "0\n";
			continue;
		}
		int l = 1, r = n - 1;
		while (l < r) {
			int mid = l + r >> 1;
			if (check(s, mid, m))l = mid + 1;
			else r = mid;
		}
		cout << l << "\n";
	}
	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
Wrong Answer
time: 30ms
memory: 4052kb

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
59
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
...

result:

wrong answer 65th numbers differ - expected: '60', found: '59'