TLE求助
查看原帖
TLE求助
843300
zkhsznlsn楼主2023/10/18 16:28
#include<bits/stdc++.h>
#define int long long
using namespace std;
int n,a[200005],f=2;
bool pd(){
	for(int i=1;i<=n;i++)if(a[i]!=-1)return 1;
	return 0;
}
signed main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin>>n;
	for(int i=1;i<=n;i++)cin>>a[i];
	while(pd()){
		for(int i=1;i<=n;i++){
			if(f!=0&&a[i]==0){
				f=0;
				cout<<i<<" ";
				a[i]=-1;
			}
			if(f!=1&&a[i]==1){
				f=1;
				cout<<i<<" ";
				a[i]=-1;
			}
		}
		cout<<"\n";
		f=2;
	}
	return 0;
}
2023/10/18 16:28
加载中...