QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#697209#6611. United in Stormwindchzhc_WA 1ms3700kbC++141.7kb2024-11-01 11:55:012024-11-01 11:55:02

Judging History

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

  • [2024-11-01 11:55:02]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3700kb
  • [2024-11-01 11:55:01]
  • 提交

answer

#include <bits/stdc++.h>

template < typename T >
inline void read(T &cnt) {
    cnt = 0; char ch = getchar(); bool op = 1;
    for (; ! isdigit(ch); ch = getchar())
        if (ch == '-') op = 0;
    for (; isdigit(ch); ch = getchar())
        cnt = cnt * 10 + ch - 48;
    cnt = op ? cnt : - cnt;
}

const int N = (1 << 20) + 5;

int n, m;
long long k, ans;
double num[N];
char s[N];

inline void FWT_XOR(double *A) {
    for (int len = 2; len <= (1 << m); len *= 2)
        for (int x = 0; x < (1 << m); x += len)
            for (int i = x; i < x + len / 2; ++ i) {
                A[i] = (A[i] + A[i + len / 2]);
                A[i + len / 2] = (A[i] - 2 * A[i + len / 2]);
            }
}

inline void IFWT_XOR(double *A) {
    for (int len = (1 << m); len >= 2; len /= 2)
        for (int x = 0; x < (1 << m); x += len)
            for (int i = x; i < x + len / 2; ++ i) {
                A[i + len / 2] = (A[i] - A[i + len / 2]) / 2;
                A[i] = (A[i] - A[i + len / 2]);
            }
}

int main() {
    read(n), read(m), read(k);
    for (int i = 1; i <= n; ++ i) {
        scanf("%s", s); int x = 0;
        for (int j = 0; j < m; ++ j) {
            x = x * 2 + (s[j] - 'A');
        }
        num[x] += 1;
    }

    FWT_XOR(num);

    for (int i = 0; i < (1 << m); ++ i)
        num[i] = num[i] * num[i];

    IFWT_XOR(num);

    for (int i = 0; i < (1 << m); ++ i)
        for (int x = 0; x < m; ++ x)
            if ((i >> x) & 1)
                num[i] = (num[i] + num[i ^ (1 << x)]);


    for (int i = 0; i < (1 << m); ++ i) {
        if (1ll * n * n - (long long)(num[((1 << m) - 1) ^ i] + 0.5) >= 2 * k)
            ans ++;
    }

    std::cout << ans << '\n';
    return 0;   
}

詳細信息

Test #1:

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

input:

2 2 1
AA
BB

output:

3

result:

ok 1 number(s): "3"

Test #2:

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

input:

2 2 1
AA
AB

output:

2

result:

ok 1 number(s): "2"

Test #3:

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

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:

56

result:

wrong answer 1st numbers differ - expected: '300', found: '56'