QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#814926 | #9871. Just another Sorting Problem | ucup-team3474 | WA | 2ms | 7908kb | C++23 | 1.6kb | 2024-12-14 22:50:15 | 2024-12-14 22:50:16 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> PII;
const ll N=5e5+10,mod=998244353;
int n,m,k,l,b;
string tg;
vector<ll> v[N];
ll a[N];
ll tr[N],tr2[N];
int pos[N];
ll mi[N];
ll ksm(ll x,ll p){
ll sum=1,item=x;
while(p){
if(p&1) sum=sum*item%mod;
p>>=1;
item=item*item%mod;
}
return sum;
}
int lowbit(int x){
return x&-x;
}
void add(int x,int c){
for(int i=x;i<=n;i+=lowbit(i)){
// cout<<i<<" ";
tr[i]+=c;
}
// cout<<endl;
}
ll query(ll x){
ll sum=0;
for(int i=x;i>0;i-=lowbit(i)){
sum+=tr[i];
}
return sum;
}
ll g2;
void __(){
string s;
cin>>n>>s;
// cout<<n<<" "<<s<<endl;
for(int i=1;i<=n;i++) scanf("%lld",&a[i]);
ll sum=0;
for(int i=1;i<=n;i++) tr[i]=0;
for(int i=n;i>=1;i--){
// cout<<a[i]<<" ";
sum+=query(a[i]);
add(a[i],1);
}
// cout<<endl;
// cout<<sum<<endl;
int cnt=0;
for(int i=2;i<=n;i++) if(a[i]>a[i-1]) cnt++;
if(cnt==0){
puts("Alice");
}else{
if(s[0]=='B'){
if(n<=3&&cnt==n-1) puts("Alice");
else puts("Bob");
}else{
if(cnt==1) puts("Alice");
else puts("Bob");
}
}
}
//246748500000
int main(){
// ios::sync_with_stdio(0);
// cin.tie(0);
// mi[0]=1;
// for(int i=1;i<=20;i++) mi[i]=mi[i-1]*3;
int _=1;
cin>>_;
for(int i=1;i<=_;i++){
__();
}
// int x;
}
詳細信息
Test #1:
score: 100
Accepted
time: 2ms
memory: 7804kb
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: 0
Accepted
time: 1ms
memory: 7764kb
input:
2 2 Alice 2 1 2 Bob 2 1
output:
Alice Alice
result:
ok 2 lines
Test #3:
score: -100
Wrong Answer
time: 1ms
memory: 7908kb
input:
10 3 Bob 2 3 1 3 Alice 3 1 2 3 Bob 3 1 2 3 Alice 1 3 2 3 Alice 3 2 1 3 Bob 2 1 3 3 Bob 1 3 2 3 Alice 2 1 3 3 Alice 2 3 1 3 Bob 3 2 1
output:
Bob Alice Bob Alice Alice Bob Bob Alice Alice Alice
result:
wrong answer 1st lines differ - expected: 'Alice', found: 'Bob'