QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#499378#6726. Turn It OffRailgun2334WA 31ms4316kbC++202.9kb2024-07-31 13:32:212024-07-31 13:32:21

Judging History

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

  • [2024-07-31 13:32:21]
  • 评测
  • 测评结果:WA
  • 用时:31ms
  • 内存:4316kb
  • [2024-07-31 13:32:21]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define re read()
#define MOD 998244353
#define i128 __int128
#define pll pair<ll,ll>
#define pii pair<int,int>
#define ull unsigned long long
#define INF 9223372036854775800
#define fr(i, x, y) for (int i = x, p = y; i <= p; ++i)
#define rp(i, x, y) for (int i = x, p = y; i >= p; --i)
#define Timeok ((double)clock() / CLOCKS_PER_SEC < MAX_TIME)
const double MAX_TIME = 1.0 - 0.0032;

inline ll read() {
	ll x = 0, f = 0;
	char ch = getchar();
	while (!isdigit(ch))
		f |= (ch == '-'), ch = getchar();
	while (isdigit(ch))
		x = (x << 1) + (x << 3) + (ch ^= 48), ch = getchar();
	return f ? -x : x;
}

void write(i128 x) {
	if (x < 0)
		putchar('-'), x = -x;
	if (x > 9)
		write(x / 10);
	putchar(x % 10 + 48);
}

inline void W(i128 x, char ch) {
	write(x);
	putchar(ch);
}

ll ksm(ll a, ll b, ll mod) { //快速幂mod
	a %= mod;
	ll res = 1;
	while (b > 0)
	{
		if (b & 1)
			res = res * a & mod;
		a = a * a % mod;
		b >>= 1;
	}
	return res;
}
ll ksm(ll a, ll b) { //快速幂
	ll res = 1;
	while (b > 0)
	{
		if (b & 1)res = res * a;
		a = a * a;
		b >>= 1;
	}
	return res;
}

pii fib(ll n) { //计算第n和n+1位斐波那契数
	if (n == 0)return{ 0,1 };
	auto p = fib(n >> 1);
	ll c = p.first * (2 * p.second - p.first);
	ll d = p.first * p.first + p.second * p.second;
	if (n & 1)
		return { d,c + d };
	else
		return { c,d };
}

ll exgcd(ll a, ll b, ll& x, ll& y) { //扩展欧几里得
	ll x1 = 1, x2 = 0, x3 = 0, x4 = 1;
	while (b != 0) {
		ll c = a / b;
		std::tie(x1, x2, x3, x4, a, b) =
			std::make_tuple(x3, x4, x1 - x3 * c, x2 - x4 * c, b, a - b * c);
	}
	x = x1, y = x2;
	return a;
}

bool liEu(ll a, ll b, ll c, ll& x, ll& y) { //线性同余方程
	ll d = exgcd(a, b, x, y);
	if (c % d != 0) return 0;
	ll k = c / d;
	x *= k;
	y *= k;
	return 1;
}

ll r[105]; //取模数
ll CRT(int k, ll* a, ll* r) { //中国剩余定理
	ll n = 1, ans = 0;
	for (int i = 1; i <= k; i++) n = n * r[i];
	for (int i = 1; i <= k; i++) {
		ll m = n / r[i], b, y;
		exgcd(m, r[i], b, y);  // b * m mod r[i] = 1
		ans = (ans + a[i] * m * b % n) % n;
	}
	return (ans % n + n) % n;
}
/*
ll Lucas(ll n, ll m, ll p) {
  if (m == 0) return 1;
  return (C(n % p, m % p, p) * Lucas(n / p, m / p, p)) % p;
}*/

int gcd(int a, int b) {
	return b == 0 ? a : gcd(b, a % b);
}

int lcm(int a, int b) {
	return a * b / gcd(a, b);
}
/*------------C-O-D-E------------*/
const int N = 1e5 + 4;
//int n, m, M, mod=998244353;
int a[114514];
void solve()
{
    int n,k;
    int sum=0;
    int ans=1;
	cin>>n>>k;
    string s;
    cin>>s;
    for(int i=0;i<n;i++)
    {
        if(s[i]=='1')
        {
            a[++sum]=i+1;
        }
    }
    for(int i=2;i<=sum;i+=k)
    {
        ans=max(ans,a[i]-a[i-1]+1);
    }
    cout<<ans<<endl;
}
int main()
{
	ll T = 1;
	cin>>T;
	while (T--)
	{
		solve();
	}
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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: 31ms
memory: 4316kb

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
5
2
2
5
2
7
3
3
3
2
3
3
2
2
2
2
2
2
2
2
3
5
5
5
2
2
1
2
4
2
2
3
4
5
6
2
3
3
6
2
3
2
2
7
3
1
3
3
6
2
2
2
2
3
2
2
2
3
6
8
4
3
3
9
5
4
2
5
4
2
2
6
5
9
2
1
3
2
3
6
2
5
8
4
2
3
2
2
6
3
3
3
6
2
2
3
3
3
4
5
1
2
2
2
8
2
2
5
2
1
6
2
3
2
3
3
2
2
13
2
5
6
4
2
4
2
6
4
5
2
2
4
2
2
2
2
8
2
5
3
5
2
3
2
2
2
2
2
3...

result:

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