QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#307976#7880. Streak ManipulationconfesserWA 26ms8768kbC++171.1kb2024-01-19 12:17:272024-01-19 12:17:28

Judging History

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

  • [2024-01-19 12:17:28]
  • 评测
  • 测评结果:WA
  • 用时:26ms
  • 内存:8768kb
  • [2024-01-19 12:17:27]
  • 提交

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);
						}
					}
				}
				G(j,k,1) dp[i][j]=min(dp[i][j],dp[i][j+1]);
			}
			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;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 2ms
memory: 8324kb

input:

8 3 2
10110110

output:

3

result:

ok 1 number(s): "3"

Test #2:

score: 0
Accepted
time: 0ms
memory: 8768kb

input:

12 3 3
100100010011

output:

2

result:

ok 1 number(s): "2"

Test #3:

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

input:

4 4 4
0000

output:

-1

result:

ok 1 number(s): "-1"

Test #4:

score: -100
Wrong Answer
time: 26ms
memory: 8264kb

input:

1000 200 5
0001001000101001110010011001101010110101101100010100111110111111010010001100100111100101011100011101011001110010111100100100011001010011000100011111010110100001101110101001110000001000111010000111110100111101100110011010011111000111101001010011000111010111010100101111100000100001011001010...

output:

82

result:

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