QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#572122 | #7900. Gifts from Knowledge | StayAlone | WA | 18ms | 28680kb | C++14 | 2.3kb | 2024-09-18 12:11:48 | 2024-09-18 12:11:48 |
Judging History
answer
#include <bits/stdc++.h>
#define rep1(i, l, r) for (int i = l; i <= int(r); ++i)
#define rep2(i, l, r) for (int i = l; i >= int(r); --i)
#define rer(i, l, r, a) rep1(i, l, r) read(a[i])
#define ptc putchar
#define il inline
#define eb emplace_back
#define ef emplace_front
#define mp make_pair
#define fst first
#define snd second
#define sqr(x) ((x) * (x))
#define ls(x) x << 1
#define rs(x) x << 1 | 1
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
// typedef __int128 bll;
// typedef unsigned __int128 ubll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int MAXN = 1e6 + 10, LOGN = log2(MAXN) + 1, inf = ~0U >> 2, INF = ~0U >> 1;
const int dx[] = {0, 0, 1, -1}, dy[] = {1, -1, 0, 0};
namespace stupid_lrc {
template <typename T> il bool read(T &x) {
x = 0; bool f = false; char ch;
while (!isdigit(ch = getchar())) {
f ^= !(ch ^ '-');
if (ch == EOF) return false;
}
while (isdigit(ch)) x = (x << 1) + (x << 3) + (ch & 15), ch = getchar();
if (f) x = ~x + 1; return true;
}
il int read() {int x; read(x); return x;}
template <typename T> il bool read(pair <T, T> &x) {return read(x.fst) && read(x.snd);}
template <typename T> il void gmin(T &x, T y) {x = x < y ? x : y;}
template <typename T> il void gmax(T &x, T y) {x = x > y ? x : y;}
template <typename T, typename ...L>
il bool read(T &x, L &...y) {return read(x) && read(y...);}
template <typename T> il T lowbit(const T &x) {return x & -x;}
}
using namespace stupid_lrc;
int n, m, pa[MAXN]; vector <char> s[MAXN];
const int mod = 1e9 + 7;
il int fpa(int x) {
return x ^ pa[x] ? pa[x] = fpa(pa[x]) : x;
}
il void merge(int x, int y) {
x = fpa(x); y = fpa(y);
pa[y] = x;
}
il void solve() {
read(n, m);
rep1(i, 1, n) s[i].resize(m + 1), scanf("%s", s[i].begin() + 1), pa[i] = i;
rep1(j, 1, m) {
vector <int> g; bool f = 0;
rep1(i, 1, n) {
if (s[i][j] == '1' && s[i][m + 1 - j] == '1') f = 1;
if (s[i][j] == '1' || s[i][m + 1 - j] == '1') g.eb(i);
}
if (f && g.size() > 1) return puts("0"), void();
for (auto v : g) merge(v, g[0]);
} int ans = 1;
rep1(i, 1, n) if (fpa(i) == i) (ans <<= 1) %= mod;
printf("%d\n", ans);
}
int main() {
// freopen("alone.in", "r", stdin);
// freopen("alone.out", "w", stdout);
for (int T = read(); T--; ) solve();
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 4ms
memory: 28232kb
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: 0
Accepted
time: 18ms
memory: 28544kb
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:
1024 32768 2 32 32768 128 32 16 16 2 16384 16384 128 128 32768 8192 128 64 16384 2 4 2 4096 16 4096 1024 32768 32768 16384 8 128 2 16 4096 8192 32768 8192 8192 16 16384 16384 256 128 8 256 8 4096 512 2 4 32 32 2 64 512 1024 32768 32768 2 64 16384 16 8192 16 256 16 64 8192 8192 64 1024 2 32768 2 4 51...
result:
ok 15613 numbers
Test #3:
score: -100
Wrong Answer
time: 15ms
memory: 28680kb
input:
15759 9 6 000000 000000 000000 000000 000000 000000 000000 000000 000000 5 15 010000000000000 000000000000000 000000000000000 000100000000000 000100000000000 14 12 000000000000 000000000000 000000000000 000000000000 000000000000 000000000000 000000000000 000000000000 000000000000 000000000000 000000...
output:
512 16 16384 512 1024 4096 32768 4 2 512 512 512 512 8 2 256 16 4096 512 64 16 4096 512 32 32768 8192 32 2048 128 16 4096 64 32768 256 32 16384 8 512 32 2048 8 16 1024 2048 128 64 32 8 512 8 8192 256 8192 32768 2 8 512 512 256 32 2 2048 8192 8 64 8 2 16384 32768 32768 1024 4096 16384 16384 128 256 4...
result:
wrong answer 1471st numbers differ - expected: '0', found: '16'