QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#370578#6346. Record ParitylexiyvvWA 84ms159812kbC++142.2kb2024-03-29 11:47:272024-03-29 11:47:29

Judging History

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

  • [2024-03-29 11:47:29]
  • 评测
  • 测评结果:WA
  • 用时:84ms
  • 内存:159812kb
  • [2024-03-29 11:47:27]
  • 提交

answer

// Author: xiaruize
#ifndef ONLINE_JUDGE
bool start_of_memory_use;
#endif
#include <bits/stdc++.h>
using namespace std;
#ifndef ONLINE_JUDGE
clock_t start_clock = clock();
#endif
#define int long long
#define ull unsigned long long
#define ALL(a) (a).begin(), (a).end()
#define pb push_back
#define mk make_pair
#define pii pair<int, int>
#define pis pair<int, string>
#define sec second
#define fir first
#define sz(a) int((a).size())
#define Yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define No cout << "No" << endl
#define NO cout << "NO" << endl
#define mms(arr, n) memset(arr, n, sizeof(arr))
#define rep(i, a, n) for (int i = (a); i <= (n); ++i)
#define per(i, n, a) for (int i = (n); i >= (a); --i)
int max(int a, int b)
{
	if (a > b)
		return a;
	return b;
}
int min(int a, int b)
{
	if (a < b)
		return a;
	return b;
}
const int INF = 0x3f3f3f3f3f3f3f3f;
const int MOD = 998244353;
const int N = 1e7 + 10;

int fac[10000009], inv[10000009];
int qpow(int a, int b)
{
	int ans = 1;
	while (b)
	{
		if (b & 1)
			ans = (ans * a) % MOD;
		a = (a * a) % MOD;
		b /= 2;
	}
	return ans;
}
void init()
{
	fac[0] = 1;
	for (int i = 1; i <= 10000000; i++)
		fac[i] = (fac[i - 1] * i) % MOD;
	inv[10000000] = qpow(fac[10000000], MOD - 2);
	for (int i = 10000000 - 1; i >= 0; i--)
		inv[i] = (inv[i + 1] * (i + 1)) % MOD;
}
int C(int x, int y)
{
	if (x < 0 || y < 0 || x < y)
		return 0;
	if (x == y || y == 0)
		return 1;
	else
		return fac[x] * inv[x - y] % MOD * inv[y] % MOD;
}

int n, k;
int a[N];
int mi = INF, cnt;

void solve()
{
	init();
	cin >> n >> k;
	rep(i, 1, n) cin >> a[i];
	per(i, n, 1)
	{
		if (mi >= a[i])
			cnt++;
		mi = min(mi, a[i]);
	}
	if (k & 1)
		cout << MOD - C(cnt, k) << endl;
	else
		cout << C(cnt, k) << endl;
}

#ifndef ONLINE_JUDGE
bool end_of_memory_use;
#endif

signed main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int testcase = 1;
	// cin >> testcase;
	while (testcase--)
		solve();
#ifndef ONLINE_JUDGE
	cerr << "Memory use:" << (&end_of_memory_use - &start_of_memory_use) / 1024.0 / 1024.0 << "MiB" << endl;
	cerr << "Time use:" << (double)clock() / CLOCKS_PER_SEC * 1000.0 << "ms" << endl;
#endif
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 74ms
memory: 159748kb

input:

5 2
4 1 2 5 3

output:

3

result:

ok 1 number(s): "3"

Test #2:

score: 0
Accepted
time: 70ms
memory: 159800kb

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: 84ms
memory: 159812kb

input:

5 5
2 5 4 1 3

output:

998244353

result:

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