Submission #24536336


Source Code Expand

#include <bits/stdc++.h>

using namespace std;

#define MOD 998244353

int n, k;
char x[5];
set<int> s[1005];
long long ans = 1;

int main() {
	scanf("%d%d", &n, &k);
	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= k; j++)
			s[i].insert(j);
	for (int i = 1; i <= k; i++) {
		int tmp;
		scanf("%s%d", x, &tmp);
		if (!s[tmp].count(i)) {
			puts("0");
			exit(0);
		}
		s[tmp].clear();
		s[tmp].insert(i);
		if (x[0] == 'L')
			for (int j = 1; j < tmp; j++)
				s[j].erase(i);
		else
			for (int j = tmp + 1; j <= n; j++)
				s[j].erase(i);
	}
	for (int i = 1; i <= n; i++)
		ans = ans * s[i].size() % MOD;
	printf("%lld\n", ans);
}

Submission Info

Submission Time
Task A - LR Constraints
User nhho
Language C++ (GCC 9.2.1)
Score 300
Code Size 671 Byte
Status AC
Exec Time 181 ms
Memory 50548 KiB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:13:7: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   13 |  scanf("%d%d", &n, &k);
      |  ~~~~~^~~~~~~~~~~~~~~~
./Main.cpp:19:8: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   19 |   scanf("%s%d", x, &tmp);
      |   ~~~~~^~~~~~~~~~~~~~~~~

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 2
AC × 17
Set Name Test Cases
Sample sample_01.txt, sample_02.txt
All random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, sample_01.txt, sample_02.txt
Case Name Status Exec Time Memory
random_01.txt AC 181 ms 50548 KiB
random_02.txt AC 3 ms 4000 KiB
random_03.txt AC 4 ms 3996 KiB
random_04.txt AC 4 ms 4088 KiB
random_05.txt AC 3 ms 3952 KiB
random_06.txt AC 34 ms 10724 KiB
random_07.txt AC 7 ms 4584 KiB
random_08.txt AC 62 ms 17824 KiB
random_09.txt AC 118 ms 33448 KiB
random_10.txt AC 3 ms 3944 KiB
random_11.txt AC 62 ms 19884 KiB
random_12.txt AC 137 ms 37948 KiB
random_13.txt AC 62 ms 19380 KiB
random_14.txt AC 74 ms 21620 KiB
random_15.txt AC 44 ms 14468 KiB
sample_01.txt AC 2 ms 3804 KiB
sample_02.txt AC 3 ms 3696 KiB