QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#668602#7900. Gifts from KnowledgenageingWA 8ms3808kbC++201.1kb2024-10-23 15:09:112024-10-23 15:09:13

Judging History

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

  • [2024-10-23 15:09:13]
  • 评测
  • 测评结果:WA
  • 用时:8ms
  • 内存:3808kb
  • [2024-10-23 15:09:11]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pii;
const int mod = 1e9 + 7;
bool chmin(int &x, int y) {
	if (x > y) {
		x = y;
		return 1;
	}
	return 0;
}
bool chmax(int &x, int y) {
	if (x < y) {
		x = y;
		return 1;
	}
	return 0;
}

void solve() {
	int n, m;
	cin >> n >> m;
	vector<string>g(n);
	for (int i = 0; i < n; i ++) {
		cin >> g[i];
	}
	vector<int> cnt(m);
	for (int i = 0; i < n; i ++) {
		for (int j = 0; j < m; j ++) {
			if (g[i][j] == '1') {
				cnt[j] ++;
				cnt[m - j - 1] ++;
			}
		}
	}
	ll ans = 1;

	for (int i = 0; i < m; i ++) {
		if (cnt[i] > 2) {
			cout << 0 << '\n';
			return;
		}
	}


	for (int i = 0; i < n; i ++) {
		bool ok = 0;
		for (int j = 0; j < m; j ++) {
			if (g[i][j] == '1') {
				if (cnt[j] == 2 || cnt[m - j - 1] == 2) {
					ok = 1;
				}
				cnt[j] --;
				cnt[m - j - 1] --;
			}
		}
		if (ok) ans = ans * 2 % mod;
	} 
	cout << ans << '\n';

}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr); cout.tie(nullptr);
	int t = 1;
	cin >> t;
	while (t --) {
		solve();
	}

	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

3
3 5
01100
10001
00010
2 1
1
1
2 3
001
001

output:

4
0
2

result:

ok 3 number(s): "4 0 2"

Test #2:

score: -100
Wrong Answer
time: 8ms
memory: 3808kb

input:

15613
10 10
0000000000
0000000000
0000000000
0000000000
0000000000
0000000000
0000000000
0000000000
0000000000
0000000000
15 8
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
1 5
00000
5 9
000000000
000000000
0000...

output:

1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
...

result:

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