提交记录 4324
用户 | 题目 | 状态 | 得分 | 用时 | 内存 | 语言 | 代码长度 |
---|---|---|---|---|---|---|---|
Dof | noi18b. 【NOI2018】冒泡排序 | Accepted | 100 | 56.434 ms | 14076 KB | C++ | 1.52 KB |
提交时间 | 评测时间 |
---|---|
2018-07-19 20:53:56 | 2020-07-31 22:52:27 |
#include <cstdio>
#include <cstring>
#include <algorithm>
typedef long long LL;
const int N = 1200005, MOD = 998244353;
int tc, n;
int fac[N], ifac[N], p[N >> 1], vis[N >> 1];
inline void Read(int &x) {
x = 0; static char c;
for (c = getchar(); c < '0' || c > '9'; c = getchar());
for (; c >= '0' && c <= '9'; x = (x << 3) + (x << 1) + c - '0', c = getchar());
}
inline int Pow(int x, int b) {
static int re;
for (re = 1; b; b >>= 1, x = (LL) x * x % MOD)
if (b & 1) re = (LL) re * x % MOD;
return re;
}
inline int C(int x, int y) {
if (x < y) return 0;
return (LL) fac[x] * ifac[y] % MOD * ifac[x - y] % MOD;
}
inline int Cal(int x, int y) {
if (x < y) return 0;
int dis = 2 * x - y, re1 = C(dis, x);
if (y + 2 > dis) return re1;
return (re1 - C(dis, (dis + y) / 2 + 1)) % MOD;
}
int main() {
fac[0] = 1;
for (int i = 1; i < N; ++i) {
fac[i] = (LL) fac[i - 1] * i % MOD;
}
ifac[N - 1] = Pow(fac[N - 1], MOD - 2);
for (int i = N - 1; i >= 1; --i) {
ifac[i - 1] = (LL) ifac[i] * i % MOD;
}
scanf("%d", &tc);
for (; tc; --tc) {
int re = 0, mx = 0, low = 1, he = 0;
memset(vis, 0, sizeof vis);
scanf("%d", &n);
for (int i = 1; i <= n; ++i) {
Read(p[i]);
}
for (int i = 1; i < n; ++i, --he) {
if (mx < p[i]) he += p[i] - mx;
mx = std::max(mx, p[i]);
for (vis[p[i]] = 1; vis[low]; ++low);
re = (re + Cal(n - i + 1, he + 1)) % MOD;
if (mx > p[i] && p[i] > low) {
break;
}
}
printf("%d\n", (re + MOD) % MOD);
}
return 0;
}
Compilation | N/A | N/A | Compile OK | Score: N/A | 显示更多 |
Testcase #1 | 10.147 ms | 11 MB + 472 KB | Accepted | Score: 4 | 显示更多 |
Testcase #2 | 10.146 ms | 11 MB + 472 KB | Accepted | Score: 4 | 显示更多 |
Testcase #3 | 10.15 ms | 11 MB + 472 KB | Accepted | Score: 4 | 显示更多 |
Testcase #4 | 10.148 ms | 11 MB + 472 KB | Accepted | Score: 4 | 显示更多 |
Testcase #5 | 10.147 ms | 11 MB + 472 KB | Accepted | Score: 4 | 显示更多 |
Testcase #6 | 10.148 ms | 11 MB + 472 KB | Accepted | Score: 4 | 显示更多 |
Testcase #7 | 10.145 ms | 11 MB + 472 KB | Accepted | Score: 4 | 显示更多 |
Testcase #8 | 10.147 ms | 11 MB + 472 KB | Accepted | Score: 4 | 显示更多 |
Testcase #9 | 10.148 ms | 11 MB + 472 KB | Accepted | Score: 4 | 显示更多 |
Testcase #10 | 10.148 ms | 11 MB + 472 KB | Accepted | Score: 4 | 显示更多 |
Testcase #11 | 10.148 ms | 11 MB + 472 KB | Accepted | Score: 4 | 显示更多 |
Testcase #12 | 10.155 ms | 11 MB + 472 KB | Accepted | Score: 4 | 显示更多 |
Testcase #13 | 10.158 ms | 11 MB + 472 KB | Accepted | Score: 4 | 显示更多 |
Testcase #14 | 10.157 ms | 11 MB + 472 KB | Accepted | Score: 4 | 显示更多 |
Testcase #15 | 10.158 ms | 11 MB + 472 KB | Accepted | Score: 4 | 显示更多 |
Testcase #16 | 10.159 ms | 11 MB + 472 KB | Accepted | Score: 4 | 显示更多 |
Testcase #17 | 10.204 ms | 11 MB + 472 KB | Accepted | Score: 4 | 显示更多 |
Testcase #18 | 10.206 ms | 11 MB + 476 KB | Accepted | Score: 4 | 显示更多 |
Testcase #19 | 10.208 ms | 11 MB + 476 KB | Accepted | Score: 4 | 显示更多 |
Testcase #20 | 10.21 ms | 11 MB + 476 KB | Accepted | Score: 4 | 显示更多 |
Testcase #21 | 37.04 ms | 12 MB + 488 KB | Accepted | Score: 4 | 显示更多 |
Testcase #22 | 44.429 ms | 12 MB + 748 KB | Accepted | Score: 4 | 显示更多 |
Testcase #23 | 53.796 ms | 13 MB + 160 KB | Accepted | Score: 4 | 显示更多 |
Testcase #24 | 56.434 ms | 13 MB + 592 KB | Accepted | Score: 4 | 显示更多 |
Testcase #25 | 55.762 ms | 13 MB + 764 KB | Accepted | Score: 4 | 显示更多 |
Judge Duck Online | 评测鸭在线
Server Time: 2024-12-05 09:37:47 | Loaded in 1 ms | Server Status
个人娱乐项目,仅供学习交流使用 | 捐赠