QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#88962#5552. SkyscraperRainAir100 ✓156ms27372kbC++232.0kb2023-03-18 03:02:132023-03-18 03:02:15

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-03-18 03:02:15]
  • 评测
  • 测评结果:100
  • 用时:156ms
  • 内存:27372kb
  • [2023-03-18 03:02:13]
  • 提交

answer

#include <bits/stdc++.h>

#define fi first
#define se second
#define db double
#define U unsigned
#define P std::pair<int,int>
#define LL long long
#define pb push_back
#define MP std::make_pair
#define all(x) x.begin(),x.end()
#define CLR(i,a) memset(i,a,sizeof(i))
#define FOR(i,a,b) for(int i = a;i <= b;++i)
#define ROF(i,a,b) for(int i = a;i >= b;--i)
#define DEBUG(x) std::cerr << #x << '=' << x << std::endl

const int MAXN = 1000+5;
const int ha = 1e9 + 7;

inline void add(int &x,int y){
    x += y-ha;x += x>>31&ha;
}

int f[2][MAXN][MAXN][3],n,L,a[MAXN];
// 和为 j 有 k 个连续段  边界用了 l 个
// 因为从 a[i]->a[i+1] 和的变化是端点的个数(2k-l)

int main(){
    scanf("%d%d",&n,&L);FOR(i,1,n) scanf("%d",a+i);std::sort(a+1,a+n+1);
    if(n == 1){
        puts("1");
        exit(0);
    }
    int now = 0;f[now][0][0][0] = 1;
    FOR(i,1,n){
        CLR(f[now^1],0);
        FOR(j,0,L){
            FOR(k,0,n){
                FOR(l,0,std::min(2,k)){
                    if(!f[now][j][k][l]) continue;
                    int w = (a[i]-a[i-1])*(2*k-l);
                    if(j+w > L) continue;
                    // 合并两个段
                    if(k) add(f[now^1][j+w][k-1][l],1ll*f[now][j][k][l]*(k-1)%ha);
                    // 贴在某个段后面 不使用边界
                    add(f[now^1][j+w][k][l],1ll*f[now][j][k][l]*(2*k-l)%ha);
                    // 新建一个段 不使用边界
                    add(f[now^1][j+w][k+1][l],1ll*f[now][j][k][l]*(k-l+1)%ha);
                    // 新建一个在边界上的段
                    if(l+1 <= 2) add(f[now^1][j+w][k+1][l+1],1ll*f[now][j][k][l]*(2-l)%ha);
                    // 使用边界 贴在之前段上
                    if(l+1 <= 2) add(f[now^1][j+w][k][l+1],1ll*f[now][j][k][l]*(2-l)%ha);
                }
            }
        }
        now ^= 1;
    }
    int ans = 0;
    FOR(i,1,L) add(ans,f[now][i][1][2]);
    printf("%d\n",ans);
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 5
Accepted

Test #1:

score: 5
Accepted
time: 2ms
memory: 3388kb

input:

1 1
8

output:

1

result:

ok single line: '1'

Test #2:

score: 0
Accepted
time: 12ms
memory: 27228kb

input:

2 6
10 4

output:

2

result:

ok single line: '2'

Test #3:

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

input:

3 11
9 1 3

output:

4

result:

ok single line: '4'

Test #4:

score: 0
Accepted
time: 13ms
memory: 27228kb

input:

6 94
45 79 24 10 41 66

output:

12

result:

ok single line: '12'

Test #5:

score: 0
Accepted
time: 11ms
memory: 27128kb

input:

8 945
493 43 988 504 328 730 841 613

output:

2

result:

ok single line: '2'

Test #6:

score: 0
Accepted
time: 26ms
memory: 27184kb

input:

8 846
304 170 710 158 561 934 100 279

output:

2

result:

ok single line: '2'

Test #7:

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

input:

8 160
136 98 27 113 68 11 34 180

output:

0

result:

ok single line: '0'

Test #8:

score: 0
Accepted
time: 14ms
memory: 27368kb

input:

8 77
20 10 22 8 3 14 7 6

output:

39672

result:

ok single line: '39672'

Test #9:

score: 0
Accepted
time: 9ms
memory: 27372kb

input:

8 904
746 229 92 195 358 2 154 709

output:

30

result:

ok single line: '30'

Test #10:

score: 0
Accepted
time: 20ms
memory: 27224kb

input:

8 121
19 41 25 47 31 4 23 17

output:

24760

result:

ok single line: '24760'

Subtask #2:

score: 15
Accepted

Test #11:

score: 15
Accepted
time: 18ms
memory: 27192kb

input:

12 63
8 2 6 3 11 9 1 12 4 5 10 7

output:

472261248

result:

ok single line: '472261248'

Test #12:

score: 0
Accepted
time: 18ms
memory: 27152kb

input:

14 96
17 36 98 27 13 68 11 34 80 50 22 73 94 37

output:

44

result:

ok single line: '44'

Test #13:

score: 0
Accepted
time: 19ms
memory: 27200kb

input:

14 45
6 9 12 15 18 2 14 5 11 17 4 3 7 10

output:

183056086

result:

ok single line: '183056086'

Test #14:

score: 0
Accepted
time: 15ms
memory: 27368kb

input:

14 97
25 2 54 78 9 29 34 99 82 36 14 66 15 64

output:

2

result:

ok single line: '2'

Test #15:

score: 0
Accepted
time: 24ms
memory: 27220kb

input:

14 98
26 70 16 95 30 2 18 96 6 5 52 99 89 24

output:

2

result:

ok single line: '2'

Test #16:

score: 0
Accepted
time: 16ms
memory: 27212kb

input:

14 92
33 3 17 38 39 45 2 48 22 29 9 28 5 10

output:

1235526

result:

ok single line: '1235526'

Test #17:

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

input:

14 29
12 6 16 9 23 20 3 1 8 25 29 26 19 24

output:

2

result:

ok single line: '2'

Test #18:

score: 0
Accepted
time: 15ms
memory: 27184kb

input:

14 43
17 11 7 8 5 2 10 16 12 9 15 3 14 18

output:

110733412

result:

ok single line: '110733412'

Test #19:

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

input:

14 72
7 13 19 16 20 15 4 10 1 6 14 11 5 8

output:

347124497

result:

ok single line: '347124497'

Test #20:

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

input:

14 83
18 73 40 48 86 97 24 21 45 69 36 16 26 35

output:

6

result:

ok single line: '6'

Subtask #3:

score: 80
Accepted

Dependency #1:

100%
Accepted

Dependency #2:

100%
Accepted

Test #21:

score: 80
Accepted
time: 43ms
memory: 27188kb

input:

40 39
14 4 18 1 31 32 21 19 37 15 40 33 30 23 10 12 24 11 39 27 20 22 17 5 25 2 6 35 26 13 29 38 9 36 34 28 8 3 7 16

output:

2

result:

ok single line: '2'

Test #22:

score: 0
Accepted
time: 111ms
memory: 27132kb

input:

78 822
11 17 6 74 82 21 92 70 66 28 37 29 26 85 68 50 77 47 67 59 12 45 19 35 90 15 30 41 55 97 36 84 49 53 65 38 76 46 16 93 48 100 94 80 2 34 1 71 18 39 44 22 20 89 60 88 13 62 32 4 99 40 5 8 25 7 51 33 42 78 23 63 9 58 56 31 95 57

output:

519066706

result:

ok single line: '519066706'

Test #23:

score: 0
Accepted
time: 121ms
memory: 27160kb

input:

100 982
571 304 440 915 800 767 836 922 44 753 87 720 151 411 624 670 606 944 312 432 993 817 700 972 640 371 837 892 858 834 329 178 684 177 490 92 435 712 905 27 791 523 365 891 885 814 442 128 180 785 538 871 562 582 166 803 733 333 855 760 848 378 463 11 820 942 721 300 113 957 391 153 49 15 45 ...

output:

2

result:

ok single line: '2'

Test #24:

score: 0
Accepted
time: 123ms
memory: 27156kb

input:

100 742
251 236 416 365 495 464 259 153 93 317 215 421 61 451 369 242 348 197 288 2 235 129 72 449 376 254 372 330 294 220 472 321 265 80 131 411 81 114 343 139 383 45 329 394 76 481 1 97 448 371 88 44 234 353 262 325 401 381 279 358 424 499 15 346 163 10 111 350 219 291 56 244 386 35 276 322 152 22...

output:

44225906

result:

ok single line: '44225906'

Test #25:

score: 0
Accepted
time: 156ms
memory: 27192kb

input:

100 994
314 762 11 841 979 1 395 508 657 552 787 432 545 740 777 585 253 109 515 455 20 29 672 371 664 948 25 544 855 9 982 553 289 164 360 380 357 462 488 354 900 789 245 881 467 284 275 237 910 568 835 940 685 652 550 267 468 111 590 328 774 582 296 937 875 436 232 973 799 71 588 298 90 647 91 112...

output:

20

result:

ok single line: '20'

Test #26:

score: 0
Accepted
time: 118ms
memory: 27196kb

input:

100 845
122 357 219 392 501 197 521 305 800 730 745 776 71 17 600 681 289 253 129 1 463 41 750 786 184 516 260 479 360 162 383 49 55 641 182 371 429 252 345 270 796 470 311 173 324 126 220 451 632 44 647 271 595 211 793 665 725 320 21 763 462 526 235 350 491 523 661 94 729 323 382 767 69 624 723 240...

output:

964691650

result:

ok single line: '964691650'

Test #27:

score: 0
Accepted
time: 111ms
memory: 27332kb

input:

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

output:

806509145

result:

ok single line: '806509145'

Test #28:

score: 0
Accepted
time: 118ms
memory: 27192kb

input:

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

output:

426165212

result:

ok single line: '426165212'

Test #29:

score: 0
Accepted
time: 105ms
memory: 27372kb

input:

100 572
133 160 57 146 103 124 90 20 95 87 108 193 101 147 2 166 145 157 75 118 176 96 67 65 92 192 141 60 98 110 164 23 86 100 120 121 149 54 177 77 34 198 194 104 9 175 167 31 182 187 126 70 26 159 186 200 22 115 61 73 156 163 49 53 71 32 1 64 148 171 183 180 197 30 102 131 21 152 46 55 158 94 16 ...

output:

608022944

result:

ok single line: '608022944'

Test #30:

score: 0
Accepted
time: 126ms
memory: 27192kb

input:

100 999
195 528 657 37 217 348 814 585 258 861 558 601 237 514 534 476 911 163 267 807 109 508 174 538 897 56 225 467 409 834 562 572 577 115 915 290 736 860 639 695 461 928 344 843 456 122 712 581 613 810 691 484 546 439 435 939 765 482 841 551 119 176 599 275 688 589 821 783 806 735 221 47 904 621...

output:

218730

result:

ok single line: '218730'

Extra Test:

score: 0
Extra Test Passed