QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#704862 | #7900. Gifts from Knowledge | hamster | WA | 16ms | 3584kb | C++23 | 1.2kb | 2024-11-02 21:18:48 | 2024-11-02 21:18:50 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define int long long
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
const int MOD=1000000007;
void Solve() {
int r,c;
cin>>r>>c;
string mp[r];
for(int i=0;i<r;i++)cin>>mp[i];
vector<vector<int>> adj(r+1);
vector<bool> vis(r+1);
for(int i=0;i<=c/2;i++) {
vector<int> v;
for(int j=0;j<r;j++) {
if(mp[j][i]=='1') {
v.push_back(j);
}
if(mp[j][c-i-1]=='1') {
v.push_back(j);
}
if(v.size()>2) {cout<<0<<endl;return;}
}
if(v.size()==2&&v[0]!=v[1]) {
adj[v[0]].emplace_back(v[1]);
adj[v[1]].emplace_back(v[0]);
}
}
function<void(int u)> dfs=[&](int u){
vis[u]=1;
for(auto v:adj[u]) {
if(!vis[v]) dfs(v);
}
};
int ans=1;
for(int i=1;i<r;i++) {
if(!vis[i]) {
dfs(i);
ans=ans*2%MOD;
}
}
cout<<ans<<endl;
}
signed main() {
int Task;
cin >> Task;
while (Task--) Solve();
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3556kb
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: 16ms
memory: 3584kb
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:
512 16384 1 16 16384 64 16 8 8 1 8192 8192 64 64 16384 4096 64 32 8192 1 2 1 2048 8 2048 512 16384 16384 8192 4 64 1 8 2048 4096 16384 4096 4096 8 8192 8192 128 64 4 128 4 2048 256 1 2 16 16 1 32 256 512 16384 16384 1 32 8192 8 4096 8 128 8 32 4096 4096 32 512 1 16384 1 2 256 2048 512 16 4096 1 16 1...
result:
wrong answer 1st numbers differ - expected: '1024', found: '512'