QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#806741#9799. Magical PalettelinjingxiangTL 0ms0kbC++14907b2024-12-09 14:42:022024-12-09 14:42:03

Judging History

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

  • [2024-12-09 14:42:03]
  • 评测
  • 测评结果:TL
  • 用时:0ms
  • 内存:0kb
  • [2024-12-09 14:42:02]
  • 提交

answer

#include <bits/stdc++.h>
#define ll long long
#define maxn 500005
using namespace std;
int t,n,c[maxn],mp[maxn];
ll ans;
struct node{int pos,val;}a[maxn];
inline bool cmp(node x,node y){return x.val>y.val;}
inline int lowbit(int x){return x&-x;}
inline void modify(int x){while(x<=n)c[x]++,x+=lowbit(x);}
inline int getsum(int x){
	int res=0;
	while(x)res+=c[x],x-=lowbit(x);
	return res;
}
int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin>>t;
	while(t--){
		ans=0;
		cin>>n;
		for(int i=1;i<=n;i++)cin>>a[i].val;
		for(int i=1;i<=n;i++)cin>>a[i].pos;
		sort(a+1,a+n+1,cmp);
		for(int i=1;i<=n;i++)mp[a[i].pos]=i;
		for(int i=1;i<=n;i++)ans+=getsum(mp[i]),modify(mp[i]);
		cout<<((ans&1)?'A':'B');
		for(int l,r,k,i=1;i<n;i++){
			char ch;cin>>ch>>l>>r>>k;
			ans+=(r-l)*k;
			cout<<((ans&1)?'A':'B');
		}
		cout<<'\n';
		for(int i=1;i<=n;i++)c[i]=0;
	}
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Time Limit Exceeded

input:

2
2 3
2 2

output:


result: