提交记录 5470


用户 题目 状态 得分 用时 内存 语言 代码长度
lyhlyhlyh noi18b. 【NOI2018】冒泡排序 Accepted 100 69.61 ms 9976 KB C++ 1.08 KB
提交时间 评测时间
2018-08-23 18:36:04 2020-08-01 00:18:33
#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;
}
const int N=1200005,mod=998244353;
int fc[N]={1},ic[N]={1},n;bool vs[N>>1];
inline int u(int a,int b){
	int ret;__asm__ __volatile__(
		"\tmull %%ebx\n\tdivl %%ecx\n":
		"=d"(ret):"a"(a),"b"(b),"c"(mod));
	return ret;
}
inline int inv(int x){
	int ret=1;
	for(int b=mod-2;b;b>>=1,x=u(x,x))
		if(b&1) ret=u(ret,x);
	return ret;
}
inline int c(int n,int m){
	if(n<m) return 0;
	return u(fc[n],u(ic[n-m],ic[m]));
}
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(){
	for(int i=1;i<N;++i) fc[i]=u(fc[i-1],i);
	ic[N-1]=inv(fc[N-1]);
	for(int i=N-1;i>1;--i) ic[i-1]=u(ic[i],i);
	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 #121.63 ms9 MB + 176 KBAcceptedScore: 4

Testcase #221.631 ms9 MB + 176 KBAcceptedScore: 4

Testcase #321.631 ms9 MB + 176 KBAcceptedScore: 4

Testcase #421.63 ms9 MB + 176 KBAcceptedScore: 4

Testcase #521.63 ms9 MB + 176 KBAcceptedScore: 4

Testcase #621.63 ms9 MB + 176 KBAcceptedScore: 4

Testcase #721.629 ms9 MB + 176 KBAcceptedScore: 4

Testcase #821.629 ms9 MB + 176 KBAcceptedScore: 4

Testcase #921.629 ms9 MB + 176 KBAcceptedScore: 4

Testcase #1021.631 ms9 MB + 176 KBAcceptedScore: 4

Testcase #1121.63 ms9 MB + 176 KBAcceptedScore: 4

Testcase #1221.637 ms9 MB + 176 KBAcceptedScore: 4

Testcase #1321.638 ms9 MB + 176 KBAcceptedScore: 4

Testcase #1421.639 ms9 MB + 176 KBAcceptedScore: 4

Testcase #1521.639 ms9 MB + 176 KBAcceptedScore: 4

Testcase #1621.644 ms9 MB + 176 KBAcceptedScore: 4

Testcase #1721.685 ms9 MB + 180 KBAcceptedScore: 4

Testcase #1821.691 ms9 MB + 180 KBAcceptedScore: 4

Testcase #1921.688 ms9 MB + 180 KBAcceptedScore: 4

Testcase #2021.695 ms9 MB + 180 KBAcceptedScore: 4

Testcase #2148.289 ms9 MB + 440 KBAcceptedScore: 4

Testcase #2256.032 ms9 MB + 504 KBAcceptedScore: 4

Testcase #2366.219 ms9 MB + 612 KBAcceptedScore: 4

Testcase #2469.61 ms9 MB + 720 KBAcceptedScore: 4

Testcase #2568.523 ms9 MB + 760 KBAcceptedScore: 4


Judge Duck Online | 评测鸭在线
Server Time: 2026-04-11 21:01:52 | Loaded in 1 ms | Server Status
个人娱乐项目,仅供学习交流使用 | 捐赠