QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#759445#6611. United in StormwindfosovWA 1ms5684kbC++141.7kb2024-11-18 08:34:102024-11-18 08:34:12

Judging History

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

  • [2024-11-18 08:34:12]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:5684kb
  • [2024-11-18 08:34:10]
  • 提交

answer

#include "bits/stdc++.h"
using namespace std;

#define ll long long 
#define lll __int128
#define INF 0x3f3f3f3f
#define LNF 0x3f3f3f3f3f3f3f3fll
#define MOD 998244353
#define pii pair<int, int>

#define N (1<<21) 

template<typename T> 
struct FWT {
    int n;

    void Xor(T* a, bool inv=0) {
        T t = !inv ? T(1) : T(2);
        for (int i = 2; i <= n; i <<= 1) {
            int h = i >> 1;
            for (int j = 0; j < n; j += i) {
                for (int k = 0; k < h; ++ k) {
                    a[j+k] = a[j+k] + a[j+k+h];
                    a[j+k+h] = a[j+k] - a[j+k+h] - a[j+k+h];
                    a[j+k] = a[j+k] / T(t);
                    a[j+k+h] = a[j+k+h] / T(t);
                }
            }
        }
    }
};


FWT<ll> fwt;
ll cnt[N], dp[N];

int main() {
#ifdef TEST
    freopen("zz.in", "r+", stdin);
#endif
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int n, m, k; cin >> n >> m >> k;
    int msk = (1<<m)-1;

    for (int i = 0; i < n; ++ i) {
        string s; cin >> s;
        int cur = 0;
        for (int j = 0; j < m; ++ j) cur |= ((s[j] == 'A') << j);
        cnt[cur] ++;
    }

    fwt.n = 1<<m;
    fwt.Xor(cnt);
    for (int i = 0; i < (1<<m); ++ i) cnt[i] *= cnt[i];
    fwt.Xor(cnt, 1);

    for (int i = 0; i < (1<<m); ++ i) dp[i] = cnt[i];
    for (int i = 1; i < (1<<m); ++ i) {
        int msb = 1<<(31-__builtin_clz(i));
        int lsb = (i&-i);

        if (msb == lsb) dp[i] += dp[i-lsb];
        else dp[i] += dp[i-lsb] + dp[i-msb] - dp[i-lsb-msb];
    }

    int res = 0;
    for (int i = 0; i < (1<<m); ++ i) res += (1ll * n * n - dp[msk^i]) >= 2ll * k;

    cout << res << '\n';
}

詳細信息

Test #1:

score: 100
Accepted
time: 1ms
memory: 5684kb

input:

2 2 1
AA
BB

output:

3

result:

ok 1 number(s): "3"

Test #2:

score: 0
Accepted
time: 1ms
memory: 5620kb

input:

2 2 1
AA
AB

output:

2

result:

ok 1 number(s): "2"

Test #3:

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

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:

526

result:

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