70分TLE
查看原帖
70分TLE
1055123
dmh0612楼主2024/10/18 20:50
#include<bits/stdc++.h>
using namespace std;
int n,a[200005][2];
int main(){
	ios::sync_with_stdio(false);
	cin>>n;
	for(int i = 0;i<n;i++){
		cin>>a[i][0];
	}
	int i = 0,s = 0,x = a[0][0];
	while(s!=n){
		if(a[i][0] == x&&!a[i][1]){
			x^=1;
			s++;
			a[i][1] = 1;
			cout<<i+1<<' ';
		}
		if(i == n-1){
			cout<<'\n';
			int t;
			for(int j = 0;j<n;j++){
				if(!a[j][1]){
					t = j;
					break;
				}
			}
			i = t;
			x = a[t][0];
		}else{
		    i++;
		}
	}
	return 0;
}
2024/10/18 20:50
加载中...