QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#806741 | #9799. Magical Palette | linjingxiang | TL | 0ms | 0kb | C++14 | 907b | 2024-12-09 14:42:02 | 2024-12-09 14:42:03 |
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;
}
}
详细
Test #1:
score: 0
Time Limit Exceeded
input:
2 2 3 2 2