QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#305603#6820. Youth Finalelmeowdn#AC ✓40ms22644kbC++142.1kb2024-01-15 18:12:232024-01-15 18:12:23

Judging History

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

  • [2024-01-15 18:12:23]
  • 评测
  • 测评结果:AC
  • 用时:40ms
  • 内存:22644kb
  • [2024-01-15 18:12:23]
  • 提交

answer

//vanitas vanitatum et omnia vanitas
#include<bits/stdc++.h>
#define fi first
#define se second
#define eb emplace_back
#define mp make_pair
using namespace std;
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef __int128 i128;
template<typename T,typename U>
T ceil(T x, U y) {return (x>0?(x+y-1)/y:x/y);}
template<typename T,typename U>
T floor(T x, U y) {return (x>0?x/y:(x-y+1)/y);}
template<class T,class S>
bool chmax(T &a,const S b) {return (a<b?a=b,1:0);}
template<class T,class S>
bool chmin(T &a,const S b) {return (a>b?a=b,1:0);}
int popcnt(int x) {return __builtin_popcount(x);}
int popcnt(ll x)  {return __builtin_popcountll(x);}
int topbit(int x) {return (x==0?-1:31-__builtin_clz(x));}
int topbit(ll x)  {return (x==0?-1:63-__builtin_clzll(x));}
int lowbit(int x) {return (x==0?-1:__builtin_ctz(x));}
int lowbit(ll x)  {return (x==0?-1:__builtin_ctzll(x));}

#define int long long
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pii> vp;
typedef tuple<int,int,int> tiii;
int read() {
  int x=0,w=1; char c=getchar(); 
  while(!isdigit(c)) {if(c=='-') w=-1; c=getchar();}
  while(isdigit(c)) {x=x*10+(c-'0'); c=getchar();} 
  return x*w;
}

const int N=1e6+5;
int n,m,s[N],a[N],ans;
char t[N];
deque<int> b;
vector<int> op;

int lb(int x) {return x&-x;}
void add(int x) {for(;x<=n;x+=lb(x)) s[x]++;}
int qry(int x,int y=0) {for(;x;x-=lb(x)) y+=s[x]; return y;}

signed main() {
  n=read(), m=read();
  rep(i,1,n) a[i]=read(), b.push_back(a[i]);
  per(i,n,1) ans+=qry(a[i]), add(a[i]);
  printf("%lld\n",ans);
  scanf("%s",t+1);
  bool rev=0;
  rep(i,1,m) {
    if(t[i]=='R') {
      rev^=1; ans=n*(n-1)/2-ans;
    } else {
      if(rev==0) {
        int x=b.front(); b.pop_front(); b.push_back(x);
        ans=ans-(x-1)+(n-x);
      } else {
        int x=b.back(); b.pop_back(); b.push_front(x);
        ans=ans-(x-1)+(n-x);
      }
    }
    op.eb(ans%10);
  }
  for(int x:op) printf("%lld",x); puts("");
  return 0;
}

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

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

5 10
5 4 3 2 1
SSSSRSSSSR

output:

10
6446466400

result:

ok 2 tokens

Test #2:

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

input:

1 1
1
R

output:

0
0

result:

ok 2 tokens

Test #3:

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

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: 29ms
memory: 12256kb

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

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

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: 31ms
memory: 22644kb

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: 29ms
memory: 21016kb

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: 40ms
memory: 22124kb

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