QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#640182#3090. Inverse ProblemohwphilAC ✓100ms35816kbPython3572b2024-10-14 08:45:062024-10-14 08:45:08

Judging History

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

  • [2024-10-14 08:45:08]
  • 评测
  • 测评结果:AC
  • 用时:100ms
  • 内存:35816kb
  • [2024-10-14 08:45:06]
  • 提交

answer

N,M=map(int,input().split())
*nums,=map(int,input().split())
in_nums=[0]*(N+1)
for n in nums:
    in_nums[n]=1
max_idx=0
ans=1
MOD=119<<23|1
for i in range(M-1):
    if nums[i]>nums[i+1]:
        break
    max_idx+=1
is_increasing=False
if sum(in_nums[:nums[0]])!=nums[0]-1:
    print(0)
    exit(0)
curr_idx=0
adder=0
for curr_num in range(1,N+1):
    if in_nums[curr_num]:
        continue
    while curr_idx<=max_idx and curr_num>nums[curr_idx]:
        curr_idx+=1
    ans=ans*(curr_idx+adder+(curr_idx==max_idx+1))%MOD
    adder+=1
print(ans)

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 13ms
memory: 10580kb

input:

7 2
2 1

output:

720

result:

ok single line: '720'

Test #2:

score: 0
Accepted
time: 8ms
memory: 10676kb

input:

8 5
2 3 4 5 8

output:

0

result:

ok single line: '0'

Test #3:

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

input:

498 121
20 35 40 72 79 92 113 117 154 231 243 244 264 268 304 337 362 378 463 477 56 494 495 1 342 395 183 423 291 475 82 422 96 265 83 283 242 34 187 75 74 47 208 380 400 17 202 50 418 73 233 307 181 344 48 149 107 435 365 459 280 55 375 391 403 241 64 374 10 386 322 308 186 136 277 497 332 262 165...

output:

0

result:

ok single line: '0'

Test #4:

score: 0
Accepted
time: 6ms
memory: 10544kb

input:

499 396
2 3 6 8 11 13 14 15 16 19 22 23 24 32 36 37 40 41 44 51 53 56 57 58 61 62 66 68 74 75 76 79 80 85 86 87 89 90 91 92 96 98 101 102 109 110 111 113 114 115 117 119 122 123 127 129 130 135 140 141 145 149 150 160 163 166 167 171 173 176 177 183 185 195 197 200 204 207 210 216 217 229 230 235 23...

output:

824443602

result:

ok single line: '824443602'

Test #5:

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

input:

500 484
2 3 6 9 11 14 16 17 19 22 23 24 25 26 28 30 31 34 36 37 41 51 52 53 57 60 62 63 64 67 69 73 74 79 81 83 85 87 88 92 101 103 105 108 113 119 120 122 123 125 126 127 128 129 130 131 134 136 137 140 142 146 149 151 152 156 157 158 159 160 162 163 165 169 170 172 175 178 183 184 185 187 194 197 ...

output:

571655683

result:

ok single line: '571655683'

Test #6:

score: 0
Accepted
time: 7ms
memory: 10644kb

input:

500 25
6 16 62 1 91 97 112 158 186 300 327 362 364 367 401 412 180 297 254 372 302 131 38 346 321

output:

0

result:

ok single line: '0'

Test #7:

score: 0
Accepted
time: 92ms
memory: 31508kb

input:

249999 198363
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 31 32 33 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 76 77 78 83 86 87 88 90 94 95 96 98 99 100 101 105 106 107 108 109 110 111 112 113...

output:

190813000

result:

ok single line: '190813000'

Test #8:

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

input:

250000 112504
1 4 5 6 9 10 12 15 16 20 21 24 25 27 29 32 33 35 49 57 58 59 60 61 62 63 65 66 67 70 72 73 75 76 78 83 84 86 88 92 94 95 96 98 103 104 107 109 110 111 112 120 124 125 129 130 132 135 137 138 139 140 152 153 154 156 158 161 163 164 167 168 171 172 174 177 179 181 182 184 185 188 193 194...

output:

276915868

result:

ok single line: '276915868'

Test #9:

score: 0
Accepted
time: 74ms
memory: 13736kb

input:

250000 13727
1 18 25 28 30 35 56 66 106 138 205 247 305 322 376 387 408 425 427 476 478 508 517 559 562 565 586 619 642 650 672 676 687 718 747 748 789 796 820 830 844 852 854 875 879 916 923 982 1050 1064 1119 1122 1134 1158 1163 1167 1197 1200 1211 1302 1303 1330 1376 1400 1406 1411 1427 1450 1452...

output:

453743268

result:

ok single line: '453743268'

Test #10:

score: 0
Accepted
time: 83ms
memory: 21696kb

input:

250000 111448
1 5 6 10 11 13 16 19 21 24 25 26 29 33 37 38 40 42 46 47 51 52 54 55 58 59 61 63 67 68 70 71 72 73 74 75 77 82 84 85 87 88 89 90 91 95 96 98 104 105 107 110 111 115 116 118 119 120 123 124 126 127 129 130 133 137 138 139 140 143 144 147 150 151 155 161 162 164 167 168 169 170 171 175 1...

output:

447677020

result:

ok single line: '447677020'

Test #11:

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

input:

