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
编号 | 题目 | 状态 | 分数 | 总时间 | 内存 | 代码 / 答案文件 | 提交者 | 提交时间 |
---|---|---|---|---|---|---|---|---|
#49222 | #1258. 地底蔷薇 | Accepted | 100 | 18544 ms | 116980 K | C++ 17 / 1.5 K | wahahah | 2021-05-28 21:31:44 |
#include <bits/stdc++.h>
#define PI 3.141592653589793238462
#define eps 1e-20
#define fi first
#define se second
using namespace std;
using cd = complex<double>;
typedef long long ll;
typedef long double db;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<db, db> pdd;
ll tree[3][2005][2005], a[2005], mod = 1e9 + 7, n, c[2005], d[2005][2005];
void add(ll t, ll s, ll x, ll v) {
while (x <= n + 2) {
tree[t][s][x] += v;
tree[t][s][x] %= mod;
x += x & (-x);
}
}
ll query(ll t, ll s, ll x) {
ll res = 0;
while (x) {
res += tree[t][s][x];
x -= x & (-x);
res %= mod;
}
return res % mod;
}
ll qpow(ll x, ll y) {
ll res = 1;
while (y) {
if (y & 1)
res = res * x % mod;
y /= 2;
x = x * x % mod;
}
return res % mod;
}
int main() {
cin >> n;
for (ll i = 2; i <= n + 1; i++) {
cin >> a[i];
a[i]++;
}
for (ll i = 1; i <= n + 2; i++) {
c[i] = qpow(i, mod - 2);
}
a[1] = 1;
a[n + 2] = n + 2;
for (ll i = 1; i <= n + 2; i++) {
for (ll j = i - 1; j > 0; j--) {
if (a[i] > a[j]) {
ll num = query(0, i, a[i] - 1) - query(0, i, a[j]);
ll v1 = query(1, i, a[i] - 1) - query(1, i, a[j]);
ll v2 = query(2, j, a[i] - 1) - query(2, j, a[j]);
v1 = (v1 % mod + mod) % mod;
v2 = (v2 % mod + mod) % mod;
if (num) {
d[j][i] = 1 + (v1 + v2) % mod * c[num] % mod;
d[j][i] %= mod;
}
}
add(0, i, a[j], 1);
add(1, i, a[j], d[j][i]);
add(2, j, a[i], d[j][i]);
}
}
cout << d[1][n + 2] << endl;
}
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