QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#884117#8240. Card GamerandomizationCompile Error//C++141.3kb2025-02-05 21:24:072025-02-05 21:24:30

Judging History

This is the latest submission verdict.

  • [2025-02-05 21:24:30]
  • Judged
  • [2025-02-05 21:24:07]
  • Submitted

answer

#include<bits/stdc++.h>
using namespace std;
void ts(){cout<<"IAKIOI"<<endl;}
const int N=5e5+5; 
int n, q, a[N], las[N];
int rt[N], ls[N<<6], rs[N<<6], tr[N<<], tot;
void upd(int &id, int L, int R, int l, int r){
	tr[++tot]=tr[id];
	ls[tot]=ls[id];
	rs[tot]=rs[id];
	id=tot;
	if(l<=L&&R<=r){
		tr[id]++;
		return;
	}
	int mid=(L+R)>>1;
	if(l<=mid)upd(ls[id],L,mid,l,r);
	if(r>mid)upd(rs[id],mid+1,R,l,r);
}
void update(int &id, int rt, int L, int R, int l, int r){
	tr[++tot]=tr[id];
	ls[tot]=ls[id];
	rs[tot]=rs[id];
	id=tot;
	if(l<=L){
		tr[id]=tr[rt]-r;
		ls[id]=ls[rt];
		rs[id]=rs[rt];
		return;
	}
	int mid=(L+R)>>1;
	if(l<=mid)update(ls[id],ls[rt],L,mid,l,r+tr[id]);
	update(rs[id],rs[rt],mid+1,R,l,r+tr[id]);
}
int qry(int id, int L, int R, int x){
	if(!id)return 0;
	if(L==R)return tr[id];
	int mid=(L+R)>>1;
	if(x<=mid)return qry(ls[id],L,mid,x)+tr[id];
	else return qry(rs[id],mid+1,R,x)+tr[id];
}
signed main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin>>n>>q;
	for(int i=1; i<=n; i++)cin>>a[i],las[a[i]]=n+1;
	for(int i=n; i; i--){
		int j=las[a[i]];
		las[a[i]]=i;
		rt[i]=rt[i+1];
		upd(rt[i],1,n,i,j-1);
		if(j<=n)update(rt[i],rt[j+1],1,n,j,0);
	}
	int lans=0;
	while(q--){
		int l, r;
		cin>>l>>r;
		l^=lans;r^=lans;
		cout<<(lans=qry(rt[l],1,n,r))<<'\n';
	}
	return 0;
}

詳細信息

answer.code:6:38: error: expected primary-expression before ‘]’ token
    6 | int rt[N], ls[N<<6], rs[N<<6], tr[N<<], tot;
      |                                      ^
answer.code: In function ‘void upd(int&, int, int, int, int)’:
answer.code:8:9: error: ‘tr’ was not declared in this scope; did you mean ‘r’?
    8 |         tr[++tot]=tr[id];
      |         ^~
      |         r
answer.code: In function ‘void update(int&, int, int, int, int, int)’:
answer.code:21:9: error: ‘tr’ was not declared in this scope; did you mean ‘rt’?
   21 |         tr[++tot]=tr[id];
      |         ^~
      |         rt
answer.code: In function ‘int qry(int, int, int, int)’:
answer.code:37:24: error: ‘tr’ was not declared in this scope; did you mean ‘ts’?
   37 |         if(L==R)return tr[id];
      |                        ^~
      |                        ts
answer.code:39:46: error: ‘tr’ was not declared in this scope; did you mean ‘ts’?
   39 |         if(x<=mid)return qry(ls[id],L,mid,x)+tr[id];
      |                                              ^~
      |                                              ts
answer.code:40:43: error: ‘tr’ was not declared in this scope; did you mean ‘ts’?
   40 |         else return qry(rs[id],mid+1,R,x)+tr[id];
      |                                           ^~
      |                                           ts