QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#508850 | #7900. Gifts from Knowledge | Welcome24ever | WA | 0ms | 3592kb | C++20 | 4.0kb | 2024-08-07 20:42:09 | 2024-08-07 20:42:09 |
Judging History
answer
// __ __ ___ ___ __ __
// /\ \ __/\ \ /\_ \ /'___'\ /\ \ \
// \ \ \/\ \ \ \ __\//\ \ ___ ___ ___ ___ __ /\_\ /\ \ \ \ \ __ __ __ __ _ __
// \ \ \ \ \ \ \ /'__'\ \ \ /'___\ / __'\ /' __' __'\ /'__'\/_/// /__\ \ \ \_ /'__'\/\ \/\ \ /'__'\/\''__\
// \ \ \_/ \_\ \/\ __/ \_\ \_/\ \__//\ \L\ \/\ \/\ \/\ \/\ __/ // /_\ \ \__ ,__\/\ __/\ \ \_/ |/\ __/\ \ \/
// \ '\___x___/\ \____\/\____\ \____\ \____/\ \_\ \_\ \_\ \____\/\______/ \/_/\_\_/\ \____\ \___/ \ \____\ \_\
// '\/__//__/ \/____/\/____/\/____/\/___/ \/_/\/_/\/_/\/____/\/_____/ \/_/ \/____/ \/__/ \/____/ \/_/
// bilibili:24Records
// link:https://space.bilibili.com/3546387113314828
// blog link:https://welcome24ever.github.io/24Records/
//
// Then,we just singing like.
// Welcome To Forever.
#include "bits/stdc++.h"
using namespace std;
const int Welcome24ever = 0;
#define endl '\n'
#define fixset(x) fixed << setprecision(x)
#define int long long
typedef long long ll; typedef pair<int,int> PII;
long double pi = acos(-1);
const int MOD = 1e9 + 7; const int N = 2e5+10;
void NeverSayNever() {
int n, m;
cin >> n >> m;
vector<string> mp(n + 1);
for (int i = 1; i <= n; i++) {
string str;
cin >> str;
mp[i] = ' ' + str;
}
vector<vector<int>> one(m + 2);
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= m; j++) {
if (mp[i][j] == '1') {
one[j].push_back(i);
}
}
}
if (m % 2 == 1) {
if (one[m / 2 + 1].size() > 1) {
cout << 0 << endl;
return;
}
}
vector<vector<int>> adj(n * 3);
for (int i = 1; i <= n; ++i) {
adj[i].push_back(i + n);
adj[i + n].push_back(i);
}
bool flag = false;
for (int i = 1; i <= m / 2; ++i) {
int cnt = one[i].size() + one[m - i + 1].size();
if (cnt > 2) {
flag = true;
break;
}
if (cnt < 2) {
continue;
}
if (one[i].size() == 1) {
int cur = one[i][0];
int nxt = one[m - i + 1][0];
if (cur == nxt) continue;
adj[cur].push_back(nxt + n);
adj[nxt + n].push_back(cur + n);
adj[nxt].push_back(cur + n);
adj[cur + n].push_back(nxt);
} else {
int cur, nxt;
if (one[i].size() != 0) {
cur = one[i][0];
nxt = one[i][1];
} else {
cur = one[m - i + 1][0];
nxt = one[m - i + 1][1];
}
adj[cur].push_back(nxt);
adj[nxt].push_back(cur);
adj[cur + n].push_back(nxt + n);
adj[nxt + n].push_back(cur + n);
}
}
if (flag) {
cout << 0 << endl;
return;
}
int ans = 1;
vector<int> vis(n + 1, 0);
auto dfs = [&](auto &&self, int cur, int fa) -> bool {
for (auto &nxt: adj[cur]) {
if (vis[cur] == vis[nxt]) {
return false;
}
if (vis[nxt] || nxt == fa) {
continue;
}
if (vis[cur] == 1) {
vis[nxt] = 2;
} else {
vis[nxt] = 1;
}
if (self(self, nxt, cur) == false) {
return false;
}
}
return true;
};
for (int i = 1; i <= 2 * n; i++) {
if (vis[i] != 0) {
continue;
}
vis[i] = 1;
if (dfs(dfs, i, 0)) {
ans = ans * 2 % MOD;
} else {
ans = 0;
}
}
cout << ans << endl;
}
signed main() {
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
int T = 1;
cin >> T;
while (T--) {
NeverSayNever();
}
return Welcome24ever;
}
詳細信息
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3592kb
input:
3 3 5 01100 10001 00010 2 1 1 1 2 3 001 001
output:
0 0 2
result:
wrong answer 1st numbers differ - expected: '4', found: '0'