提交记录 6581
用户 | 题目 | 状态 | 得分 | 用时 | 内存 | 语言 | 代码长度 |
---|---|---|---|---|---|---|---|
lunch | noi18b. 【NOI2018】冒泡排序 | Accepted | 100 | 88.111 ms | 11808 KB | C++ | 1.25 KB |
提交时间 | 评测时间 |
---|---|
2018-10-28 19:20:05 | 2020-08-01 00:46:14 |
#include<cstdio>
#include<bitset>
using namespace std;
const int N = 6e5 + 10;
const int mod = 998244353;
bitset<N> vis;
int fac[N << 1], ifac[N << 1], q[N];
int qpow(int a, int x) {
int ret = 1;
while(x) {
if(x & 1) ret = 1ll * ret * a % mod;
x >>= 1, a = 1ll * a * a % mod;
}
return ret;
}
void Math_Init(int n) {
fac[0] = 1;
for(int i = 1; i <= n; ++ i)
fac[i] = 1ll * fac[i - 1] * i % mod;
ifac[n] = qpow(fac[n], mod - 2);
for(int i = n; i >= 1; -- i)
ifac[i - 1] = 1ll * ifac[i] * i % mod;
}
int C(int n, int m) {
return n < m ? 0 : 1ll * fac[n] * ifac[n - m] % mod * ifac[m] % mod;
}
int cal(int x, int y) {
return x > y ? 0 : (C(x + y, y) + mod - C(x + y, y + 1)) % mod;
}
int main() {
#ifdef ylsakioi
freopen("4769.in", "r", stdin);
freopen("4769.out", "w", stdout);
#endif
Math_Init((N - 5) << 1);
int t, n, ans = 0;
for(scanf("%d", &t); t -- ; ans = 0, vis.reset()) {
scanf("%d", &n);
for(int i = 1; i <= n; ++ i)
scanf("%d", &q[i]);
int mn = 1, mx = 0, left = 0;
for(int i = 1; i <= n; ++ i, -- left) {
if(q[i] > mx) left += q[i] - mx, mx = q[i];
(ans += cal(n - i - left, n - i + 1)) %= mod;
if(mn < q[i] && q[i] < mx) break;
for(vis[q[i]] = 1; vis[mn]; ++ mn) ;
}
printf("%d\n", ans);
}
return 0;
}
Compilation | N/A | N/A | Compile OK | Score: N/A | 显示更多 |
Testcase #1 | 9.761 ms | 9 MB + 252 KB | Accepted | Score: 4 | 显示更多 |
Testcase #2 | 9.766 ms | 9 MB + 252 KB | Accepted | Score: 4 | 显示更多 |
Testcase #3 | 9.768 ms | 9 MB + 252 KB | Accepted | Score: 4 | 显示更多 |
Testcase #4 | 9.761 ms | 9 MB + 252 KB | Accepted | Score: 4 | 显示更多 |
Testcase #5 | 9.762 ms | 9 MB + 252 KB | Accepted | Score: 4 | 显示更多 |
Testcase #6 | 9.762 ms | 9 MB + 252 KB | Accepted | Score: 4 | 显示更多 |
Testcase #7 | 9.763 ms | 9 MB + 252 KB | Accepted | Score: 4 | 显示更多 |
Testcase #8 | 9.764 ms | 9 MB + 252 KB | Accepted | Score: 4 | 显示更多 |
Testcase #9 | 9.762 ms | 9 MB + 252 KB | Accepted | Score: 4 | 显示更多 |
Testcase #10 | 9.762 ms | 9 MB + 252 KB | Accepted | Score: 4 | 显示更多 |
Testcase #11 | 9.763 ms | 9 MB + 252 KB | Accepted | Score: 4 | 显示更多 |
Testcase #12 | 9.779 ms | 9 MB + 252 KB | Accepted | Score: 4 | 显示更多 |
Testcase #13 | 9.784 ms | 9 MB + 252 KB | Accepted | Score: 4 | 显示更多 |
Testcase #14 | 9.783 ms | 9 MB + 252 KB | Accepted | Score: 4 | 显示更多 |
Testcase #15 | 9.785 ms | 9 MB + 252 KB | Accepted | Score: 4 | 显示更多 |
Testcase #16 | 9.787 ms | 9 MB + 252 KB | Accepted | Score: 4 | 显示更多 |
Testcase #17 | 9.881 ms | 9 MB + 252 KB | Accepted | Score: 4 | 显示更多 |
Testcase #18 | 9.891 ms | 9 MB + 256 KB | Accepted | Score: 4 | 显示更多 |
Testcase #19 | 9.888 ms | 9 MB + 256 KB | Accepted | Score: 4 | 显示更多 |
Testcase #20 | 9.893 ms | 9 MB + 256 KB | Accepted | Score: 4 | 显示更多 |
Testcase #21 | 57.675 ms | 10 MB + 268 KB | Accepted | Score: 4 | 显示更多 |
Testcase #22 | 70.499 ms | 10 MB + 528 KB | Accepted | Score: 4 | 显示更多 |
Testcase #23 | 84.652 ms | 10 MB + 964 KB | Accepted | Score: 4 | 显示更多 |
Testcase #24 | 88.111 ms | 11 MB + 372 KB | Accepted | Score: 4 | 显示更多 |
Testcase #25 | 87.262 ms | 11 MB + 544 KB | Accepted | Score: 4 | 显示更多 |
Judge Duck Online | 评测鸭在线
Server Time: 2024-12-05 09:44:09 | Loaded in 1 ms | Server Status
个人娱乐项目,仅供学习交流使用 | 捐赠