QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#650722#7900. Gifts from KnowledgeabsabsWA 20ms3664kbC++232.9kb2024-10-18 16:15:262024-10-18 16:15:26

Judging History

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

  • [2024-10-18 16:15:26]
  • 评测
  • 测评结果:WA
  • 用时:20ms
  • 内存:3664kb
  • [2024-10-18 16:15:26]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl "\n"
#define ull unsigned long long
#define ms(x, y) memset(x, y, sizeof x);
#define debug(x) cout << #x << " = " << x << endl;
#define ios ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
#define fre                           \
freopen("input.txt", "r", stdin); \
freopen("output.txt", "w", stdout);
const int mod = 1e9 + 7;
const int inf = 0x3f3f3f3f3f3f3f3f;
const int N = 1e6 + 10;
const double esp = 1e-6;
const ull MOD1 = 1610612741;
const ull MOD2 = 805306457;
const ull BASE1 = 1331;
const ull BASE2 = 131;
#define pre(i, a, b) for (int i = a; i <= b; i++)
#define rep(i, a, b) for (int i = a; i >= b; i--)
#define all(x) (x).begin(), (x).end()
char *p1, *p2, buf[100000]; // 快读和同步流二者只能选一个
#define nc() (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 100000, stdin), p1 == p2) ? EOF : *p1++)
int read()
{
	int x = 0, f = 1;
	char ch = nc();
	while (ch < 48 || ch > 57)
	{
		if (ch == '-')
			f = -1;
		ch = nc();
	}
	while (ch >= 48 && ch <= 57)
		x = x * 10 + ch - 48, ch = nc();
	return x * f;
}
void write(int x)
{
	if (x < 0)
		putchar('-'), x = -x;
	if (x > 9)
		write(x / 10);
	putchar(x % 10 + '0');
	return;
}
int n,m;
int qmi(int a,int b)
{
	int res = 1;
	while(b)
	{
		if(b & 1) res = res * a % mod;
		a = a * a % mod;
		b >>= 1;
	}
	return res;
}
void solve()
{
	cin >> n >> m;
	vector<vector<int>> g(n + 1,vector<int>(m + 1));
	map<int,int> mp;
	int f = 0,tp = 0,ans = 1,res = 0;
	vector<int> ve;
	pre(i,1,n)
	{
		int cnt = 0,ff = 0;
		map<int,int> res;
		pre(j,1,m)
		{
			char c;
			cin >> c;
			g[i][j] = c - '0';
			if(g[i][j] == 0) continue;
			// cnt ++ ;
			// if(m % 2 == 1 && j == (m + 1) / 2)
			// 	tp = 1;
			res[j] = 1;
			// cout << g[i][j] << " " << mp[g[i][j]] << "     " << mp[m - g[i][j] + 1] << endl;
			if(mp[j] == 1)
			{
				if(mp[m - j + 1] == 1)
					f = 1;
				else mp[m - j + 1] = 1;
			}
			else mp[j] = 1;
		}
		for(auto [L,c] : res)
		{
			if(res[m - L + 1]) continue ;
			else ff = 1;
		}
		if(!ff) ve.push_back(i);
		// if(tp == 1 && cnt == 1)
		// 	ve.push_back(i);
	}	
	// pre(i,1,n)
	// {
	// 	pre(j,1,m) cout << g[i][j];
	// 	cout << endl;
	// }
	// cout << ve.size() << " " << (n - ve.size()) / 2 << endl;
	if(f) cout << 0 << endl;
	else 
	{
		cout << qmi(2,ve.size()) % mod * qmi(2,(n - ve.size()) / 2) % mod << endl;
	}
}
// #define LOCAL
signed main()
{
	ios
	// fre
#ifdef LOCAL
	freopen("in.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
	auto start = std::chrono::high_resolution_clock::now();
#endif
	
	int t = 1;
	cin >> t;
	while (t--)
		solve();
	
#ifdef LOCAL
	auto end = std::chrono::high_resolution_clock::now();
	cout << "Execution time: "
	<< std::chrono::duration_cast<std::chrono::milliseconds>(end - start).count()
	<< " ms" << '\n';
#endif
	return 0;
}


Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3648kb

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: 0
Accepted
time: 18ms
memory: 3664kb

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
2
4096
16
4096
1024
32768
32768
16384
8
128
2
16
4096
8192
32768
8192
8192
16
16384
16384
256
128
8
256
8
4096
512
2
4
32
32
2
64
512
1024
32768
32768
2
64
16384
16
8192
16
256
16
64
8192
8192
64
1024
2
32768
2
4
51...

result:

ok 15613 numbers

Test #3:

score: -100
Wrong Answer
time: 20ms
memory: 3608kb

input:

15759
9 6
000000
000000
000000
000000
000000
000000
000000
000000
000000
5 15
010000000000000
000000000000000
000000000000000
000100000000000
000100000000000
14 12
000000000000
000000000000
000000000000
000000000000
000000000000
000000000000
000000000000
000000000000
000000000000
000000000000
000000...

output:

512
8
16384
256
1024
2048
16384
4
1
512
512
256
512
8
2
256
16
2048
256
64
16
4096
512
16
32768
8192
32
1024
128
16
4096
32
32768
256
16
16384
8
512
16
2048
8
8
512
1024
64
32
32
8
512
4
8192
256
2048
32768
1
8
512
512
256
32
2
1024
8192
4
64
8
2
16384
32768
16384
1024
4096
16384
8192
128
256
2
8192...

result:

wrong answer 2nd numbers differ - expected: '16', found: '8'