QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#171220#7108. Couleurkjhhjki#Compile Error//C++172.5kb2023-09-09 16:38:262023-09-09 16:38:27

Judging History

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

  • [2023-09-09 16:38:27]
  • 评测
  • [2023-09-09 16:38:26]
  • 提交

answer

#include<cstdio>
#include<set>
#include<algorithm>
using namespace std;
const int MAXN=100003;
typedef long long LL;
struct node {
	int tot;
	node *ch[2];
	node() {
		tot=0;
		ch[0]=ch[1]=NULL;
	}
};
node data[MAXN*20];
node *root[MAXN];
node *ncnt=&data[0];
LL read() {
    LL x=0;char s=getchar();   
    while(s<'0'||s>'9') s=getchar();
    while(s>='0'&&s<='9') x=x*10+s-'0', s=getchar();
    return x;
}
void Build(node *&rt,int l,int r) {
	rt=ncnt++;
	rt->tot=0;
	if(l==r) {
		rt->ch[0]=rt->ch[1]=NULL;
		return ;
	}
	int mid=(l+r)>>1;
	Build(rt->ch[0],l,mid);
	Build(rt->ch[1],mid+1,r);
}
void Insert(node *&x,node *y,int val,int l,int r) {
	x=ncnt++;
	*x=*y; x->tot++;
	if(l==r) return ;
	int mid=(l+r)>>1;
	if(val<=mid) Insert(x->ch[0],y->ch[0],val,l,mid);
	else Insert(x->ch[1],y->ch[1],val,mid+1,r);
}
int Query(node *x,node *y,int k,int l,int r) {   //how many <= k 
	if(l==r) return y->tot - x->tot;
	int mid=(l+r)>>1;
	if(k<=mid) return Query(x->ch[0],y->ch[0],k,l,mid);
	return Query(x->ch[1],y->ch[1],k,mid+1,r) + y->ch[0]->tot - x->ch[0]->tot;
}
int n, a[MAXN], rhs[MAXN];
LL val[MAXN], z[MAXN];
set<int>seq;
multiset<LL,greater<LL> >ans;
void Solve() {
	seq.clear(), ans.clear();
	ncnt=&data[0];
	Build(root[0],0,n=read());
	for(int i=1;i<=n;i++)
		Insert(root[i],root[i-1],a[i]=read(),0,n);
	rhs[1]=n, val[1]=0;
	for(int i=2;i<=n;i++)
		val[1]+=i-1-Query(root[0],root[i-1],a[i],0,n);
	seq.insert(1), ans.insert(val[1]);

	for(int i=1,p;i<=n;i++) {
		z[i]=*ans.begin(), p=read()^z[i];
		set<int>::iterator it=seq.upper_bound(p);
		int pos=*(--it);
		seq.erase(pos), ans.erase(ans.find(val[pos]));
		LL lval, rval;
		if(p-pos<=rhs[pos]-p) {
			lval=0, rval=val[pos];
			for(int i=pos;i<p;i++) {
				rval-=Query(root[i],root[rhs[pos]],a[i]-1,0,n);
				lval+=Query(root[i],root[p-1],a[i]-1,0,n);
			}
			rval-=Query(root[p],root[rhs[pos]],a[p]-1,0,n);
		} else {
			lval=val[pos], rval=0;
			for(int i=rhs[pos];i>p;i--) {
				lval-=(i-pos)-Query(root[pos-1],root[i-1],a[i],0,n);
				rval+=(i-1-p)-Query(root[p],root[i-1],a[i],0,n);
			}
			lval-=(p-pos)-Query(root[pos-1],root[p-1],a[p],0,n);
		}
		if(p!=rhs[pos])
			rhs[p+1]=rhs[pos], seq.insert(p+1), ans.insert(val[p+1]=rval);
		if(p!=pos)
			rhs[pos]=p-1, seq.insert(pos), ans.insert(val[pos]=lval);
	}
	for(int i=1;i<n;i++)
		printf("%lld ",z[i]);
	printf("%lld\n",z[n]);
}
int main() {
	int T;
	scanf("%d",&T);
	for(int Cas=1;Cas<=T;Cas++)
		Solve();
	return 0;
}

詳細信息

answer.code:17:13: error: reference to ‘data’ is ambiguous
   17 | node *ncnt=&data[0];
      |             ^~~~
In file included from /usr/include/c++/11/set:63,
                 from answer.code:2:
/usr/include/c++/11/bits/range_access.h:319:5: note: candidates are: ‘template<class _Tp> constexpr const _Tp* std::data(std::initializer_list<_Tp>)’
  319 |     data(initializer_list<_Tp> __il) noexcept
      |     ^~~~
/usr/include/c++/11/bits/range_access.h:310:5: note:                 ‘template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])’
  310 |     data(_Tp (&__array)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/11/bits/range_access.h:300:5: note:                 ‘template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)’
  300 |     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
/usr/include/c++/11/bits/range_access.h:290:5: note:                 ‘template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)’
  290 |     data(_Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
answer.code:15:6: note:                 ‘node data [2000060]’
   15 | node data[MAXN*20];
      |      ^~~~
answer.code: In function ‘void Solve()’:
answer.code:55:15: error: reference to ‘data’ is ambiguous
   55 |         ncnt=&data[0];
      |               ^~~~
In file included from /usr/include/c++/11/set:63,
                 from answer.code:2:
/usr/include/c++/11/bits/range_access.h:319:5: note: candidates are: ‘template<class _Tp> constexpr const _Tp* std::data(std::initializer_list<_Tp>)’
  319 |     data(initializer_list<_Tp> __il) noexcept
      |     ^~~~
/usr/include/c++/11/bits/range_access.h:310:5: note:                 ‘template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])’
  310 |     data(_Tp (&__array)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/11/bits/range_access.h:300:5: note:                 ‘template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)’
  300 |     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
/usr/include/c++/11/bits/range_access.h:290:5: note:                 ‘template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)’
  290 |     data(_Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
answer.code:15:6: note:                 ‘node data [2000060]’
   15 | node data[MAXN*20];
      |      ^~~~
answer.code: In function ‘int main()’:
answer.code:96:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   96 |         scanf("%d",&T);
      |         ~~~~~^~~~~~~~~