QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#202671#6346. Record ParityqzzyqWA 1ms7980kbC++141.6kb2023-10-06 12:58:142023-10-06 12:58:15

Judging History

你现在查看的是最新测评结果

  • [2023-10-06 12:58:15]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:7980kb
  • [2023-10-06 12:58:14]
  • 提交

answer

#include<bits/stdc++.h>
#define int long long
#define ull unsigned long long
#define maxn 1000006
#define put() putchar('\n')
#define Tp template<typename Ty>
#define Ts template<typename Ty,typename... Ar>
using namespace std;
void read(int &x){
    int f=1;x=0;char c=getchar();
    while (c<'0'||c>'9') {if (c=='-') f=-1;c=getchar();}
    while (c>='0'&&c<='9') {x=x*10+c-'0';c=getchar();}
    x*=f;
}
namespace Debug{
	Tp void _debug(char* f,Ty t){cerr<<f<<'='<<t<<endl;}
	Ts void _debug(char* f,Ty x,Ar... y){while(*f!=',') cerr<<*f++;cerr<<'='<<x<<",";_debug(f+1,y...);}
	Tp ostream& operator<<(ostream& os,vector<Ty>& V){os<<"[";for(auto& vv:V) os<<vv<<",";os<<"]";return os;}
	#define gdb(...) _debug((char*)#__VA_ARGS__,__VA_ARGS__)
}using namespace Debug;
#define fi first
#define se second
#define mk make_pair
const int mod=998244353;
int power(int x,int y=mod-2) {
	int sum=1;
	while (y) {
		if (y&1) sum=sum*x%mod;
		x=x*x%mod;y>>=1;
	}
	return sum;
}
int suf[maxn],isuf[maxn],a[maxn],n,k;
int C(int x,int y) {return suf[x]*isuf[y]%mod*isuf[x-y]%mod;}
void add(int &x,int y) {x=(x+y)%mod;}
signed main(void){
//	freopen("1.in","r",stdin);
	int i;
	read(n);read(k);
	for (i=1;i<=n;i++) read(a[i]);
	for (suf[0]=1,i=1;i<=n;i++) suf[i]=suf[i-1]*i%mod;
	for (isuf[n]=power(suf[n]),i=n;i>=1;i--) isuf[i-1]=isuf[i]*i%mod;
	int ans=0,tot=1;
	for (i=2;i<=n+1;i++) {
		if (a[i]>a[i-1]) tot++;
		else {
			if (tot>=k) add(ans,C(tot,k));
			tot=1;
		} 
	}	
	if (k&1) printf("%lld",(mod-ans)%mod);
	else printf("%lld",ans);
	return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 1ms
memory: 7912kb

input:

5 2
4 1 2 5 3

output:

3

result:

ok 1 number(s): "3"

Test #2:

score: 0
Accepted
time: 1ms
memory: 7980kb

input:

7 3
1 2 3 4 5 6 7

output:

998244318

result:

ok 1 number(s): "998244318"

Test #3:

score: 0
Accepted
time: 1ms
memory: 7828kb

input:

5 5
2 5 4 1 3

output:

0

result:

ok 1 number(s): "0"

Test #4:

score: -100
Wrong Answer
time: 1ms
memory: 7904kb

input:

10 3
9 7 3 6 10 4 8 2 5 1

output:

998244352

result:

wrong answer 1st numbers differ - expected: '0', found: '998244352'