关于如何卡常
查看原帖
关于如何卡常
769482
CmathFrog楼主2022/8/23 10:31
#include <bits/stdc++.h>
using namespace std;
#define fo(a,b,c) for(register int a=b;a<=c;a++)
#define of(a,b,c) for(register int a=b;a>=c;a--)
const int N=2e5+10;
const int MINN=-0x3f3f3f3f;
bool vis[N];
struct Node{
	int kind;
	int ans;
} a[N];
inline int read(){
	register int s=0,f=1;
	char ch=getchar();
	while(ch<'0'||ch>'9'){
		if(ch=='-') f=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9'){
		s=s*10+ch-'0';
		ch=getchar();
	}
	return s*f;
}
signed main(){
    //ios::sync_with_stdio(false);
	fo(i,0,N-1){
		vis[i]=1;
	}
	//cin.tie(0);
    //cout.tie(0);
	register int n;
	n=read();
	fo(i,1,n){
		a[i].kind=read();
		a[i].ans=i;
	}
	int cnt=n;
	while(cnt){
		int k=0,p=0;
		a[0].kind=MINN;
		fo(i,1,n){
			if(!vis[i]){
				continue;
			}
			if(a[i].kind==a[k].kind){
				continue;
			}
			++p;
			cout<<a[i].ans<<" ";
			k=i;
			--cnt;
			vis[i]=0;
		}
		cout<<endl;
		if(p!=1){
			continue;
		}
		fo(i,1,n){
			if(!vis[i]){
				continue;
			}
			cout<<a[i].ans<<endl;
		}
		return 0;
	}
	return 0;
} 
卡到90,没法了。。
2022/8/23 10:31
加载中...