WA求调
查看原帖
WA求调
1285722
zwz2010楼主2024/9/8 11:44

这道题的样例能过,代码如下

#include<iostream>
#include<cstdio>
using namespace std;
int stack[7][300001];
int top[7];

int main(){
	int n,p,ans,x;
	/*
	while(scanf("%d",&p)==1){
		ans++;
	}
	*/
	scanf("%d%d",&n,&p);
	for(int i=1;i<=n;i++){
		scanf("%d%d",&p,&x);
		while(stack[p][top[p]]>x&&top[p]>0){
			--top[p];
			++ans;
		}
		if(stack[p][top[p]]==x)continue;
		stack[p][++top[p]] = x;++ans;
	}
	printf("%d\n",ans);
	return 0;
}

但是全部WA 然后我把测试点下载下来 发现数据之间没空格(雾) 然后照着测试点数据再交了一份

#include<iostream>
#include<cstdio>
using namespace std;
int stack[7][300001];
int top[7];

int main(){
	int n,p,ans,x,prep;
	/*
	while(scanf("%d",&p)==1){
		ans++;
	}
	*/
	scanf("%d%d",&n,&p);
	prep = p%10;
	for(int i=1;i<=n;i++){
		p = prep;
		scanf("%d",&x);
		prep = x%10;
		if(i!=n) x /=10;
		while(stack[p][top[p]]>x&&top[p]>0){
			--top[p];
			++ans;
		}
		if(stack[p][top[p]]==x)continue;
		stack[p][++top[p]] = x;++ans;
	}
	printf("%d\n",ans);
	return 0;
}

本地运行成功 但交上去全RE 有大佬帮忙看下怎么回事

2024/9/8 11:44
加载中...