大家帮忙看下,在c++上测试是对的,为什么提交后只得72分?
查看原帖
大家帮忙看下,在c++上测试是对的,为什么提交后只得72分?
741022
B2214shengmin楼主2022/6/26 22:50
#include<bits/stdc++.h>
using namespace std;
char a[1000001],b[1000001];
int main(){
	int len,m,i=0,top=-1;
	scanf("%s%d",a,&m);
	len=strlen(a);
	if(m==0){
		puts(a);
		return 0;
	}
	if(m==len)return 0;
	while(m>0){
	while(top<0||i<len&&(b[top]<=a[i]))b[++top]=a[i++];
	top--;m--;
	}
	for(int k=0;k<=top;k++)printf("%c",b[k]);
	for(int k=i;k<len;k++)printf("%c",a[k]);
	return 0;																											
}
2022/6/26 22:50
加载中...