QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#549208 | #8685. Doing the Container Shuffle | ucup-team052 | AC ✓ | 93ms | 11732kb | C++20 | 1.3kb | 2024-09-06 12:24:37 | 2024-09-06 12:24:38 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define eb emplace_back
//mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define mod 998244353
#define ll long long
#define inf 0x3f3f3f3f
#define INF 0x3f3f3f3f3f3f3f3f
inline int read()
{
char ch=getchar(); int nega=1; while(!isdigit(ch)) {if(ch=='-') nega=-1; ch=getchar();}
int ans=0; while(isdigit(ch)) {ans=ans*10+ch-48;ch=getchar();}
if(nega==-1) return -ans;
return ans;
}
void print(vector<int> x){for(int i=0;i<(int)x.size();i++) printf("%d%c",x[i]," \n"[i==(int)x.size()-1]);}
#define N 1000005
struct BIT
{
int len,t[N];
void init(int l){len=l,memset(t,0,sizeof(t));}
inline int lowbit(int x){return x&(-x);}
void update(int u,int v){for(int i=u;i<=len;i+=lowbit(i)) t[i]+=v;}
int query(int u)
{
int ans=0;
for(int i=u;i>0;i-=lowbit(i)) ans+=t[i];
return ans;
}
int qry(int l,int r) {return query(r)-query(l);}
}t;
int a[N],n;
ll ans;
signed main()
{
cin>>n;
for(int i=1;i<=n;i++) a[i]=read();
ans+=(n-a[1])*2;
ans+=4;
t.init(n);
for(int i=1;i<=n;i++) t.update(i,1);
t.update(a[1],-1);
for(int i=2;i<=n;i++)
{
t.update(a[i],-1);
int p=a[i-1],q=a[i];
if(p>q) swap(p,q);
ans+=t.qry(p,q)*2;
ans+=t.qry(q,n)*2;
ans+=4;
}
printf("%lld.%lld\n",ans/4,ans%4*25);
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 7848kb
input:
1 1
output:
1.0
result:
ok found '1.00000', expected '1.00000', error '0.00000'
Test #2:
score: 0
Accepted
time: 1ms
memory: 8016kb
input:
11 5 9 1 3 11 10 2 4 6 8 7
output:
31.50
result:
ok found '31.50000', expected '31.50000', error '0.00000'
Test #3:
score: 0
Accepted
time: 61ms
memory: 11644kb
input:
1000000 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 100 ...
output:
250000750000.0
result:
ok found '250000750000.00000', expected '250000750000.00000', error '0.00000'
Test #4:
score: 0
Accepted
time: 61ms
memory: 11536kb
input:
1000000 1000000 999999 999998 999997 999996 999995 999994 999993 999992 999991 999990 999989 999988 999987 999986 999985 999984 999983 999982 999981 999980 999979 999978 999977 999976 999975 999974 999973 999972 999971 999970 999969 999968 999967 999966 999965 999964 999963 999962 999961 999960 9999...
output:
1000000.0
result:
ok found '1000000.00000', expected '1000000.00000', error '0.00000'
Test #5:
score: 0
Accepted
time: 57ms
memory: 11644kb
input:
1000000 1000000 1 999999 2 999998 3 999997 4 999996 5 999995 6 999994 7 999993 8 999992 9 999991 10 999990 11 999989 12 999988 13 999987 14 999986 15 999985 16 999984 17 999983 18 999982 19 999981 20 999980 21 999979 22 999978 23 999977 24 999976 25 999975 26 999974 27 999973 28 999972 29 999971 30 ...
output:
250000250000.50
result:
ok found '250000250000.50000', expected '250000250000.50000', error '0.00000'
Test #6:
score: 0
Accepted
time: 93ms
memory: 11596kb
input:
994035 501373 247446 988466 937134 343835 973148 182415 951866 745865 339379 898937 664973 414939 497080 565725 595547 866210 838583 1781 170429 231711 725020 700441 244760 764648 903161 47032 657141 341312 19655 564907 809801 365122 716028 737378 344047 876468 285811 642071 250280 125260 431866 471...
output:
164630427617.50
result:
ok found '164630427617.50000', expected '164630427617.50000', error '0.00000'
Test #7:
score: 0
Accepted
time: 92ms
memory: 11732kb
input:
990577 319151 990109 386981 458867 837995 238010 339168 3601 487855 247241 31467 247761 126854 472633 167808 316914 429050 605798 437031 792795 522666 316627 126071 730410 904464 145293 433549 16684 768650 71832 815538 687489 190661 503739 596590 962984 352360 530342 741527 98472 784959 723314 79978...
output:
163590360586.0
result:
ok found '163590360586.00000', expected '163590360586.00000', error '0.00000'
Test #8:
score: 0
Accepted
time: 77ms
memory: 11660kb
input:
990623 1 2 3 4 5 6 7 9 10 12 13 15 16 17 19 21 24 26 30 32 33 35 36 37 38 39 41 42 43 44 46 48 49 50 51 52 54 56 57 58 59 61 62 65 66 67 69 70 71 74 75 77 80 81 82 83 85 87 88 89 90 91 92 94 96 100 103 106 108 109 110 111 112 113 114 115 116 117 119 120 121 122 123 124 125 129 130 131 132 134 135 13...
output:
181710269146.0
result:
ok found '181710269146.00000', expected '181710269146.00000', error '0.00000'
Test #9:
score: 0
Accepted
time: 74ms
memory: 11656kb
input:
991684 991684 991683 991682 991680 991679 991678 991677 991676 991674 991673 991671 991670 991669 991668 991666 991665 991664 991662 991661 991660 991659 991658 991656 991655 991654 991651 991650 991646 991644 991643 991642 991641 991639 991638 991637 991635 991634 991633 991632 991628 991626 991625...
output:
72935001476.0
result:
ok found '72935001476.00000', expected '72935001476.00000', error '0.00000'
Test #10:
score: 0
Accepted
time: 0ms
memory: 9396kb
input:
2 1 2
output:
2.50
result:
ok found '2.50000', expected '2.50000', error '0.00000'
Test #11:
score: 0
Accepted
time: 1ms
memory: 8704kb
input:
2 2 1
output:
2.0
result:
ok found '2.00000', expected '2.00000', error '0.00000'
Test #12:
score: 0
Accepted
time: 1ms
memory: 8272kb
input:
3 1 2 3
output:
4.50
result:
ok found '4.50000', expected '4.50000', error '0.00000'
Test #13:
score: 0
Accepted
time: 1ms
memory: 9332kb
input:
3 1 3 2
output:
4.50
result:
ok found '4.50000', expected '4.50000', error '0.00000'
Test #14:
score: 0
Accepted
time: 1ms
memory: 9544kb
input:
3 2 1 3
output:
4.0
result:
ok found '4.00000', expected '4.00000', error '0.00000'
Test #15:
score: 0
Accepted
time: 1ms
memory: 7972kb
input:
3 2 3 1
output:
3.50
result:
ok found '3.50000', expected '3.50000', error '0.00000'
Test #16:
score: 0
Accepted
time: 0ms
memory: 8996kb
input:
3 3 1 2
output:
3.50
result:
ok found '3.50000', expected '3.50000', error '0.00000'
Test #17:
score: 0
Accepted
time: 0ms
memory: 8408kb
input:
3 3 2 1
output:
3.0
result:
ok found '3.00000', expected '3.00000', error '0.00000'
Test #18:
score: 0
Accepted
time: 0ms
memory: 9752kb
input:
4 1 2 3 4
output:
7.0
result:
ok found '7.00000', expected '7.00000', error '0.00000'
Test #19:
score: 0
Accepted
time: 1ms
memory: 9308kb
input:
4 4 3 2 1
output:
4.0
result:
ok found '4.00000', expected '4.00000', error '0.00000'
Test #20:
score: 0
Accepted
time: 0ms
memory: 8208kb
input:
4 2 3 4 1
output:
5.50
result:
ok found '5.50000', expected '5.50000', error '0.00000'
Test #21:
score: 0
Accepted
time: 1ms
memory: 8996kb
input:
10 1 3 5 7 9 2 4 6 8 10
output:
29.50
result:
ok found '29.50000', expected '29.50000', error '0.00000'
Test #22:
score: 0
Accepted
time: 1ms
memory: 8552kb
input:
10 10 8 6 4 2 1 3 5 7 9
output:
20.0
result:
ok found '20.00000', expected '20.00000', error '0.00000'
Test #23:
score: 0
Accepted
time: 1ms
memory: 8444kb
input:
100 90 76 96 2 19 32 25 16 14 5 80 72 52 10 41 94 75 11 73 85 42 31 30 28 69 9 60 29 6 93 1 43 97 54 47 34 7 95 22 39 57 12 15 51 26 33 20 53 82 74 24 59 3 62 55 45 71 64 35 17 77 79 50 61 18 100 89 68 44 4 40 84 48 78 98 49 8 23 83 63 91 38 65 46 27 56 92 67 58 88 66 87 81 86 21 13 36 37 99 70
output:
1905.0
result:
ok found '1905.00000', expected '1905.00000', error '0.00000'
Test #24:
score: 0
Accepted
time: 1ms
memory: 7912kb
input:
1000 536 844 931 150 719 434 698 95 224 485 118 759 113 852 362 251 493 185 927 939 949 328 359 554 317 46 591 630 763 877 722 775 675 173 954 815 24 625 547 544 230 689 956 142 944 87 151 285 900 616 540 771 901 398 864 429 818 126 738 450 740 825 670 809 353 581 269 936 146 12 752 505 139 545 364 ...
output:
167358.50
result:
ok found '167358.50000', expected '167358.50000', error '0.00000'
Test #25:
score: 0
Accepted
time: 1ms
memory: 8040kb
input:
10000 3121 5398 7502 7133 2730 4786 9279 968 6950 9938 206 2976 7705 313 171 5770 3278 509 4011 5358 9301 3857 88 3260 3728 30 7258 251 5519 132 5960 3815 7638 8574 5645 6593 6996 1531 6532 1425 3001 6770 8591 9440 1908 1956 1480 9453 4260 4176 4335 8469 8987 6592 8829 4279 5290 5004 2200 1012 2859 ...
output:
16657203.0
result:
ok found '16657203.00000', expected '16657203.00000', error '0.00000'
Test #26:
score: 0
Accepted
time: 8ms
memory: 8792kb
input:
100000 73766 90001 97450 82800 12572 40005 17755 62280 17053 49546 35716 92236 15667 72056 63775 39360 912 43582 67293 41298 82840 35311 78525 54385 64298 94640 17530 32052 35721 52679 51406 9347 77404 45655 38543 85594 35458 96799 20259 81626 27124 61778 63240 87760 60303 89782 71337 28741 12499 26...
output:
1666906476.0
result:
ok found '1666906476.00000', expected '1666906476.00000', error '0.00000'
Extra Test:
score: 0
Extra Test Passed