QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#676055 | #6611. United in Stormwind | lonelywolf | WA | 1ms | 3888kb | C++20 | 1.7kb | 2024-10-25 20:08:04 | 2024-10-25 20:08:05 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define int long long
void FWT(vector<int> &a, bool inv) {
for (int n = a.size(), step = 1; step < n; step *= 2) {
for (int i = 0; i < n; i += 2 * step) {
for (int j = i; j < i + step; j++) {
int &u = a[j], &v = a[j + step];
// tie(u, v) = inv ? pair(v - u, u) : pair(v, u + v); // AND
// tie(u, v) = inv ? pair(v, u - v) : pair(u + v, u); // OR
tie(u, v) = pair(u + v, u - v); // XOR
}
}
}
if (inv) {
for (auto &x : a) {
x /= a.size(); // XOR only
}
}
}
vector<int> conv(vector<int> a, vector<int> b) {
FWT(a, false);
FWT(b, false);
for (int i = 0; i < a.size(); i++) {
a[i] *= b[i];
}
FWT(a, true);
return a;
}
signed main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n, m, k;
cin >> n >> m >> k;
vector<int> a(n + 1);
vector<int> x(1LL << m);
for (int i = 1; i <= n; i++) {
for (int j = 0; j < m; j++) {
char c;
cin >> c;
if (c == 'A') {
a[i] |= (1LL << j);
}
}
x[a[i]]++;
}
auto f = conv(x, x);
f[0] -= n;
for (int i = 0; i < (1LL << m); i++) {
f[i] /= 2;
}
auto g = f;
for (int i = 0; i < m; i++) {
for (int j = 0; j < (1LL << m); j++) {
if (j >> i & 1) {
g[j] += f[j ^ (1LL << i)];
}
}
}
int ans = 0;
for (int i = 1; i < (1LL << m); i++) {
int x = i;
for (int j = 0; j < m; j++) {
x ^= (1LL << j);
}
if (n * (n - 1) / 2 - g[x] >= k) {
ans++;
}
}
cout << ans << "\n";
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3608kb
input:
2 2 1 AA BB
output:
3
result:
ok 1 number(s): "3"
Test #2:
score: 0
Accepted
time: 0ms
memory: 3620kb
input:
2 2 1 AA AB
output:
2
result:
ok 1 number(s): "2"
Test #3:
score: -100
Wrong Answer
time: 1ms
memory: 3888kb
input:
5000 10 12302135 AABAAAABBA AAABAABBAB BAABABAAAB ABBAABBBBA BAAAAABAAB BABBAAAAAA BABBABABAB BBABBAAAAB BABBABBBBA AAAAAAABAA BBBBBAABBA BAABABBAAB BABAAABAAA AAAAABAABB BBABAABABB ABAABBABBA BBBAAABABA BAAABABBAB ABAAAAABAA AABBBBBBAA ABBABBABBA AABBBABBAB BAABBAAABB BAAABBBBBB ABABBAABBB BABBABBA...
output:
1023
result:
wrong answer 1st numbers differ - expected: '300', found: '1023'