提交记录 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;
}

CompilationN/AN/ACompile OKScore: N/A

Testcase #19.741 ms9 MB + 180 KBAcceptedScore: 4

Testcase #29.742 ms9 MB + 180 KBAcceptedScore: 4

Testcase #39.744 ms9 MB + 180 KBAcceptedScore: 4

Testcase #49.741 ms9 MB + 180 KBAcceptedScore: 4

Testcase #59.74 ms9 MB + 180 KBAcceptedScore: 4

Testcase #69.741 ms9 MB + 180 KBAcceptedScore: 4

Testcase #79.74 ms9 MB + 180 KBAcceptedScore: 4

Testcase #89.74 ms9 MB + 180 KBAcceptedScore: 4

Testcase #99.741 ms9 MB + 180 KBAcceptedScore: 4

Testcase #109.74 ms9 MB + 180 KBAcceptedScore: 4

Testcase #119.74 ms9 MB + 180 KBAcceptedScore: 4

Testcase #129.746 ms9 MB + 180 KBAcceptedScore: 4

Testcase #139.748 ms9 MB + 180 KBAcceptedScore: 4

Testcase #149.748 ms9 MB + 180 KBAcceptedScore: 4

Testcase #159.749 ms9 MB + 180 KBAcceptedScore: 4

Testcase #169.75 ms9 MB + 180 KBAcceptedScore: 4

Testcase #179.788 ms9 MB + 180 KBAcceptedScore: 4

Testcase #189.792 ms9 MB + 180 KBAcceptedScore: 4

Testcase #199.792 ms9 MB + 180 KBAcceptedScore: 4

Testcase #209.795 ms9 MB + 180 KBAcceptedScore: 4

Testcase #2133.636 ms9 MB + 440 KBAcceptedScore: 4

Testcase #2239.821 ms9 MB + 504 KBAcceptedScore: 4

Testcase #2347.666 ms9 MB + 612 KBAcceptedScore: 4

Testcase #2450.251 ms9 MB + 720 KBAcceptedScore: 4

Testcase #2549.184 ms9 MB + 760 KBAcceptedScore: 4


Judge Duck Online | 评测鸭在线
Server Time: 2024-12-05 09:38:00 | Loaded in 1 ms | Server Status
个人娱乐项目,仅供学习交流使用 | 捐赠