QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#759472#6611. United in StormwindfosovWA 1ms5772kbC++141.6kb2024-11-18 09:05:362024-11-18 09:05:36

Judging History

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

  • [2024-11-18 09:05:36]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:5772kb
  • [2024-11-18 09:05:36]
  • 提交

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;
                    a[j+k+h] = a[j+k+h] / 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);

    ll 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 < m; ++ i) {
        for (int j = 0; j < (1<<m); ++ j) {
            if ((j>>i)&1) {
                dp[j] += dp[j^(1<<i)];
            }
        }
    }

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

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

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

2 2 1
AA
BB

output:

3

result:

ok 1 number(s): "3"

Test #2:

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

input:

2 2 1
AA
AB

output:

2

result:

ok 1 number(s): "2"

Test #3:

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

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:

442

result:

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