QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#622246#6820. Youth FinaleSound_MediumWA 59ms11052kbC++231.6kb2024-10-08 20:28:192024-10-08 20:28:20

Judging History

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

  • [2024-10-08 20:28:20]
  • 评测
  • 测评结果:WA
  • 用时:59ms
  • 内存:11052kb
  • [2024-10-08 20:28:19]
  • 提交

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]);
        
        add(a[i],1);
    }
    string s;
    cin>>s;
    int f=0;
    cout<<ans[0]<<endl;
    ans[0]%=10;
    ans[1]%=10;
    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: 100
Accepted
time: 1ms
memory: 7732kb

input:

5 10
5 4 3 2 1
SSSSRSSSSR

output:

10
6446466400

result:

ok 2 tokens

Test #2:

score: 0
Accepted
time: 0ms
memory: 7728kb

input:

1 1
1
R

output:

0
0

result:

ok 2 tokens

Test #3:

score: 0
Accepted
time: 1ms
memory: 5708kb

input:

1000 2000
313 691 343 806 897 516 38 769 391 353 43 55 246 7 65 790 185 362 60 203 642 66 731 64 760 780 266 920 805 48 724 788 730 560 766 491 748 986 439 904 619 749 652 571 617 785 202 588 234 5 717 113 84 823 399 282 269 894 703 745 886 364 258 177 622 621 573 322 487 422 413 58 39 436 543 756 9...

output:

251209
43874381050107890783098123234927898721470309674923058363694547296507416143876969292321676989034983038541030987896725616943010543872367252169438969430743696107694147678721892527816985092189692785010789030107898907692961674507816763438529678381214145296929276765098723496107898943450929092765672...

result:

ok 2 tokens

Test #4:

score: 0
Accepted
time: 17ms
memory: 6176kb

input:

1000 600000
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 ...

output:

0
9614541690961454169096145416909614541690961454169096145416909614541690961454169096145416909614541690961454169096145416909614541690961454169096145416909614541690961454169096145416909614541690961454169096145416909614541690961454169096145416909614541690961454169096145416909614541690961454169096145416...

result:

ok 2 tokens

Test #5:

score: 0
Accepted
time: 1ms
memory: 5656kb

input:

1000 2000
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 10...

output:

0
9614541690961454169096145416909614541690961454169096145416909614541690961454169096145416909614541690961454169096145416909614541690961454169096145416909614541690961454169096145416909614541690961454169096145416909614541690961454169096145416909614541690961454169096145416909614541690961454169096145416...

result:

ok 2 tokens

Test #6:

score: 0
Accepted
time: 1ms
memory: 5872kb

input:

1000 2000
150 443 960 545 218 487 896 382 519 944 26 699 275 12 715 906 956 513 495 297 501 843 269 378 132 7 758 216 344 660 400 708 9 778 131 803 61 852 746 305 953 354 805 502 601 407 24 189 458 861 17 622 210 500 617 403 650 379 673 943 6 677 196 161 902 743 375 428 723 100 51 614 535 719 780 66...

output:

250097
83450763698129098341058307214561498329894785414721856749038329874905010347832743016943894929492589674569432745416385658569830323278525834143676161670903650345854749414367692929234383210763838129490921254905294583814907656567818349630325814769870507234541478147890327650783412563254523490989252...

result:

ok 2 tokens

Test #7:

score: -100
Wrong Answer
time: 59ms
memory: 11052kb

input:

300000 600000
59593 244970 183397 263692 143501 110537 3864 101843 1080 104527 47380 223219 88791 12167 155830 135504 187349 12430 104143 118721 192905 131555 80271 1440 232446 220093 111239 220148 22134 269720 31720 4511 60938 127008 57672 144594 165595 88632 203696 126332 4331 276338 12191 164758 ...

output:

22488549666
1-89-45250189-8189256101212-9-49-67-298385896-521-450-907-670-38323814-589-432-5-810-3090301050-9094501-49-8-129610-1-81650521-2-725452103296-365-874-381674921-4901-858905616707858-5492-7294-7-2-9-69-8507070-9810-7494169-8-1-8501-8-1090-3610-30-5-4-963070-1034-96-5054-1-8-7-6-7-238-56-30...

result:

wrong answer 2nd words differ - expected: '129652501892189256101212169478...3614989890945812981290585418946', found: '1-89-45250189-8189256101212-9-...-2989094581298-92905854-98-14-4'