QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#667006#7900. Gifts from KnowledgedyfhpuRE 0ms3600kbC++17926b2024-10-22 20:44:272024-10-22 20:44:38

Judging History

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

  • [2024-10-22 20:44:38]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:3600kb
  • [2024-10-22 20:44:27]
  • 提交

answer

#include <iostream>
using namespace std;
const int mod=1e9+7;
const int N = 1e6+10;
int p[N];
long long power(int a, int b){
	long long res = 1;
	while (b){
		if (b & 1) res = res * a % mod;
		b >>= 1;
		a = a * a % mod;
	}
	return res;
}
void solve()
{
	int r,c,ans=0;
	cin>>r>>c;
	int a[r+10],b[c+10];
	string s;
	for(int i=0;i<=r;i++) p[i]=i;
	for(int i=0;i<=c;i++) a[i]=0,b[i]=0;
	for(int i=1;i<=r;i++) {
		cin>>s;
		s=" "+s;
		for(int j=1;j<=c;j++) {
			if(s[j]=='1') {
				a[j]++;a[c-j+1]++;
				if(a[j]>2||a[c-j+1]>2) {
					cout<<0<<endl;
					return ;
				}
				if(b[j]==0&&b[c-j+1]==0) {
					b[j]=i;
					b[c-j+1]=i;
				}
				else {
					p[i]=p[b[j]];
				}
			}
		}
	}
	for(int i=1;i<=r;i++) {
		if(p[i]==i) ans++;
		p[i]=0;
	}
	cout<<power(2,ans)<<endl;
	return ;
}
int main()
{
    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: 3600kb

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
Runtime Error

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:

1024
32768
2
32
32768
128
32
16
16
2
16384
16384
128
128
32768
8192
128
64
16384
2
4

result: