QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#676028#6611. United in StormwindlonelywolfWA 1ms3608kbC++201.6kb2024-10-25 20:02:312024-10-25 20:02:31

Judging History

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

  • [2024-10-25 20:02:31]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3608kb
  • [2024-10-25 20:02:31]
  • 提交

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;
	}

	vector<int> g(1LL << m);
	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++) {
		if (n * (n - 1) / 2 - g[i] >= k) {
			ans++;
		}
	}

	cout << ans << "\n";

    return 0;
}  

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 3480kb

input:

2 2 1
AA
BB

output:

3

result:

ok 1 number(s): "3"

Test #2:

score: 0
Accepted
time: 0ms
memory: 3608kb

input:

2 2 1
AA
AB

output:

2

result:

ok 1 number(s): "2"

Test #3:

score: -100
Wrong Answer
time: 1ms
memory: 3592kb

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'