QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#442216#8781. Element-Wise ComparisonRimworld#RE 221ms314488kbC++14824b2024-06-15 10:17:102024-06-15 10:17:10

Judging History

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

  • [2024-06-15 10:17:10]
  • 评测
  • 测评结果:RE
  • 用时:221ms
  • 内存:314488kb
  • [2024-06-15 10:17:10]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

const int maxn=5e4; 
int n,m,a[maxn+5]; 
bitset<maxn+5> B[maxn+5],suf[maxn+5],pre[maxn+5]; 
int pos[maxn+5]; 
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin>>n>>m;
    for (int i=1;i<=n;i++) {
        cin>>a[i]; 
        pos[a[i]]=i; 
    }
    bitset<maxn+5> S;
    for (int i=1;i<=n;i++) S[i]=1;
    for (int i=1;i<=n;i++) {
        S[pos[i]]=0;
        B[pos[i]]=(S>>pos[i]); 
    }
    long long ans=0; 
    for (int i=m;i<=n;i+=m) {
        suf[1]=pre[1]=B[i]; 
        for (int j=2;j<=m;j++) {
            suf[j]=suf[j-1]&B[i-j+1];
            pre[j]=pre[j-1]&B[i+j-1];  
        }
        for (int j=1;j<=m;j++) {
            ans+=(suf[j]&pre[m-j+1]).count(); 
        }
    }
    cout<<ans<<'\n'; 
    return 0; 
}

詳細信息

Test #1:

score: 100
Accepted
time: 1ms
memory: 7688kb

input:

5 3
5 2 1 3 4

output:

0

result:

ok answer is '0'

Test #2:

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

input:

5 2
3 1 4 2 5

output:

2

result:

ok answer is '2'

Test #3:

score: 0
Accepted
time: 2ms
memory: 9756kb

input:

4 2
1 2 3 4

output:

3

result:

ok answer is '3'

Test #4:

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

input:

4 2
4 3 2 1

output:

0

result:

ok answer is '0'

Test #5:

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

input:

1 1
1

output:

0

result:

ok answer is '0'

Test #6:

score: 0
Accepted
time: 200ms
memory: 312620kb

input:

50000 2
44045 29783 5389 7756 44022 45140 21967 5478 10868 49226 21775 31669 49836 13511 46116 14229 27206 31168 37389 3158 10658 41154 14635 18526 40540 6451 23197 46719 30593 13517 8604 46666 39189 43746 12778 3684 3194 36979 43020 14652 19549 31178 17144 27177 44336 2849 40220 11751 41993 32209 4...

output:

310780127

result:

ok answer is '310780127'

Test #7:

score: 0
Accepted
time: 203ms
memory: 313248kb

input:

50000 2
44015 31580 38779 29675 3269 12273 40322 471 4551 44568 21486 17093 43442 11483 9686 39913 36953 47673 34066 4943 28304 34228 9197 43349 1974 32227 8177 33236 24942 42131 34294 48071 17452 9633 18281 13817 27423 9880 15629 6991 20035 13601 39212 33548 8865 39161 48449 22164 36815 28852 43065...

output:

317708201

result:

ok answer is '317708201'

Test #8:

score: 0
Accepted
time: 193ms
memory: 313884kb

input:

50000 2
45828 16955 24033 12988 15675 6086 482 27940 30132 39389 14266 35347 46159 8317 24605 9737 30077 32664 6326 43387 7896 17806 20481 8573 8438 36474 33708 42437 8187 12300 13318 48764 34683 14983 40909 34874 47938 31131 12519 21122 22457 21062 32953 47733 46731 18062 1061 28388 27032 47303 390...

output:

309719539

result:

ok answer is '309719539'

Test #9:

score: 0
Accepted
time: 197ms
memory: 313260kb

input:

