QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#727615 | #7900. Gifts from Knowledge | Albert711 | WA | 0ms | 3612kb | C++20 | 2.5kb | 2024-11-09 13:27:49 | 2024-11-09 13:27:50 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
// #define int long long
#define ll long long
const int N = 2e5 + 10;
const int mod = 998244353;
vector<int> fa;
int find(int k){
if(k == fa[k]) return k;
return fa[k] = find(fa[k]);
}
int jj;
int cc=0;
void abt(){
int n, len;
cin >> n >> len;
vector<string> s(n + 1);
vector<vector<int>> cnt(len + 1);
fa = vector<int>(2 * n + 1);
for(int i = 1; i <= n; i++) {
cin >> s[i];
s[i] = ' ' + s[i];
for(int j = 1; j <= len; j++) {
if(s[i][j] == '1') {
cnt[j].push_back(i);
}
}
}
cc++;
if(jj==1&&cc!=147) {
return;
}
for(int i=1;i<=n;i++) {
cout<<s[i]<<'\n';
}
int jud = 0;
for(int i = 1; i <= len / 2; i++) {
int tmp = cnt[i].size() + cnt[len - i + 1].size();
if(tmp > 2) {
jud = 1;
break;
}
}
if(len % 2 == 1) {
if(cnt[len / 2 + 1].size() == 2) jud = 1;
}
if(jud) {
cout << 0 << '\n';
return;
}
for(int i = 1; i <= 2 * n; i++) {
fa[i] = i;
}
for(int i = 1; i <= len / 2; i++) {
int tmp = cnt[i].size() + cnt[len - i + 1].size();
if(tmp == 2) {
if(cnt[i].size() == 2) {
fa[find(cnt[i][0])] = find(cnt[i][1] + n);
fa[find(cnt[i][0] + n)] = find(cnt[i][1]);
} else if(cnt[len - i + 1].size() == 2) {
fa[find(cnt[len - i + 1][0])] = find(cnt[len - i + 1][1] + n);
fa[find(cnt[len - i + 1][0] + n)] = find(cnt[len - i + 1][1]);
} else {
fa[find(cnt[i][0])] = find(cnt[len - i + 1][0]);
fa[find(cnt[i][0] + n)] = find(cnt[len - i + 1][0] + n);
}
}
}
jud=0;
for(int i=1;i<=n;i++) {
if(find(i)==find(i+n)) {
jud=1;
break;
}
}
if(jud) {
cout << 0 << '\n';
return;
}
int ans = 0;
vector<int> idx(2 * n + 1);
for(int i = 1; i <= 2 * n; i++) {
if(idx[find(i)] == 0) {
ans++;
}
idx[find(i)]++;
}
ans /= 2;
cout << (1 << ans) << '\n';
}
signed main(){
ios::sync_with_stdio(false);
cin.tie(nullptr), cout.tie(nullptr);
int T = 1;
cin >> T;
if(T==15734) jj=1;
while(T--) abt();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3612kb
input:
3 3 5 01100 10001 00010 2 1 1 1 2 3 001 001
output:
01100 10001 00010 4 1 1 0 001 001 2
result:
wrong output format Expected integer, but "01100" found