QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#650728#7900. Gifts from KnowledgeabsabsWA 15ms3908kbC++233.0kb2024-10-18 16:16:362024-10-18 16:16:37

Judging History

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

  • [2024-10-18 16:16:37]
  • 评测
  • 测评结果:WA
  • 用时:15ms
  • 内存:3908kb
  • [2024-10-18 16:16:36]
  • 提交

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(cnt == 0) 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: 3844kb

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: 15ms
memory: 3908kb

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:

639837028
899139017
117470694
518124367
899139017
144994908
518124367
759062187
759062187
117470694
949569512
949569512
144994908
144994908
899139017
237392378
144994908
72497454
949569512
117470694
469882776
117470694
118696189
759062187
118696189
639837028
899139017
899139017
949569512
939765552
1...

result:

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