50000 2
17900 11121 24441 14321 9486 32843 40283 49359 21526 27801 47381 11444 24372 25999 16187 49470 11724 21419 31873 49053 47656 4516 33567 25021 42444 36150 1362 3711 31260 49923 19998 7275 2927 29522 40437 39439 30777 6413 17107 30917 48362 29997 47038 23951 25835 23665 2875 18889 10610 26400 ...

output:

313258830

result:

ok answer is '313258830'

Test #10:

score: 0
Accepted
time: 211ms
memory: 314488kb

input:

50000 2
29869 3482 18962 41513 1378 27297 29435 6651 12343 3742 27703 32031 15628 16084 12571 1726 30037 31904 2642 817 26607 21749 34528 33044 39980 26798 41826 37079 2809 33387 10169 47346 8551 24214 40572 43065 41730 32281 16630 47892 48890 34159 12884 8185 38452 15606 19304 8428 24230 31397 2232...

output:

313582202

result:

ok answer is '313582202'

Test #11:

score: 0
Accepted
time: 216ms
memory: 313124kb

input:

50000 25
24181 9781 31983 1958 1472 39943 17049 26890 16005 42039 40012 41453 7508 47251 35614 5522 27201 31665 6000 49393 17743 30487 44282 1097 39409 39745 43972 13876 33786 40423 41046 227 44642 27611 9775 21229 48475 7795 32834 15085 44154 45504 26464 45685 42844 44948 26372 30941 8490 8094 4343...

output:

58

result:

ok answer is '58'

Test #12:

score: 0
Accepted
time: 221ms
memory: 311772kb

input:

50000 25
6313 11310 29122 32400 9407 40175 21363 25205 29691 30033 29057 30793 36967 207 521 12478 24585 23970 5059 11072 43604 39890 37153 33289 32907 12925 22807 9811 13003 49978 46897 4643 36366 15146 47056 35036 620 17016 36024 2580 26634 22497 33728 49094 42598 29510 2588 11492 39217 19535 3568...

output:

64

result:

ok answer is '64'

Test #13:

score: 0
Accepted
time: 214ms
memory: 312160kb

input:

50000 25
7101 46567 42238 21041 47850 43080 21835 14601 21483 45662 8296 49277 44528 8471 16934 49649 1159 37986 23124 44670 27253 4997 22785 23185 23498 28808 42277 2373 4953 45403 17687 6448 6646 11865 37061 16908 43882 22053 18899 32888 3268 13484 8282 28369 45369 32118 19979 14248 18913 30053 37...

output:

4

result:

ok answer is '4'

Test #14:

score: 0
Accepted
time: 214ms
memory: 313564kb

input:

50000 25
9582 16768 44838 18085 12760 46386 18931 47470 38877 23660 42553 15072 1132 7328 39756 19422 43849 5886 9208 46852 49509 26185 42588 9415 41859 21884 49608 29541 6265 4552 30506 11148 40872 12019 7531 39615 10614 12159 2888 43822 43634 44176 10373 12227 32929 26749 20475 3280 27429 22261 80...

output:

28

result:

ok answer is '28'

Test #15:

score: 0
Accepted
time: 216ms
memory: 313296kb

input:

50000 25
18777 32602 29569 8351 12443 5109 46381 5184 35720 26389 29442 26751 49739 48691 22692 18229 45132 45826 46500 38936 3677 2482 3508 36713 12096 4589 31302 45887 18816 9740 42267 2275 7538 34775 41814 36968 10986 25755 13093 20616 34034 13055 36066 41746 36775 48968 33860 5503 17541 49741 47...

output:

38

result:

ok answer is '38'

Test #16:

score: -100
Runtime Error

input:

50000 250
15070 16717 48256 4440 24276 17592 15337 6219 15845 49955 49002 14123 11954 42720 46986 13584 375 6790 1018 42467 49666 37960 47896 26126 14305 30153 44783 26247 2186 19154 4711 38130 33117 11795 16035 32042 4312 28081 24406 3372 23671 23565 10262 43282 49792 44765 6270 23998 9630 20581 15...

output:


result: