QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#814923#9871. Just another Sorting Problemucup-team3474WA 2ms7964kbC++231.6kb2024-12-14 22:45:132024-12-14 22:45:18

Judging History

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

  • [2024-12-14 22:45:18]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:7964kb
  • [2024-12-14 22:45:13]
  • 提交

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;
    bool flag=0;
    for(int i=2;i<=n;i++) if(a[i]>a[i-1]) flag=1;
    if(sum==0){
        puts("Alice");
    }else{
        if(s[0]=='A'){
            if(sum==1) puts("Alice");
            else puts("Bob");
        }else{
            if(flag) puts("Bob");
            else puts("Alice");
        }
    }
}



//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: 1ms
memory: 7964kb

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: 2ms
memory: 7728kb

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: 7800kb

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
Bob
Bob
Alice
Bob
Bob
Bob
Alice
Bob
Alice

result:

wrong answer 1st lines differ - expected: 'Alice', found: 'Bob'