QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#202670 | #6346. Record Parity | qzzyq | WA | 1ms | 7904kb | C++14 | 1.5kb | 2023-10-06 12:57:52 | 2023-10-06 12:57:53 |
Judging History
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);
else printf("%lld",ans);
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 7788kb
input:
5 2 4 1 2 5 3
output:
3
result:
ok 1 number(s): "3"
Test #2:
score: 0
Accepted
time: 1ms
memory: 7904kb
input:
7 3 1 2 3 4 5 6 7
output:
998244318
result:
ok 1 number(s): "998244318"
Test #3:
score: -100
Wrong Answer
time: 1ms
memory: 7840kb
input:
5 5 2 5 4 1 3
output:
998244353
result:
wrong answer 1st numbers differ - expected: '0', found: '998244353'