求助,疑似访问越界
  • 板块学术版
  • 楼主Tis员工
  • 当前回复1
  • 已保存回复1
  • 发布时间2024/5/20 23:50
  • 上次更新2024/5/21 15:56:50
查看原帖
求助,疑似访问越界
430920
Tis员工楼主2024/5/20 23:50

返回3221225477

上网查实说访问越界,但我没找到qwq

#include<bits/stdc++.h>
using namespace std;
inline int read(){
	int x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-48;ch=getchar();}
	return x*f;
}
int a[200010];
int n,totb,tots=1,totans,g;
int si[200010],ss[200010],r[200010];
int ans[200010];
vector<int>b[200010];
//200010
int main()
{
    n=read();
    for(int i=1;i<=n;i++)a[i]=read();
    for(int i=n;i>=1;i--)b[a[i]].push_back(i);
    
    si[1]=1;ss[1]=b[0].size();r[1]=0;
    while(totans<n){
    	totans++;
    	g=b[totb][si[tots]-1];
    	ans[totans]=g;
		
		//-----应该是这一部分有问题 
    	if(b[g][0]!=0){
    		totb=g;tots++;
    		r[tots]=g;si[tots]=1;ss[tots]=b[g].size();
		}//else if(si[tots]-1==ss[tots]){
		//	tots--;totb=r[tots];si[tots]++;
		//}else {si[tots]++;}
		//------这一部分有问题 
		
	}
	for(int i=1;i<=n;i++)cout<<ans[i]<<" ";
	return 0;
}
2024/5/20 23:50
加载中...