70分,超时了,求助
查看原帖
70分,超时了,求助
486166
Incin楼主2021/10/29 20:39
#include<bits/stdc++.h>
using namespace std;

const int N = 200010;

typedef long long LL;

int n;
int a[N];
int st[N],ans;

int main()
{
	scanf("%d",&n);
	for(int i =1;i<=n;i++)scanf("%d",&a[i]);
	
	int i,j,cnt,first = 1;
		
	while(ans<n)
	{
		for(i = first;i <= n;i ++)
		{
			if(!st[i])
			{
				cnt = a[i];
				st[i] = true;
				first = i;
				ans ++;
				printf("%d ",i);
				break;	
			}
		}
		
		for( j =i + 1;j <= n;j ++)
		{
			if(!st[j])
			{
				if(a[j] != cnt)
				{
					st[j]  = true;
					cnt = a[j];
					ans++;
					printf("%d ",j);
				}
			}	
		}
	printf("\n");
	}
	
	return 0;
} 
2021/10/29 20:39
加载中...