249999 106534
8 1 65 66 102 115 150 183 188 189 200 205 229 231 262 292 305 343 400 429 471 507 520 529 530 627 693 699 829 840 897 960 972 1110 1179 1202 1217 1225 1263 1264 1301 1325 1334 1423 1434 1452 1543 1579 1585 1598 1660 1667 1687 1689 1705 1707 1792 1800 1861 1885 2027 2137 2173 2205 2209 ...

output:

0

result:

ok single line: '0'

Test #12:

score: 0
Accepted
time: 55ms
memory: 30628kb

input:

250000 215199
2 1 3 4 6 8 9 10 11 13 14 16 20 21 22 23 26 29 30 32 36 37 38 41 46 47 50 51 53 62 67 69 70 71 72 73 75 77 84 87 88 90 95 97 98 99 101 102 106 109 111 112 115 117 118 120 123 126 127 130 131 134 136 138 139 140 142 145 147 149 151 152 154 155 157 159 161 162 163 164 165 167 172 173 174...

output:

840500544

result:

ok single line: '840500544'

Test #13:

score: 0
Accepted
time: 59ms
memory: 23276kb

input:

250000 128016
4 1 9 10 14 18 19 20 28 34 35 40 43 44 45 47 48 49 60 67 71 79 80 82 84 85 88 89 92 94 102 104 109 111 112 115 117 123 125 126 129 140 147 149 151 155 159 162 164 166 172 177 180 184 187 189 193 197 198 200 201 210 212 214 216 222 223 225 226 227 229 234 237 243 248 251 253 255 256 258...

output:

548846886

result:

ok single line: '548846886'

Test #14:

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

input:

250000 86285
35 1 225 325 457 589 619 747 756 1252 1310 1388 1505 1709 1794 1808 1936 1951 2144 2165 2250 2354 2443 2482 2577 2622 2638 2707 2909 2965 3048 3081 3198 3408 3428 3438 3541 3548 3634 3722 3741 4080 4193 4228 4235 4237 4244 4264 4641 4658 4707 4768 4965 5021 5049 5144 5203 5230 5284 5287...

output:

0

result:

ok single line: '0'

Test #15:

score: 0
Accepted
time: 45ms
memory: 25404kb

input:

249999 161229
5 9 10 18 19 20 21 29 30 34 40 47 48 49 50 52 54 55 56 58 62 69 76 80 81 85 88 92 103 105 113 123 127 129 131 138 146 147 152 155 157 163 164 170 172 175 176 177 180 181 184 188 189 192 194 196 199 211 213 214 221 222 225 227 228 234 235 241 242 243 246 247 249 252 254 255 269 271 275 ...

output:

0

result:

ok single line: '0'

Test #16:

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

input:

250000 10338
109 114 151 176 267 294 334 393 466 485 554 660 675 680 739 913 925 959 1042 1073 1083 1122 1125 1218 1280 1294 1389 1420 1486 1787 1912 1934 1937 1974 2068 2094 2186 2355 2397 2491 2544 2671 2761 2766 2855 2971 3230 3290 3445 3485 3497 3736 3840 3963 3992 3994 4064 4195 4255 4321 4487 ...

output:

0

result:

ok single line: '0'

Test #17:

score: 0
Accepted
time: 60ms
memory: 35816kb

input:

250000 250000
2 5 6 7 8 10 11 12 13 14 17 31 32 33 38 40 42 44 47 48 51 54 55 56 59 61 62 64 66 70 71 73 81 82 84 85 86 88 89 93 96 97 100 101 105 108 109 110 111 118 119 120 123 124 125 126 131 132 133 135 136 137 138 140 141 144 145 146 147 149 150 151 152 153 155 156 163 165 168 169 170 171 172 1...

output:

1

result:

ok single line: '1'

Test #18:

score: 0
Accepted
time: 87ms
memory: 31512kb

input:

250000 198427
1 2 5 7 11 13 14 18 22 24 25 28 31 32 35 36 39 41 42 45 47 48 49 50 51 54 58 61 67 68 70 76 78 80 81 82 86 87 91 92 93 94 97 98 99 100 102 104 111 113 115 117 118 119 122 123 126 132 134 135 136 137 139 140 143 146 148 149 151 152 155 156 159 161 162 164 166 169 170 171 173 174 177 178...

output:

250004123

result:

ok single line: '250004123'

Test #19:

score: 0
Accepted
time: 86ms
memory: 23552kb

input:

250000 131590
1 3 4 9 12 14 15 17 20 25 26 28 29 33 34 38 39 45 46 47 50 51 53 54 56 59 60 67 69 72 74 76 79 85 86 87 88 91 92 97 100 101 102 103 106 110 114 116 117 122 123 126 129 133 135 136 137 139 146 147 151 152 153 154 156 163 166 167 170 171 172 173 174 176 177 182 185 187 190 191 192 195 20...

output:

120108800

result:

ok single line: '120108800'

Test #20:

score: 0
Accepted
time: 73ms
memory: 16792kb

input:

250000 47772
2 13 16 60 109 166 172 208 235 254 335 383 392 393 401 405 413 548 559 572 573 588 656 674 710 726 814 828 880 921 940 1029 1034 1048 1075 1093 1109 1170 1228 1246 1285 1302 1342 1356 1406 1419 1494 1508 1559 1576 1583 1606 1618 1690 1700 1710 1724 1757 1766 1772 1805 1807 1872 1877 189...

output:

82858423

result:

ok single line: '82858423'