QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#307990#7880. Streak ManipulationconfesserWA 22ms10260kbC++171.0kb2024-01-19 12:30:292024-01-19 12:30:29

Judging History

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

  • [2024-01-19 12:30:29]
  • 评测
  • 测评结果:WA
  • 用时:22ms
  • 内存:10260kb
  • [2024-01-19 12:30:29]
  • 提交

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][8];

int main(){
	cin.tie(0)->ios::sync_with_stdio(0);
	int n,m,d;
	cin>>n>>m>>d;
	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);
			F(i,0,n) dp[i][0]=0;
			F(i,1,n) G(j,d,1){
				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);
					}
				}
				dp[i][j]=min(dp[i][j],dp[i][j+1]);
			}
			F(i,1,n) if(dp[i][d]<=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: 0ms
memory: 10260kb

input:

8 3 2
10110110

output:

3

result:

ok 1 number(s): "3"

Test #2:

score: 0
Accepted
time: 3ms
memory: 9872kb

input:

12 3 3
100100010011

output:

2

result:

ok 1 number(s): "2"

Test #3:

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

input:

4 4 4
0000

output:

-1

result:

ok 1 number(s): "-1"

Test #4:

score: -100
Wrong Answer
time: 22ms
memory: 9852kb

input:

1000 200 5
0001001000101001110010011001101010110101101100010100111110111111010010001100100111100101011100011101011001110010111100100100011001010011000100011111010110100001101110101001110000001000111010000111110100111101100110011010011111000111101001010011000111010111010100101111100000100001011001010...

output:

90

result:

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