Submission #43717411


Source Code Expand

#include <cstdio>
#include <cstring>
#include <vector>

#define N 400010
#define mod 998244353
#define ll long long
using namespace std;

ll fac[N], p[N];
inline ll qpow(ll a, ll b){
	ll base = a, ans = 1;
	while(b){
		if(b & 1){ ans *= base; ans %= mod; }
		base *= base; base %= mod;
		b >>= 1;
	}
	return ans;
}
void init(){
	fac[0] = fac[1] = 1;
    for(int i = 2 ; i <= N - 5 ; i++) fac[i] = fac[i - 1] * i % mod;
}
inline ll inv(ll x){ return qpow(x, mod - 2); }
inline ll C(ll x, ll y){
	return fac[x] * inv(fac[y]) % mod * inv(fac[x - y]) % mod;
}

int n, k, a[N];
int c[N];
vector <int> v;
ll ans = 0;

void Solve(){
	memset(c, 0, sizeof(c)); v.clear(); ans = 1;
	scanf("%d%d", &n, &k);
	for(int i = 1 ; i <= n ; i++){
		scanf("%d", &a[i]); c[a[i]]++;
	}
	for(int i = 0 ; i <= N - 10 ; i++)
		if(!c[i]) v.push_back(i);
	for(int i = 1 ; i <= k ; i++)
		ans += C(v[i - 1] + k - i, k - i + 1), ans %= mod;
	printf("%lld\n", ans);
}

int main(){
	init();
	int T = 1; //; scanf("%d", &T);
	while(T--)
		Solve();
	return 0;
}

Submission Info

Submission Time
Task B - Mex on Blackboard
User CSP_Sept
Language C++ (GCC 9.2.1)
Score 500
Code Size 1082 Byte
Status AC
Exec Time 82 ms
Memory 10316 KiB

Compile Error

./Main.cpp: In function ‘void Solve()’:
./Main.cpp:36:7: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   36 |  scanf("%d%d", &n, &k);
      |  ~~~~~^~~~~~~~~~~~~~~~
./Main.cpp:38:8: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   38 |   scanf("%d", &a[i]); c[a[i]]++;
      |   ~~~~~^~~~~~~~~~~~~

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 500 / 500
Status
AC × 3
AC × 22
Set Name Test Cases
Sample 00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt
All 00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt, 01_small_01.txt, 01_small_02.txt, 01_small_03.txt, 01_small_04.txt, 01_small_05.txt, 02_large_01.txt, 02_large_02.txt, 02_large_03.txt, 02_large_04.txt, 02_large_05.txt, 02_large_06.txt, 02_large_07.txt, 03_sparse_01.txt, 03_sparse_02.txt, 03_sparse_03.txt, 03_sparse_04.txt, 03_sparse_05.txt, 03_sparse_06.txt, 03_sparse_07.txt
Case Name Status Exec Time Memory
00_sample_01.txt AC 12 ms 9544 KiB
00_sample_02.txt AC 15 ms 9324 KiB
00_sample_03.txt AC 12 ms 9508 KiB
01_small_01.txt AC 12 ms 9460 KiB
01_small_02.txt AC 15 ms 9420 KiB
01_small_03.txt AC 13 ms 9488 KiB
01_small_04.txt AC 14 ms 9420 KiB
01_small_05.txt AC 12 ms 9532 KiB
02_large_01.txt AC 78 ms 9184 KiB
02_large_02.txt AC 73 ms 10316 KiB
02_large_03.txt AC 65 ms 10128 KiB
02_large_04.txt AC 53 ms 10072 KiB
02_large_05.txt AC 52 ms 10000 KiB
02_large_06.txt AC 74 ms 10032 KiB
02_large_07.txt AC 56 ms 10076 KiB
03_sparse_01.txt AC 33 ms 9852 KiB
03_sparse_02.txt AC 81 ms 10196 KiB
03_sparse_03.txt AC 81 ms 10152 KiB
03_sparse_04.txt AC 79 ms 10288 KiB
03_sparse_05.txt AC 80 ms 10104 KiB
03_sparse_06.txt AC 82 ms 10152 KiB
03_sparse_07.txt AC 82 ms 10100 KiB