提交记录 5471
用户 | 题目 | 状态 | 得分 | 用时 | 内存 | 语言 | 代码长度 |
---|---|---|---|---|---|---|---|
lyhlyhlyh | noi18b. 【NOI2018】冒泡排序 | Accepted | 100 | 50.251 ms | 9976 KB | C++ | 1021 B |
提交时间 | 评测时间 |
---|---|
2018-08-24 09:29:23 | 2020-08-01 00:18:37 |
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
#define _(d) while(d((ch=getchar()-48)>=0))
inline int get(){
char ch;_(!);int x=ch;
_() x=(x<<3)+(x<<1)+ch;
return x;
}
typedef long long ll;
const int N=1200005,mod=998244353;
int fc[N],ic[N],n;bool vs[N>>1];
inline int inv(int x){
int ret=1;
for(int b=mod-2;b;b>>=1,x=ll(x)*x%mod)
if(b&1) ret=ll(ret)*x%mod;
return ret;
}
inline int c(int n,int m){
if(n<m) return 0;
return ll(fc[n])*ic[n-m]%mod*ic[m]%mod;
}
inline int f(int i,int q){
int a=(n<<1)-i-q,b=n-i+1;
b=c(a,b)-c(a,b+1);
return b<0?b+mod:b;
}
int main(){
fc[0]=ic[0]=1;
for(int i=1;i<N;++i) fc[i]=fc[i-1]*ll(i)%mod;
ic[N-1]=inv(fc[N-1]);
for(int i=N-1;i>1;--i) ic[i-1]=ic[i]*ll(i)%mod;
for(int T=get();T--;){
memset(vs+1,0,n=get());
int ans=0,mx=0,ps=1,i,x,t;
for(i=1;i<=n;++i,mx=t){
vs[x=get()]=1;
if((ans+=f(i,t=max(x,mx)))>=mod) ans-=mod;
if(x<mx&&ps<x) break;
for(;vs[ps];++ps);
}while(i<n) ++i,get();
printf("%d\n",ans);
}
return 0;
}
Compilation | N/A | N/A | Compile OK | Score: N/A | 显示更多 |
Testcase #1 | 9.741 ms | 9 MB + 180 KB | Accepted | Score: 4 | 显示更多 |
Testcase #2 | 9.742 ms | 9 MB + 180 KB | Accepted | Score: 4 | 显示更多 |
Testcase #3 | 9.744 ms | 9 MB + 180 KB | Accepted | Score: 4 | 显示更多 |
Testcase #4 | 9.741 ms | 9 MB + 180 KB | Accepted | Score: 4 | 显示更多 |
Testcase #5 | 9.74 ms | 9 MB + 180 KB | Accepted | Score: 4 | 显示更多 |
Testcase #6 | 9.741 ms | 9 MB + 180 KB | Accepted | Score: 4 | 显示更多 |
Testcase #7 | 9.74 ms | 9 MB + 180 KB | Accepted | Score: 4 | 显示更多 |
Testcase #8 | 9.74 ms | 9 MB + 180 KB | Accepted | Score: 4 | 显示更多 |
Testcase #9 | 9.741 ms | 9 MB + 180 KB | Accepted | Score: 4 | 显示更多 |
Testcase #10 | 9.74 ms | 9 MB + 180 KB | Accepted | Score: 4 | 显示更多 |
Testcase #11 | 9.74 ms | 9 MB + 180 KB | Accepted | Score: 4 | 显示更多 |
Testcase #12 | 9.746 ms | 9 MB + 180 KB | Accepted | Score: 4 | 显示更多 |
Testcase #13 | 9.748 ms | 9 MB + 180 KB | Accepted | Score: 4 | 显示更多 |
Testcase #14 | 9.748 ms | 9 MB + 180 KB | Accepted | Score: 4 | 显示更多 |
Testcase #15 | 9.749 ms | 9 MB + 180 KB | Accepted | Score: 4 | 显示更多 |
Testcase #16 | 9.75 ms | 9 MB + 180 KB | Accepted | Score: 4 | 显示更多 |
Testcase #17 | 9.788 ms | 9 MB + 180 KB | Accepted | Score: 4 | 显示更多 |
Testcase #18 | 9.792 ms | 9 MB + 180 KB | Accepted | Score: 4 | 显示更多 |
Testcase #19 | 9.792 ms | 9 MB + 180 KB | Accepted | Score: 4 | 显示更多 |
Testcase #20 | 9.795 ms | 9 MB + 180 KB | Accepted | Score: 4 | 显示更多 |
Testcase #21 | 33.636 ms | 9 MB + 440 KB | Accepted | Score: 4 | 显示更多 |
Testcase #22 | 39.821 ms | 9 MB + 504 KB | Accepted | Score: 4 | 显示更多 |
Testcase #23 | 47.666 ms | 9 MB + 612 KB | Accepted | Score: 4 | 显示更多 |
Testcase #24 | 50.251 ms | 9 MB + 720 KB | Accepted | Score: 4 | 显示更多 |
Testcase #25 | 49.184 ms | 9 MB + 760 KB | Accepted | Score: 4 | 显示更多 |
Judge Duck Online | 评测鸭在线
Server Time: 2024-12-05 09:38:00 | Loaded in 1 ms | Server Status
个人娱乐项目,仅供学习交流使用 | 捐赠