QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#880741#9698. Twenty-twozqsWA 2ms12368kbC++141.5kb2025-02-03 19:18:182025-02-03 19:18:18

Judging History

This is the latest submission verdict.

  • [2025-02-03 19:18:18]
  • Judged
  • Verdict: WA
  • Time: 2ms
  • Memory: 12368kb
  • [2025-02-03 19:18:18]
  • Submitted

answer

#include <cstdio>
#include <algorithm>
#include <bitset>

const int mod = 998244353;
using std::min; using std::max;
int f[155][155][155], g[155], crs[155][155][155], a[155], n, q1, q2, mn = 1e9;
bool vis[155], cov[155];
std::bitset<155> hav[155][155][155];

int main() {
	scanf("%d%d%d", &n, &q1, &q2);
	for (int i = 1; i <= n; ++ i) scanf("%d", a + i);
	for (int i = 1, x; i <= q1; ++ i) scanf("%d", &x), vis[x] = 1, mn = min(mn, x);
	for (int i = 1; i <= n; ++ i) a[i] = min(a[i], mn);
	for (int i = 0; i <= n; ++ i)
	for (int x = 0; x <= n + 1; ++ x) f[i + 1][i][x] = 1;
	for (int i = 1, l, r, x; i <= q2; ++ i)  {
		scanf("%d%d%d", &l, &r, &x);
		for (int j = l; j <= r; ++ j) crs[l][r][j] = max(crs[l][r][j], x), hav[l][r][j].set(x), cov[j] = 1;
	}
	for (int l = n; l; -- l)
	for (int r = l; r <= n; ++ r) {
		for (int k = l; k <= r; ++ k) {
			crs[l][r][k] = max(crs[l][r][k], max(crs[l + 1][r][k], crs[l][r - 1][k]));
			hav[l][r][k] |= hav[l + 1][r][k] | hav[l][r - 1][k];
		}
		for (int x = n; x; -- x) {
			g[l - 1] = 1;
			for (int i = l; i <= r; ++ i) {
				g[i] = 0;
				if ((mn <= x || !cov[i]) &&
				(a[i] <= x && (a[i] == x || (vis[x] && crs[l][r][i] >= x) || hav[l][r][i][x])))
					for (int j = l - 1; j < i; ++ j)
						g[i] = (g[i] + 1ll * g[j] * f[j + 1][i - 1][x + 1]) % mod;
			}
			for (int k = l; k <= r; ++ k)
				f[l][r][x] = (f[l][r][x] + 1ll * g[k] * f[k + 1][r][x + 1]) % mod;
			f[l][r][x] = (f[l][r][x] + f[l][r][x + 1]) % mod;
		}
	}
	printf("%d", f[1][n][1]);
	return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 8012kb

input:

5 2 2
4 1 3 5 2
2 4
1 3 3
2 5 5

output:

6

result:

ok 1 number(s): "6"

Test #2:

score: 0
Accepted
time: 0ms
memory: 12064kb

input:

13 2 1
12 13 4 12 9 12 11 3 13 1 3 8 10
3 9
6 7 10

output:

3

result:

ok 1 number(s): "3"

Test #3:

score: 0
Accepted
time: 2ms
memory: 12368kb

input:

16 3 2
9 16 6 15 8 7 6 3 11 12 14 9 12 13 1 2
12 15 9
1 2 10
4 5 14

output:

6

result:

ok 1 number(s): "6"

Test #4:

score: -100
Wrong Answer
time: 1ms
memory: 10064kb

input:

8 1 4
8 2 7 4 8 7 7 5
4
1 2 3
4 7 5
5 6 8
3 8 6

output:

0

result:

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