QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#263414#7771. 不是这一道据数构结题CrysflyCompile Error//C++173.5kb2023-11-24 20:22:272023-11-24 20:22:28

Judging History

你现在查看的是最新测评结果

  • [2023-11-24 20:22:28]
  • 评测
  • [2023-11-24 20:22:27]
  • 提交

answer

// what is matter? never mind. 
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,sse4,popcnt,abm,mmx,avx,avx2") 
#include<bits/stdc++.h>
#define For(i,a,b) for(int i=(a);i<=(b);++i)
#define Rep(i,a,b) for(int i=(a);i>=(b);--i)
#define ll long long
#define ull unsigned long long
using namespace std;
inline int read()
{
    char c=getchar();int x=0;bool f=0;
    for(;!isdigit(c);c=getchar())f^=!(c^45);
    for(;isdigit(c);c=getchar())x=(x<<1)+(x<<3)+(c^48);
    if(f)x=-x;return x;
}

#define mod 1000000007
struct modint{
	int x;
	modint(int o=0){x=o;}
	modint &operator = (int o){return x=o,*this;}
	modint &operator +=(modint o){return x=x+o.x>=mod?x+o.x-mod:x+o.x,*this;}
	modint &operator -=(modint o){return x=x-o.x<0?x-o.x+mod:x-o.x,*this;}
	modint &operator *=(modint o){return x=1ll*x*o.x%mod,*this;}
	modint &operator ^=(int b){
		modint a=*this,c=1;
		for(;b;b>>=1,a*=a)if(b&1)c*=a;
		return x=c.x,*this;
	}
	modint &operator /=(modint o){return *this *=o^=mod-2;}
	friend modint operator +(modint a,modint b){return a+=b;}
	friend modint operator -(modint a,modint b){return a-=b;}
	friend modint operator *(modint a,modint b){return a*=b;}
	friend modint operator /(modint a,modint b){return a/=b;}
	friend modint operator ^(modint a,int b){return a^=b;}
	friend bool operator ==(modint a,int b){return a.x==b;}
	friend bool operator !=(modint a,int b){return a.x!=b;}
	bool operator ! () {return !x;}
	modint operator - () {return x?mod-x:0;}
	bool operator <(const modint&b)const{return x<b.x;}
};
inline modint qpow(modint x,int y){return x^y;}

vector<modint> fac,ifac,iv;
inline void initC(int n)
{
	if(iv.empty())fac=ifac=iv=vector<modint>(2,1);
	int m=iv.size(); ++n;
	if(m>=n)return;
	iv.resize(n),fac.resize(n),ifac.resize(n);
	For(i,m,n-1){
		iv[i]=iv[mod%i]*(mod-mod/i);
		fac[i]=fac[i-1]*i,ifac[i]=ifac[i-1]*iv[i];
	}
}
inline modint C(int n,int m){
	if(m<0||n<m)return 0;
	return initC(n),fac[n]*ifac[m]*ifac[n-m];
}
inline modint sign(int n){return (n&1)?(mod-1):(1);}

#define fi first
#define se second
#define pb push_back
#define mkp make_pair
typedef pair<int,int>pii;
typedef vector<int>vi;

#define maxn 1000005
#define inf 0x3f3f3f3f

int n,m,a[maxn],res[maxn];
vector<pii>Q[maxn];

struct bit{
	vector<int>tr;
	int n;
	void init(int N){n=N,tr=vector<int>(N+1,0);}
	void add(int x,int y){for(;x<=n;x+=x&-x)tr[x]+=y;}
	int ask(int x){
		int s=0;
		for(;x;x^=x&-x)s+=tr[x];
		return s;
	}
	void down(){For(i,1,n)tr[i]+=tr[i^(i&-i)];}
}tr;
int st[maxn],tp;
vi p1[maxn],p2[maxn];
int st[20][maxn];

int jump(int x,int up){
	while(x<=n && a[x]<=up) ++x;
	return x;
}

signed main()
{
	n=read(),m=read();
	For(i,1,n)a[i]=read();
	For(i,1,m){
		int l=read(),r=read();
		Q[l].pb(mkp(r,i));
	}
	st[0]=n+1;
	tr.init(n);
	Rep(i,n,1){
	//	cout<<"i: "<<i<<"\n";
		while(tp&&a[st[tp]]>a[i]){
			for(int j:p1[tp]) tr.add(j,-1);
			for(int j:p2[tp]) tr.add(j,1);
			p1[tp].clear();
			p2[tp].clear();
			tp--;
		}
		if(a[i]==a[st[tp]]){
			st[tp]=i;
			p1[tp].pb(i);
			p2[tp].pb(jump(p2[tp].back()+1,a[i]));
		}else{
			st[++tp]=i;
			p1[tp].pb(i);
			p2[tp].pb(jump(st[tp-1],a[i]));
		}
	//	puts("QAQ");
		tr.add(p1[tp].back(),1);
		tr.add(p2[tp].back(),-1);
		for(auto [r,id]:Q[i]) res[id]=r-i+1-tr.ask(r);
	}
	For(i,1,m)printf("%d\n",res[i]);
    return 0;
}
/*
8 10
1 2
2 3
3 4
4 1
3 6
6 5
5 4
6 7
7 8
8 3
*/

詳細信息

answer.code:91:5: error: conflicting declaration ‘int st [20][1000005]’
   91 | int st[20][maxn];
      |     ^~
answer.code:89:5: note: previous declaration as ‘int st [1000005]’
   89 | int st[maxn],tp;
      |     ^~