QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#397673#8546. Min or Max 2comeintocalm#WA 1ms3872kbC++171.1kb2024-04-24 15:48:232024-04-24 15:48:23

Judging History

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

  • [2024-04-24 15:48:23]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3872kb
  • [2024-04-24 15:48:23]
  • 提交

answer

#include <bits/stdc++.h>
#define LL long long
#define db double
using namespace std;

const int mo = 998244353;
const int MAXN = 3e3 + 5;
#define inc(t1) ((t1) >= mo ? ((t1) -= mo) : 0)
int T, n, m;
char s[MAXN];

int ok[MAXN];
int f[MAXN][MAXN];

int r[MAXN], l[MAXN];

int main() {
	int i,j,k;
	cin >> n;
	f[0][1] = 1;
	r[0] = 1;
	for (i = 1; i <= n; ++i) {
		cin >> s + 1;
		int ret = 0, flg = 0;
		r[i] = 1, l[i] = n;
		for (j = 1; j <= n; ++j)
			if (s[j] == '0') r[i] = j, flg = 1;
		for (j = n; j >= 1; --j)
			if (s[j] == '0') l[i] = j;
		for (j = r[i - 1]; j <= l[i]; ++j)
			if (s[j] != '1') f[i][j] += f[i - 1][j], inc (f[i][j]);
		for (j = r[i - 1]; j <= n; ++j) {
			if (s[j] != '0') ret += f[i - 1][j];
			if (s[j] != '1') f[i][j] += ret, inc (f[i][j]);
			
			if (s[j] == '0') ret = f[i][j];
			else if (s[j] == '?') ret += f[i][j], inc (ret);
		}
		if (!flg) {
			for (j = 1; j <= n; ++j) f[i][j] += f[i - 1][j], inc (f[i][j]);
		}
		//for (j = r[i]; j <= n; ++j) f[i][j] += f[i - 1][j], inc (f[i][j]);
	}
	int ans = 0;
	for (j = 1; j <= n; ++j) ans += f[n][j], inc (ans);
	printf ("%d", ans);
	return 0;
}

詳細信息

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 3872kb

input:

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

output:

399

result:

wrong answer 1st numbers differ - expected: '2', found: '399'