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
<8798 bytes omitted>
用户输出
2000
系统信息
Exited with return code 0
编号 | 题目 | 状态 | 分数 | 总时间 | 内存 | 代码 / 答案文件 | 提交者 | 提交时间 |
---|---|---|---|---|---|---|---|---|
#47981 | #1258. 地底蔷薇 | Accepted | 100 | 4935 ms | 73116 K | C++ 17 / 1.3 K | Komeiji Koishi | 2021-05-10 12:40:59 |
#include <cstdio>
#include <algorithm>
using namespace std;
int n, dp[2005][2005], a[2005], inv[2005], cnt[2005], sum[2005], suf[2005];
int tr[4][2005][2005], ty; // hou qian
const int mod = 1e9 + 7;
int lowbit(int p) { return p & -p; }
int mypow(int a, int b) {
int ans = 1;
while (b) {
if (b & 1)
ans = 1ll * ans * a % mod;
a = 1ll * a * a % mod;
b >>= 1;
}
return ans;
}
int M(int x) { return x >= mod ? x - mod : x; }
int ask(int pos, int p) {
int ans = 0;
while (p) {
ans = M(ans + tr[ty][pos][p]);
p -= lowbit(p);
}
return ans;
}
void modify(int pos, int p, int v) {
while (p <= n + 2) {
tr[ty][pos][p] = M(tr[ty][pos][p] + v);
p += lowbit(p);
}
}
int main() {
scanf("%d", &n);
inv[1] = 1;
for (int i = 2; i <= n + 2; i++) inv[i] = mypow(i, mod - 2);
a[0] = 1;
for (int i = 1; i <= n; i++) scanf("%d", &a[i]), a[i]++;
a[n + 1] = n + 2;
for (int l = 2; l <= n + 2; l++) {
for (int i = 0; i <= n + 2 - l; i++) {
int j = i + l - 1;
if (a[i] > a[j])
continue;
ty = 0;
int sum = ask(j, n + 2) - ask(j, a[i]);
if (sum > 0) {
ty = 1;
int res1 = M(ask(j, n + 2) - ask(j, a[i]) + mod);
ty = 3;
int res2 = ask(i, a[j]);
dp[i][j] = M(1ll * M(res1 + res2) * inv[sum] % mod + 1);
}
ty = 0;
modify(j, a[i], 1);
ty = 1;
modify(j, a[i], dp[i][j]);
ty = 2;
modify(i, a[j], 1);
ty = 3;
modify(i, a[j], dp[i][j]);
}
}
printf("%d\n", dp[0][n + 1]);
return 0;
}
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
<8798 bytes omitted>
用户输出
2000
系统信息
Exited with return code 0
用户输出
666666673
系统信息
Exited with return code 0
2000
2000 1999 1998 1997 1996 1995 1994 1993 1992 1991 1990 1989 1988 1987 1986 1985 1984 1983 1982
<8798 bytes omitted>
用户输出
1
系统信息
Exited with return code 0
30
26 16 28 30 23 11 29 18 22 15 20 13 27 9 21 7 5 25 4 19 8 3 1 24 10 14 17 12 2 6
用户输出
297703424
系统信息
Exited with return code 0
2000
2 1 4 3 6 5 8 7 10 9 12 11 14 13 16 15 18 17 20 19 22 21 24 23 26 25 28 27 30 29 32 31 34 33 36
<8798 bytes omitted>
用户输出
964900949
系统信息
Exited with return code 0
2000
1246 320 473 1336 755 1463 1509 1713 1778 1406 1438 1012 664 1507 44 1516 306 1419 1363 550 286
<8798 bytes omitted>
用户输出
989609100
系统信息
Exited with return code 0
2000
1304 1681 1730 1944 245 1774 15 1634 254 1653 659 837 1879 1506 512 1571 123 1738 1651 1514 181
<8798 bytes omitted>
用户输出
903963298
系统信息
Exited with return code 0
2000
497 837 1125 828 182 1161 1428 1893 1258 429 1311 1374 686 1223 1685 1365 1080 808 1658 155 113
<8798 bytes omitted>
用户输出
555364839
系统信息
Exited with return code 0
2000
1692 854 278 300 282 811 1510 622 1780 861 181 1972 551 1900 1263 480 1559 1373 98 1301 1671 43
<8798 bytes omitted>
用户输出
960859403
系统信息
Exited with return code 0
2000
70 59 1152 1991 1137 1043 1432 1706 839 1998 1719 1208 1111 1849 1906 649 80 187 443 26 955 605
<8798 bytes omitted>
用户输出
941150290
系统信息
Exited with return code 0
2000
1154 754 921 695 1784 1523 1106 881 1873 297 129 1845 496 1104 1509 1996 101 599 1092 767 1290
<8798 bytes omitted>
用户输出
515073153
系统信息
Exited with return code 0
1785
148 748 1449 1676 1331 109 639 1337 932 572 1359 204 1038 286 987 1367 203 339 185 1292 1383 25
<7723 bytes omitted>
用户输出
676079957
系统信息
Exited with return code 0
1961
826 613 452 1355 1174 862 448 1549 1124 196 180 1078 1255 1468 1810 912 1189 1852 1194 831 1369
<8603 bytes omitted>
用户输出
715868914
系统信息
Exited with return code 0
1833
1032 1306 1801 371 1506 127 1142 1615 1027 62 602 358 1262 1043 1609 1702 1468 1681 603 1430 94
<7963 bytes omitted>
用户输出
231149025
系统信息
Exited with return code 0
809
533 329 768 540 551 193 650 389 361 330 351 118 787 663 624 539 61 372 549 378 333 600 715 713 7
<3032 bytes omitted>
用户输出
474487141
系统信息
Exited with return code 0
681
387 191 249 603 24 13 416 473 388 522 497 89 46 628 93 5 149 386 625 312 41 630 43 36 104 126 73
<2520 bytes omitted>
用户输出
18920488
系统信息
Exited with return code 0
762
268 594 332 676 361 505 34 98 336 670 496 669 634 190 657 529 225 303 36 180 630 123 433 740 760
<2844 bytes omitted>
用户输出
55647230
系统信息
Exited with return code 0
1338
136 101 470 258 1043 607 783 814 301 137 87 1232 220 46 996 1100 1337 431 48 782 638 618 1161 4
<5488 bytes omitted>
用户输出
334227892
系统信息
Exited with return code 0
1610
222 1106 504 856 1427 714 263 100 1007 454 130 718 357 1204 77 505 805 257 1382 1008 1533 1202
<6848 bytes omitted>
用户输出
130746815
系统信息
Exited with return code 0
890
137 588 631 558 614 464 36 724 456 62 596 381 294 173 790 446 607 196 888 625 855 876 436 800 11
<3356 bytes omitted>
用户输出
551733880
系统信息
Exited with return code 0
362
50 181 208 99 117 288 124 229 262 192 268 52 249 296 263 180 130 108 8 12 145 325 49 361 139 177
<1244 bytes omitted>
用户输出
401464746
系统信息
Exited with return code 0
用户输出
454166673
系统信息
Exited with return code 0
用户输出
619523818
系统信息
Exited with return code 0
用户输出
666666673
系统信息
Exited with return code 0
用户输出
666666673
系统信息
Exited with return code 0
用户输出
200000005
系统信息
Exited with return code 0
用户输出
228571434
系统信息
Exited with return code 0
用户输出
532063499
系统信息
Exited with return code 0
用户输出
800000010
系统信息
Exited with return code 0
用户输出
357142863
系统信息
Exited with return code 0
用户输出
500000005
系统信息
Exited with return code 0
用户输出
5
系统信息
Exited with return code 0