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
编号 | 题目 | 状态 | 分数 | 总时间 | 内存 | 代码 / 答案文件 | 提交者 | 提交时间 |
---|---|---|---|---|---|---|---|---|
#49295 | #1258. 地底蔷薇 | Accepted | 100 | 5529 ms | 96264 K | C++ 17 / 2.5 K | 丁丁跑卡车 | 2021-06-17 18:18:16 |
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define ud unsigned int
#define ll long long
#define ull unsigned long long
#define MAX_INF 0x3f
#define MAX_INF_VAL 0x3f3f3f3f
#define MAX_INF_VAL_LL 0x3f3f3f3f3f3f3f3f
//#define pi 3.141592653589
#define eps 1e-9
#define F(x) ((x) / 3 + ((x) % 3 == 1 ? 0 : tb))
#define G(x) ((x) < tb ? (x)*3 + 1 : ((x)-tb) * 3 + 2)
//#define p 2173412051LL
//#define sz 2
using namespace std;
template <typename T>
void read(T &x) {
x = 0;
char ch = getchar();
ll f = 1;
while (!isdigit(ch)) {
if (ch == '-')
f *= -1;
ch = getchar();
}
while (isdigit(ch)) {
x = x * 10 + ch - 48;
ch = getchar();
}
x *= f;
}
struct custom_hash {
static uint64_t splitmix64(uint64_t x) {
x += 0x9e3779b97f4a7c15;
x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
return x ^ (x >> 31);
}
size_t operator()(uint64_t x) const {
static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
return splitmix64(x + FIXED_RANDOM);
}
};
const ll p = 1e9 + 7;
int n;
int a[2010];
ll inv[2010];
ll sumL[2010][2010], sumR[2010][2010], totL[2010][2010];
ll f[2010][2010];
void pre(int);
int low_bit(int);
void update(ll *, int, ll);
ll query(ll *, int);
int main() {
ios::sync_with_stdio(false);
cin.tie(0), cout.tie(0);
cin >> n;
for (int i = 2; i <= n + 1; ++i) {
cin >> a[i];
++a[i];
}
a[1] = 1;
a[n + 2] = n + 2;
n += 2;
pre(n);
for (int len = 2; len <= n + 1; ++len) {
for (int i = 1, j = len; j <= n; ++i, ++j) {
if (a[i] >= a[j])
continue;
f[i][j] = (query(sumL[i], a[j] - 1) + query(sumR[j], n) - query(sumR[j], a[i]) +
query(totL[i], a[j] - 1) + p) *
inv[query(totL[i], a[j] - 1)] % p;
update(sumL[i], a[j], f[i][j]);
update(sumR[j], a[i], f[i][j]);
update(totL[i], a[j], 1);
}
}
cout << f[1][n];
return 0;
}
void pre(int n) {
inv[1] = 1;
for (int i = 2; i <= n; ++i) inv[i] = (p - p / i) * inv[p % i] % p;
}
int low_bit(int x) { return x & -x; }
void update(ll *f, int i, ll x) {
while (i <= n) {
f[i] = (f[i] + x) % p;
i += low_bit(i);
}
}
ll query(ll *f, int i) {
ll res = 0;
while (i) {
res += f[i];
i -= low_bit(i);
}
return res % p;
}
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