QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#508884#7900. Gifts from Knowledgeucup-team3591WA 1ms3596kbC++203.9kb2024-08-07 21:11:502024-08-07 21:11:50

Judging History

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

  • [2024-08-07 21:11:50]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3596kb
  • [2024-08-07 21:11:50]
  • 提交

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;
int fa[N];
int find(int x)	{return x == fa[x] ? x : fa[x] = find(fa[x]);}
inline int merge(int u, int v) {
	int fu = find(u), fv = find(v);
	if (fu == fv)
		return 0;
	fa[fu] = fv;
	return 1;
}

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 * 2 + 2);
    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);
			merge(cur, nxt + n);
            adj[nxt + n].push_back(cur);
			merge(nxt + n, cur);
            adj[nxt].push_back(cur + n);
			merge(nxt, cur + n);
            adj[cur + n].push_back(nxt);
			merge(cur + n, 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);
			merge(cur, nxt);
            adj[nxt].push_back(cur);
			merge(nxt, cur);
            adj[cur + n].push_back(nxt + n);
			merge(cur + n, nxt + n);
            adj[nxt + n].push_back(cur + n);
			merge(nxt + n, cur + n);
        }
    }
    if (flag) {
        cout << 0 << endl;
        return;
    }
    int ans = 1;
    for (int i = 1; i <= n; i++)
		if (find(i) == find(i + n)) {
			std::cout << "0" << '\n';
			return ;
		}
	int cnt = 0;
    for (int i = 1; i <= 2 * n; i++) {
        if (fa[i] == i)
			cnt++;
    }
	cnt >>= 1;
	for (int i = 1; i <= cnt; i++)
		ans = ans * 2 % MOD;
    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: 1ms
memory: 3596kb

input:

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

output:

0
0
0

result:

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