QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#71357#5270. Easily Distinguishable Trianglesneko_nyaa#WA 2ms3452kbC++20991b2023-01-09 20:35:492023-01-09 20:35:51

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-01-09 20:35:51]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:3452kb
  • [2023-01-09 20:35:49]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

#define int long long
const int M = 998244353;

signed main() {
	ios::sync_with_stdio(0); cin.tie(0);
	
	int n; cin >> n;
	vector<string> s(n);
	for (int i = 0; i < n; i++) {
		cin >> s[i];
	}

	int ans = 1;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			if (s[i][j] == '?') {
				int l = j, r = j;
				while (r < n && s[i][r] == '?') {
					r++;
				}
				r--;

				int bd = 2;
				if (l > 0 && s[i][l-1] == '#') bd--; 
				if (r+1 < n && s[i][r+1] == '#') bd--;
				ans = ans*bd % M; 

				j = r;
			}
		}
	}

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			if (s[j][i] == '?') {
				int l = j, r = j;
				while (r < n && s[r][i] == '?') {
					r++;
				}
				r--;

				int bd = 2;
				if (l > 0 && s[l-1][i] == '#') bd--; 
				if (r+1 < n && s[r+1][i] == '#') bd--;
				ans = ans*bd % M; 

				j = r;
			}
		}
	}
	cout << ans << '\n';

	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 2ms
memory: 3440kb

input:

2
.?
?#

output:

4

result:

ok 1 number(s): "4"

Test #2:

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

input:

3
#??
#??
?##

output:

1

result:

ok 1 number(s): "1"

Test #3:

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

input:

3
.#.
#?#
.#.

output:

0

result:

ok 1 number(s): "0"

Test #4:

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

input:

1
.

output:

1

result:

ok 1 number(s): "1"

Test #5:

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

input:

1
#

output:

1

result:

ok 1 number(s): "1"

Test #6:

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

input:

1
?

output:

4

result:

ok 1 number(s): "4"

Test #7:

score: -100
Wrong Answer
time: 2ms
memory: 3440kb

input:

2
?.
?.

output:

8

result:

wrong answer 1st numbers differ - expected: '12', found: '8'