QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#307972#7880. Streak ManipulationconfesserWA 25ms8312kbC++171.0kb2024-01-19 12:14:482024-01-19 12:14:48

Judging History

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

  • [2024-01-19 12:14:48]
  • 评测
  • 测评结果:WA
  • 用时:25ms
  • 内存:8312kb
  • [2024-01-19 12:14:48]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using pi=pair<int,int>;
#define F(i,a,b) for(int i=(a);i<=(b);i++)
#define G(i,a,b) for(int i=(a);i>=(b);i--)
#define ms(a,b) memset(a,b,sizeof(a))
#define si(a) ((int)(a).size())
#define all(a) (a).begin(),(a).end()
#define fi first
#define se second
#define pb push_back

const int N=2e5+3;
int a[N],dp[N][6];

int main(){
	cin.tie(0)->ios::sync_with_stdio(0);
	int n,m,k;
	cin>>n>>m>>k;
	F(i,1,n){
		char c;
		cin>>c;
		a[i]=c-'0';
	}
	int l=1,r=n,ans=-1;
	while(l<=r){
		int mid=(l+r)>>1;
		auto chk=[&](){
			ms(dp,63);
			dp[0][0]=0;
			F(i,1,n){
				F(j,1,k){
					int w=0;
					G(k,i,1){
						if(!a[k]) w++;
						if(i-k+1>=mid&&!a[k-1]){
							if(k>=2) dp[i][j]=min(dp[i][j],dp[k-2][j-1]+w);
							else if(j==1) dp[i][j]=min(dp[i][j],w);
						}
					}
				}
			}
			F(i,1,n) if(dp[i][k]<=m) return 1;
			return 0;
		};
		if(chk()){
			ans=mid;
			l=mid+1;
		}else r=mid-1;
	}
	cout<<ans;
}

詳細信息

Test #1:

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

input:

8 3 2
10110110

output:

3

result:

ok 1 number(s): "3"

Test #2:

score: 0
Accepted
time: 2ms
memory: 8312kb

input:

12 3 3
100100010011

output:

2

result:

ok 1 number(s): "2"

Test #3:

score: 0
Accepted
time: 2ms
memory: 8260kb

input:

4 4 4
0000

output:

-1

result:

ok 1 number(s): "-1"

Test #4:

score: -100
Wrong Answer
time: 25ms
memory: 8292kb

input:

1000 200 5
0001001000101001110010011001101010110101101100010100111110111111010010001100100111100101011100011101011001110010111100100100011001010011000100011111010110100001101110101001110000001000111010000111110100111101100110011010011111000111101001010011000111010111010100101111100000100001011001010...

output:

82

result:

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