QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#499384#6726. Turn It OffUmokWA 0ms7212kbC++20753b2024-07-31 13:39:572024-07-31 13:39:58

Judging History

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

  • [2024-07-31 13:39:58]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:7212kb
  • [2024-07-31 13:39:57]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
const int N = 1e6 + 5;
#define int long long
typedef pair<int, int> PII;
#define MAX LONG_LONG_MAX
int ar[N];
void solve()
{
    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    s = " " + s;
    for (int i = 1; i <= n;i ++)
        if(s[i] == '1')
            ar[i] = 1;
        else
            ar[i] = 0;
    int ans = 0;
    for (int i = 1; i <= n; i ++)
    {
        if(ar[i] == 0)
            continue;
        ans++;
        i += k - 1;
    }
    cout << ans << endl;
}
signed main()
{
    ios::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    int tcase;
    cin >> tcase;
    while (tcase--)
        solve();
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3616kb

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: 0ms
memory: 7212kb

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:

2
1
2
2
2
2
3
6
9
3
3
3
4
2
2
2
2
2
2
3
2
2
6
7
2
2
2
1
2
2
2
3
2
2
3
4
2
1
4
2
2
7
2
2
5
2
1
4
9
15
2
2
2
5
2
2
3
2
3
2
2
2
1
2
26
11
3
4
3
3
2
2
4
2
2
2
1
2
2
3
2
4
4
3
2
2
5
4
2
2
4
2
2
2
2
2
5
3
4
2
3
1
2
2
2
2
2
2
3
1
1
47
2
5
2
2
1
2
2
20
2
5
3
3
2
1
2
3
2
8
1
2
4
2
2
3
2
33
2
1
2
2
1
2
2
2
3
...

result:

wrong answer 1st numbers differ - expected: '1', found: '2'