QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#622241#6820. Youth FinaleSound_MediumWA 1ms7764kbC++231.5kb2024-10-08 20:26:562024-10-08 20:27:00

Judging History

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

  • [2024-10-08 20:27:00]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:7764kb
  • [2024-10-08 20:26:56]
  • 提交

answer

#include <bits/stdc++.h>
#define int long long
using namespace std;
#define lowbit(x) (x&(-x))
int n, m;
const int N=3e5+10;
int a[N],tr[N];
const int mod=10;
void add(int x,int k){
    for(int i=x;i<N;i+=lowbit(i)){
        tr[i]+=k;
    }
}
int query(int x){
    int ans=0;
    for(int i=x;i>0;i-=lowbit(i)){
        ans+=tr[i];
    }
    return ans;
}
int query(int l,int r){
    return query(r)-query(l-1);
}
void solve () {
    cin>>n>>m;
    deque<int>q;
    array<int,2>ans={0,0};
    for(int i=1;i<=n;i++){
        cin>>a[i],q.push_back(a[i]);
        ans[0]+=query(a[i],n);
        ans[1]+=query(a[i]);
        ans[0]%=10;
        ans[1]%=10;
        add(a[i],1);
    }
    string s;
    cin>>s;
    int f=0;
    for(auto v:s){
        if(v=='S'){
            if(f==1){
                int k=q.back();
                q.pop_back();
                q.push_front(k);
                ans[f]=(ans[f]-(k-1)+n-k+100000)%mod;
                ans[f^1]=(ans[f^1]-(n-k)+k-1+100000)%mod;
            }else{
                int k=q.front();
                q.pop_front();
                q.push_back(k);
                ans[f]=(ans[f]-(k-1)+n-k+100000)%mod;
                ans[f^1]=(ans[f^1]-(n-k)+k-1+100000)%mod;
            }
        }else{
            f^=1;
            // swap(ans[0],ans[1]);
        }
        cout<<(ans[f]%10);

    }
    
}
signed main () {
    int T = 1; 
    std::ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    //cin>>T;
    while (T --) solve ();
    return 0;
}

詳細信息

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 7764kb

input:

5 10
5 4 3 2 1
SSSSRSSSSR

output:

6446466400

result:

wrong answer 1st words differ - expected: '10', found: '6446466400'