QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#875967 | #9871. Just another Sorting Problem | windcity# | WA | 1ms | 3840kb | C++14 | 764b | 2025-01-30 15:03:44 | 2025-01-30 15:03:45 |
Judging History
answer
#include<cmath>
#include<cstdio>
#include<vector>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
int a[100001],f[100001],n;
inline int lowbit(int x){return x&-x;}
inline void add(int x){
while(x<=n){
f[x]++;
x+=lowbit(x);
}
}
inline int query(int x){
int sum=0;
while(x!=0){
sum+=f[x];
x-=lowbit(x);
}
return sum;
}
int main(){
int t;
scanf("%d",&t);
while(t--){
scanf("%d",&n);string s;cin>>s;
for(register int i=1;i<=n;++i){
scanf("%d",&a[i]);
f[i]=0;
}
int ans=0;
for(register int i=1;i<=n;++i){
add(a[i]);
ans+=i-query(a[i]);
}
if(ans%2==1)cout<<s<<endl;
else if(s[0]=='A')cout<<"Bob\n";
else cout<<"Alice\n";
}
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 3840kb
input:
3 2 Alice 2 1 3 Bob 1 3 2 10 Bob 1 2 3 4 5 6 7 8 10 9
output:
Alice Bob Bob
result:
ok 3 lines
Test #2:
score: -100
Wrong Answer
time: 1ms
memory: 3712kb
input:
2 2 Alice 2 1 2 Bob 2 1
output:
Alice Bob
result:
wrong answer 2nd lines differ - expected: 'Alice', found: 'Bob'