没用单调栈,样例过但是WA求调嘤嘤嘤~
查看原帖
没用单调栈,样例过但是WA求调嘤嘤嘤~
956316
77Glorious楼主2024/6/3 20:00

(忽略快读模板没去掉负数w)

#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long ll;
ll read()
{
	char c; ll f=1,x=0;
	c=getchar();
	while(!isdigit(c))
	{
		if(c=='-') f=-1;
		c=getchar();
	}
	while(isdigit(c)) x=x*10+c-'0',c=getchar();
	return x*f;
}
ll n,a[2000010],ans;
int main()
{
	ios::sync_with_stdio(0);
	ll l=1;
	n=read();
	a[1]=read(); ans=1; cout<<ans<<endl;
	for(ll i=2;i<=n;i++)
	{
		a[i]=read();
		if(a[i]<a[l])
		{
			ans^=i;
			cout<<ans<<endl;
		}
		else{
			ans=i;
			l=i;
			cout<<ans<<endl;
		}
	}
}
2024/6/3 20:00
加载中...