QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#235108#6820. Youth Finalezyfy#AC ✓44ms8848kbC++141.3kb2023-11-02 14:16:192023-11-02 14:16:20

Judging History

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

  • [2023-11-02 14:16:20]
  • 评测
  • 测评结果:AC
  • 用时:44ms
  • 内存:8848kb
  • [2023-11-02 14:16:19]
  • 提交

answer

#include <bits/stdc++.h>
#define int long long
#define lowbit(x) x & (-x)
using namespace std;
const int N = 3e5 + 6;
int t[N << 2];
int mx;
void update(int now) {
    while(now <= mx) {
        t[now]++;
        now += lowbit(now);
    }
}

int query(int now) {
    int res = 0;
    while(now) {
        res += t[now];
        now -= lowbit(now);
    }
    return res;
}

void solve() {
    int n, m; cin >> n >> m;
    vector<int>a(n + 1);
    
    for(int i = 1; i <= n; i++) {
        cin >> a[i]; mx = max(mx, a[i]);
    }
    int ans = 0;
    for(int i = 1; i <= n; i++) {
        ans += query(mx) - query(a[i]);
        update(a[i]);
    }
    cout << ans << endl;
    string s; cin >> s;
    int now = 1, f = 0;
    for(auto i : s) {
        if(i == 'S') {
            ans += n - a[now] - (a[now] - 1);
        } else {
            ans = n * (n - 1) / 2 - ans;
            f ^= 1;
        }
        if(f == 0) {
            now++;
            if(now == n + 1) now = 1;
        } else {
            now--;
            if(now == 0) now = n;
        }
        cout << ans % 10;
    } cout << '\n';
 
}


signed main() {
	ios::sync_with_stdio(false);
	int tt = 1;
	// cin >> tt;
	while (tt--) {
		solve();
	}
}




这程序好像有点Bug,我给组数据试试?

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3648kb

input:

5 10
5 4 3 2 1
SSSSRSSSSR

output:

10
6446466400

result:

ok 2 tokens

Test #2:

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

input:

1 1
1
R

output:

0
0

result:

ok 2 tokens

Test #3:

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

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: 16ms
memory: 4208kb

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: 0ms
memory: 3596kb

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: 0ms
memory: 3824kb

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: 0
Accepted
time: 40ms
memory: 8672kb

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
129652501892189256101212169478983858965216501074707832381458963252107090301050109450169292961092165052183254521032967652747816749216901258905616707858549232943814925070701810349416929250129090761070561630709034165054923438385670363616369230107214961216925018367290125434907878747270581876...

result:

ok 2 tokens

Test #8:

score: 0
Accepted
time: 37ms
memory: 8676kb

input:

300000 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 9...

output:

0
9614541690961454169096145416909614541690961454169096145416909614541690961454169096145416909614541690961454169096145416909614541690961454169096145416909614541690961454169096145416909614541690961454169096145416909614541690961454169096145416909614541690961454169096145416909614541690961454169096145416...

result:

ok 2 tokens

Test #9:

score: 0
Accepted
time: 44ms
memory: 8848kb

input:

300000 600000
256714 282921 213569 167450 279657 195033 47299 86621 75700 204165 55521 58785 99140 55086 10559 56761 258898 111717 26169 80370 121033 15029 190330 179354 275543 99358 232270 276133 261366 31764 283311 254699 90077 39580 30549 146621 283862 157645 7990 1250 284849 76808 122147 282676 ...

output:

22561618259
214527090101214385894781612769818921890149654567650927854163078349010765232903832345094167076323438385438149498145892165056787058381076183432549476347432109876745816789618589274921454143852101810125616145252987030525894729076907496925612783698781054583096909412145814167612389054187894181...

result:

ok 2 tokens