Submission #46186376


Source Code Expand

#include<bits/stdc++.h>
#define LL long long
#define DB double
#define MOD 998244353
#define ls(x) (x << 1)
#define rs(x) (x << 1 | 1)
#define lowbit(x) ((-x) & x)
#define MP make_pair
#define VI vector<int>
#define VL vector<LL>
#define VII VI::iterator
#define VLI VL::iterator
#define all(x) x.begin(), x.end()
#define EB emplace_back
#define PII pair<int, int>
#define SI set<int>
#define SII SI::iterator
#define fi first
#define se second
using namespace std;
template<typename T> void chkmn(T &a, const T &b) { (a > b) && (a = b); }
template<typename T> void chkmx(T &a, const T &b) { (a < b) && (a = b); }
void Inc(int &a, const int &b) { ((a += b) >= MOD) && (a -= MOD); }
void Dec(int &a, const int &b) { ((a -= b) < 0) && (a += MOD); }
void Mul(int &a, const int &b) { a = 1LL * a * b % MOD; }
void Sqr(int &a) { a = 1LL * a * a % MOD; }
int inc(const int &a, const int &b) { return (a + b >= MOD) ? a + b - MOD : a + b; }
int dec(const int &a, const int &b) { return (a - b < 0) ? a - b + MOD : a - b; }
int mul(const int &a, const int &b) { return 1LL * a * b % MOD; }
int sqr(const int &a) { return 1LL * a * a % MOD; }
int qwqmi(int x, int k = MOD - 2)
{
	int res = 1;
	while(k)
	{
		if(k & 1) Mul(res, x);
		k >>= 1, Sqr(x);
	}
	return res;
}
const int N = 5e3 + 5;
int n, a[N], f[N];
int main()
{
	scanf("%d", &n);
	for(int i = 1; i <= n; ++i)
		scanf("%d", &a[i]);
	f[0] = 1;
	for(int i = 1; i <= n; ++i)
	{
		int x = a[i];
		int l = i, r = i;
		for(; l > 1 && a[l - 1] < x; --l);
		for(; r < n && a[r + 1] < x; ++r);
		for(int j = l; j <= r; ++j)
			Inc(f[j], f[j - 1]);
	}
	printf("%d\n", f[n]);
	return 0;
}

Submission Info

Submission Time
Task B - Adjacent Chmax
User Schucking_Sattin
Language C++ 20 (gcc 12.2)
Score 700
Code Size 1687 Byte
Status AC
Exec Time 38 ms
Memory 3920 KiB

Compile Error

Main.cpp: In function ‘int main()’:
Main.cpp:45:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   45 |         scanf("%d", &n);
      |         ~~~~~^~~~~~~~~~
Main.cpp:47:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   47 |                 scanf("%d", &a[i]);
      |                 ~~~~~^~~~~~~~~~~~~

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 700 / 700
Status
AC × 3
AC × 40
Set Name Test Cases
Sample 00-sample-001.txt, 00-sample-002.txt, 00-sample-003.txt
All 00-sample-001.txt, 00-sample-002.txt, 00-sample-003.txt, 01-001.txt, 01-002.txt, 01-003.txt, 01-004.txt, 01-005.txt, 01-006.txt, 01-007.txt, 01-008.txt, 01-009.txt, 01-010.txt, 01-011.txt, 01-012.txt, 01-013.txt, 01-014.txt, 01-015.txt, 01-016.txt, 01-017.txt, 01-018.txt, 01-019.txt, 01-020.txt, 01-021.txt, 01-022.txt, 01-023.txt, 01-024.txt, 01-025.txt, 01-026.txt, 01-027.txt, 01-028.txt, 01-029.txt, 01-030.txt, 01-031.txt, 01-032.txt, 01-033.txt, 01-034.txt, 01-035.txt, 01-036.txt, 01-037.txt
Case Name Status Exec Time Memory
00-sample-001.txt AC 1 ms 3764 KiB
00-sample-002.txt AC 1 ms 3688 KiB
00-sample-003.txt AC 1 ms 3688 KiB
01-001.txt AC 1 ms 3896 KiB
01-002.txt AC 1 ms 3676 KiB
01-003.txt AC 1 ms 3768 KiB
01-004.txt AC 2 ms 3692 KiB
01-005.txt AC 1 ms 3696 KiB
01-006.txt AC 1 ms 3676 KiB
01-007.txt AC 2 ms 3832 KiB
01-008.txt AC 2 ms 3796 KiB
01-009.txt AC 36 ms 3828 KiB
01-010.txt AC 37 ms 3828 KiB
01-011.txt AC 37 ms 3796 KiB
01-012.txt AC 37 ms 3788 KiB
01-013.txt AC 37 ms 3920 KiB
01-014.txt AC 38 ms 3680 KiB
01-015.txt AC 37 ms 3856 KiB
01-016.txt AC 38 ms 3732 KiB
01-017.txt AC 37 ms 3620 KiB
01-018.txt AC 36 ms 3860 KiB
01-019.txt AC 37 ms 3800 KiB
01-020.txt AC 35 ms 3796 KiB
01-021.txt AC 37 ms 3684 KiB
01-022.txt AC 36 ms 3828 KiB
01-023.txt AC 37 ms 3680 KiB
01-024.txt AC 37 ms 3624 KiB
01-025.txt AC 37 ms 3716 KiB
01-026.txt AC 37 ms 3824 KiB
01-027.txt AC 36 ms 3672 KiB
01-028.txt AC 31 ms 3676 KiB
01-029.txt AC 33 ms 3720 KiB
01-030.txt AC 36 ms 3916 KiB
01-031.txt AC 37 ms 3832 KiB
01-032.txt AC 36 ms 3624 KiB
01-033.txt AC 37 ms 3620 KiB
01-034.txt AC 32 ms 3744 KiB
01-035.txt AC 33 ms 3716 KiB
01-036.txt AC 8 ms 3796 KiB
01-037.txt AC 8 ms 3680 KiB