QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#771591#6611. United in Stormwinddaylight-et-alWA 60ms19952kbC++236.3kb2024-11-22 14:25:182024-11-22 14:25:24

Judging History

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

  • [2024-11-22 14:25:24]
  • 评测
  • 测评结果:WA
  • 用时:60ms
  • 内存:19952kb
  • [2024-11-22 14:25:18]
  • 提交

answer

// competitive-verifier: PROBLEM
#include <cassert>
#include <cstdint>
#include <utility>
namespace internal {
namespace floor_sum {
// @param m `1 <= m`
// @return x mod m
constexpr std::int64_t safe_mod(std::int64_t x, std::int64_t m) {
    x %= m;
    if (x < 0) x += m;
    return x;
}
// @param n `n < 2^32`
// @param m `1 <= m < 2^32`
// @return sum_{i=0}^{n-1} floor((ai + b) / m) (mod 2^64)
std::uint64_t floor_sum_unsigned(std::uint64_t n, std::uint64_t m, std::uint64_t a,
                                 std::uint64_t b) {
    std::uint64_t ans = 0;
    while (true) {
        if (a >= m) {
            ans += n * (n - 1) / 2 * (a / m);
            a %= m;
        }
        if (b >= m) {
            ans += n * (b / m);
            b %= m;
        }
        std::uint64_t y_max = a * n + b;
        if (y_max < m) break;
        // y_max < m * (n + 1)
        // floor(y_max / m) <= n
        n = (std::uint64_t)(y_max / m);
        b = (std::uint64_t)(y_max % m);
        std::swap(m, a);
    }
    return ans;
}
}  // namespace floor_sum
}  // namespace internal
/**
 * @brief floor sum
 *
 * @param n
 * @param m
 * @param a
 * @param b
 * @retval std::int64_t sum[0 <= i < n]floor((a * i + b) / m)
 *
 * @see https://atcoder.github.io/ac-library/production/document_ja/math.html
 */
std::int64_t floor_sum(std::int64_t n, std::int64_t m, std::int64_t a, std::int64_t b) {
    assert(0 <= n && n < (1LL << 32));
    assert(1 <= m && m < (1LL << 32));
    std::uint64_t ans = 0;
    if (a < 0) {
        std::uint64_t a2 = internal::floor_sum::safe_mod(a, m);
        ans -= 1ULL * n * (n - 1) / 2 * ((a2 - a) / m);
        a = a2;
    }
    if (b < 0) {
        std::uint64_t b2 = internal::floor_sum::safe_mod(b, m);
        ans -= 1ULL * n * ((b2 - b) / m);
        b = b2;
    }
    return ans + internal::floor_sum::floor_sum_unsigned(n, m, a, b);
}
#ifdef ATCODER
#pragma GCC target("sse4.2,avx512f,avx512dq,avx512ifma,avx512cd,avx512bw,avx512vl,bmi2")
#endif
#pragma GCC optimize("Ofast,fast-math,unroll-all-loops")
#include <bits/stdc++.h>
#ifndef ATCODER
#pragma GCC target("sse4.2,avx2,bmi2")
#endif
template <class T, class U>
constexpr bool chmax(T &a, const U &b) {
    return a < (T)b ? a = (T)b, true : false;
}
template <class T, class U>
constexpr bool chmin(T &a, const U &b) {
    return (T)b < a ? a = (T)b, true : false;
}
constexpr std::int64_t INF = 1000000000000000003;
constexpr int Inf = 1000000003;
constexpr double EPS = 1e-7;
constexpr double PI = 3.14159265358979323846;
#define FOR(i, m, n) for (int i = (m); i < int(n); ++i)
#define FORR(i, m, n) for (int i = (m)-1; i >= int(n); --i)
#define FORL(i, m, n) for (int64_t i = (m); i < int64_t(n); ++i)
#define rep(i, n) FOR (i, 0, n)
#define repn(i, n) FOR (i, 1, n + 1)
#define repr(i, n) FORR (i, n, 0)
#define repnr(i, n) FORR (i, n + 1, 1)
#define all(s) (s).begin(), (s).end()
struct Sonic {
    Sonic() {
        std::ios::sync_with_stdio(false);
        std::cin.tie(nullptr);
        std::cout << std::fixed << std::setprecision(20);
    }
    constexpr void operator()() const {}
} sonic;
using namespace std;
using ll = std::int64_t;
using ld = long double;
template <class T, class U>
std::istream &operator>>(std::istream &is, std::pair<T, U> &p) {
    return is >> p.first >> p.second;
}
template <class T>
std::istream &operator>>(std::istream &is, std::vector<T> &v) {
    for (T &i : v) is >> i;
    return is;
}
template <class T, class U>
std::ostream &operator<<(std::ostream &os, const std::pair<T, U> &p) {
    return os << '(' << p.first << ',' << p.second << ')';
}
template <class T>
std::ostream &operator<<(std::ostream &os, const std::vector<T> &v) {
    for (auto it = v.begin(); it != v.end(); ++it) os << (it == v.begin() ? "" : " ") << *it;
    return os;
}
template <class Head, class... Tail>
void co(Head &&head, Tail &&...tail) {
    if constexpr (sizeof...(tail) == 0) std::cout << head << '\n';
    else std::cout << head << ' ', co(std::forward<Tail>(tail)...);
}
template <class Head, class... Tail>
void ce(Head &&head, Tail &&...tail) {
    if constexpr (sizeof...(tail) == 0) std::cerr << head << '\n';
    else std::cerr << head << ' ', ce(std::forward<Tail>(tail)...);
}
void Yes(bool is_correct = true) { std::cout << (is_correct ? "Yes\n" : "No\n"); }
void No(bool is_not_correct = true) { Yes(!is_not_correct); }
void YES(bool is_correct = true) { std::cout << (is_correct ? "YES\n" : "NO\n"); }
void NO(bool is_not_correct = true) { YES(!is_not_correct); }
void Takahashi(bool is_correct = true) { std::cout << (is_correct ? "Takahashi" : "Aoki") << '\n'; }
void Aoki(bool is_not_correct = true) { Takahashi(!is_not_correct); }
template <typename T>
void fwt(vector<T>& f) {
    int n = f.size();
    for (int i = 1; i < n; i <<= 1) {
        for (int j = 0; j < n; j++) {
            if ((j & i) == 0) {
                T x = f[j], y = f[j | i];
                f[j] = x + y, f[j | i] = x - y;
            }
        }
    }
}
template <typename T>
void ifwt(vector<T>& f) {
    int n = f.size();
    for (int i = 1; i < n; i <<= 1) {
        for (int j = 0; j < n; j++) {
            if ((j & i) == 0) {
                T x = f[j], y = f[j | i];
                f[j] = (x + y) / 2, f[j | i] = (x - y) / 2;
            }
        }
    }
}
template <typename T>
void fzt(vector<T>& f) {
    int n = f.size();
    for (int i = 1; i < n; i <<= 1) {
        for (int j = 0; j < n; j++) {
            if ((j & i) == 0) {
                f[j] += f[j | i];
                // この場合上位集合の畳み込みになる
                // 左辺と右辺を逆にすると下位集合の畳み込みになる
            }
        }
    }
}
int main(void) {
    int n, m, k;
    cin >> n >> m >> k;
    vector<string> s(n);
    cin >> s;
    vector<ll> a(1 << m), b(1 << m);
    rep (i, n) {
        int x = 0, y = 0;
        rep (j, m) {
            if (s[i][j] == 'B') {
                x |= 1 << j;
            } else {
                y |= 1 << j;
            }
        }
        a[x] += 1, b[y] += 1;
    }
    fwt(a), fwt(b);
    rep (i, 1 << m) a[i] *= b[i];
    ifwt(a);
    a[(1 << m) - 1] -= n;
    fzt(a);
    int ans = 0;
    rep (i, 1 << m) {
        ans += ((ll)n * (n - 1) / 2 - a[i] / 2) >= k;
    }
    co(ans);
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

2 2 1
AA
BB

output:

3

result:

ok 1 number(s): "3"

Test #2:

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

input:

2 2 1
AA
AB

output:

2

result:

ok 1 number(s): "2"

Test #3:

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

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:

300

result:

ok 1 number(s): "300"

Test #4:

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

input:

5000 10 1
AABBAABBBB
AABBAABBBB
AABBAABBBB
AABBAABBBB
AABBAABBBB
AABBAABBBB
AABBAABBBB
AABBAABBBB
AABBAABBBB
AABBAABBBB
AABBAABBBB
AABBAABBBB
AABBAABBBB
AABBAABBBB
AABBAABBBB
AABBAABBBB
AABBAABBBB
AABBAABBBB
AABBAABBBB
AABBAABBBB
AABBAABBBB
AABBAABBBB
AABBAABBBB
AABBAABBBB
AABBAABBBB
AABBAABBBB
AABB...

output:

0

result:

ok 1 number(s): "0"

Test #5:

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

input:

5000 10 8968133
BABAAAAAAA
BABAAAAAAA
AAABAAAAAA
BABBBBBAAA
AABBAAABAA
AAABAAAAAA
ABAAABAAAB
BABBBBBAAA
BABAAAAAAA
BABBBBBAAA
ABAAABAAAB
BABAAAAAAA
ABAAABAAAB
AABBAAABAA
AAABAAAAAA
BABAAAAAAA
AAABAAAAAA
BABBBBBAAA
BABBBBBAAA
BABAAAAAAA
BABAAAAAAA
AABBAAABAA
AABBAAABAA
AAABAAAAAA
AAABAAAAAA
AAABAAAAA...

output:

886

result:

ok 1 number(s): "886"

Test #6:

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

input:

5000 10 10507302
BBBAABAAAB
BBBAABAAAB
ABAABAAAAA
BBBABBAAAA
ABBABABBAB
ABBABABBAB
BBBABBAAAA
BBBABBAAAA
AABAABBABA
ABBABAAABB
ABBABAAABB
ABAABAAAAA
BBABBABBAB
BAABBAABAA
BAABBBAAAA
BABBBABAAB
ABBABAAABB
BAABBAABAA
BBABBABBAB
BBABBABBAB
ABAABAAAAA
ABBABABBAB
ABAABAAAAA
ABBABAAABB
AABAABBABA
BBABBABB...

output:

755

result:

ok 1 number(s): "755"

Test #7:

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

input:

5000 10 10810288
BBBAAABBBB
BBBBBAAAAB
BBBABAABBB
BBBBABBBBA
BBBBABBBBA
AAAAAABAAA
BBAAABBABB
AAABBABAAB
AAABBBAABB
ABBBBBABBA
ABABABBBBA
AABBABBBAA
AAABAABBAB
BBBAABBBAA
AAABAABBAA
BBAABBBAAA
ABBAABABBB
BBAABBBAAA
BAABBBBABA
BBBBBABABA
AABABABAAA
BABBBBBAAB
BBABBABAAB
AAABAABBAA
BBBBABBBBA
AAABAAAB...

output:

870

result:

ok 1 number(s): "870"

Test #8:

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

input:

5000 10 12280385
ABABAAABBA
ABBBBABBAB
AABBBBAABA
BBBABAABAA
AAAAABABAA
BBBBABAAAA
BBAAAABBBA
ABABBABAAB
ABABAABBAB
BAAABAAAAB
AAAABBBABA
BABBBAABAA
ABBBBBBAAB
ABBBABBABA
BBAABAABAA
ABABBBAABB
ABBBBBAAAB
BBBAABBAAB
BBBBBAABBB
BBBABAABAB
ABAAAAABBB
AAAAABABAA
BBAAAAABBA
BAAABBABAB
BABBBBBABA
ABAAABAB...

output:

141

result:

ok 1 number(s): "141"

Test #9:

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

input:

5000 10 12436636
ABABABAABB
ABAABAAABA
BBBBAAABAB
BABAAABAAB
BBABABAABB
ABAABAAABB
ABBAAAABAB
BAAAABBBBB
ABABAAAABB
BAABAAABBA
AAAAAAABAA
BAAABBABAB
BAAABBBABA
AAAABBBBAA
AABBBAABBA
BBBAAAABAB
BBBBAABBBB
AABABBBBBA
ABABBBAABB
BBAABBABBA
ABAABABABA
BBBBAAABAB
BBBBBAAAAA
AAABABAAAB
ABABAAAAAA
AABBABAB...

output:

28

result:

ok 1 number(s): "28"

Test #10:

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

input:

5000 10 9373047
ABABAAABBB
BABBAABABB
ABABAAAAAB
ABBBAAAABA
ABBBAABABB
AABBBBBABB
AAABAAABAB
ABAABBBBAB
ABAAAABAAB
BBABBBBBAA
AABAAAAABB
BAAAAAAABA
BAABBABBBB
BABAABABBB
ABBBAABABB
ABBAAAAABB
BABBBABBAB
ABAAABABAB
AABBBABAAA
AAABAAAAAB
AABBAABABB
BBBBAAAAAB
AAABBAABBA
ABABABABBB
AABBBBBBAB
AAABAAABB...

output:

999

result:

ok 1 number(s): "999"

Test #11:

score: 0
Accepted
time: 53ms
memory: 19792kb

input:

5000 20 12473302
AAAABBABAABBBABABBAB
ABAABAAAABAABBABBABA
ABBBAABABABABBBAAAAB
BBABABBBAAAAAAABABAA
BAABBBBAABBBBABABBBB
BABBBABBBAAABABAAABB
BAAAABAABBABAABBABBA
ABBAABAAABABABBABBBA
AABAABABAABAABAABBBA
BBBABABAABBAABAAAABA
BBBBBABAAABBBBBABBBB
BBAAAAAAAAABBABBBABA
ABBAAAABABAAAAABBBBB
BBAABBABAB...

output:

635417

result:

ok 1 number(s): "635417"

Test #12:

score: 0
Accepted
time: 52ms
memory: 19792kb

input:

5000 20 1
AAABABAABABBAABBBBAA
AAABABAABABBAABBBBAA
AAABABAABABBAABBBBAA
AAABABAABABBAABBBBAA
AAABABAABABBAABBBBAA
AAABABAABABBAABBBBAA
AAABABAABABBAABBBBAA
AAABABAABABBAABBBBAA
AAABABAABABBAABBBBAA
AAABABAABABBAABBBBAA
AAABABAABABBAABBBBAA
AAABABAABABBAABBBBAA
AAABABAABABBAABBBBAA
AAABABAABABBAABBB...

output:

0

result:

ok 1 number(s): "0"

Test #13:

score: 0
Accepted
time: 50ms
memory: 19852kb

input:

5000 20 9998760
ABABBAABBBABAAAABBAB
BBBABAABAABAAABAAAAA
BBBABAABAABAAABAAAAA
ABAAAAAAABAABAAABAAB
BBBABAABAABAAABAAAAA
ABAAAAAAABAABAAABAAB
BBBABAABAABAAABAAAAA
ABAAAAAAABAABAAABAAB
BBBABAABAABAAABAAAAA
BBBABAABAABAAABAAAAA
ABABBAABBBABAAAABBAB
ABBBBABBBAAAAAAAAABA
ABBBBABBBAAAAAAAAABA
BBBABAABAAB...

output:

1023376

result:

ok 1 number(s): "1023376"

Test #14:

score: 0
Accepted
time: 57ms
memory: 19836kb

input:

5000 20 11247826
BBAAABBABBABAABABAAA
BAABABBAABBBBAAAABBA
AAAAABABAAABAABAABBA
BBBBBABAAABABBBBAAAA
BBBBBABBBABABABBBABA
BBBBBABBBABABABBBABA
BABBAAABBBBAABABAABA
AABBAAABABABAABBBBBA
BBAAABBABBABAABABAAA
BBBABBBAABABBBAAAABB
BAABABAAAABBBABBBBAA
BBBABBBAABABBBAAAABB
BAABABBAABBBBAAAABBA
AABBAAABAB...

output:

929006

result:

ok 1 number(s): "929006"

Test #15:

score: 0
Accepted
time: 55ms
memory: 19816kb

input:

5000 20 12248582
ABABABABABBBAABAAABA
BBBABABABBABBBBBAABA
BAAAAAAABABBBBBBBABB
BAAABAAAAAAAABAABABB
BAABBBAABBABABBBBAAB
BBAABABBBAABBBAAABAA
BABABBABABBBABABABAB
BBBBABBBBAABABBAAAAA
ABBBBBBBBABBABBBBAAB
AABBBBBABBBABBBAAAAA
ABABAAABABBBAABAABBA
BBABABAAABBABAAABABA
BBBBBAABBABBBBBBAAAB
AAABAAABBA...

output:

342770

result:

ok 1 number(s): "342770"

Test #16:

score: 0
Accepted
time: 60ms
memory: 19952kb

input:

5000 20 12315136
ABBBABABBABBAABBBAAA
BAAAABAABAABAABBABAA
BBBABBBBABBBBABBBBAB
AAABAABBAAAABBAAABAB
AABBABBBBAAAABABAAAA
BBABBBBAAABBBBAAABBB
ABAAABAABAAAABABBBAA
BABBBBBABABAAABAABAB
AAABAABABBABBAAAAAAB
ABABBABBAABBBAAABABA
BAABBAAABBBAABABBBAA
BAABBBAAAAAABABBBAAB
AAABABBAAABABBBABBBA
AAABAABBAA...

output:

891051

result:

ok 1 number(s): "891051"

Test #17:

score: 0
Accepted
time: 51ms
memory: 19876kb

input:

5000 20 12460867
AABBABBAAABABABABABA
ABAABBBABAAAABAABABB
ABAABAAABAABABAABAAA
AABABBABBAABABBAABBB
BAABBAABABBABBABBBBA
BBBABABAAABBBAABBABA
BABABBAABBABAAAABABB
BABBBABBBBAABAABBABA
BABABBABAAABBAABABAA
AABAABBBABBAABBABABB
AABBBABBBBABABBAAAAA
BBBBBABBBABBBBBAABBA
ABABAABBAAAAAABAAABB
AABBBABAAA...

output:

487621

result:

ok 1 number(s): "487621"

Test #18:

score: 0
Accepted
time: 53ms
memory: 19880kb

input:

5000 20 12482845
BBBBAABABBBAAAAAABBA
BBBAAAABBABBABBAABAA
BABABBBBBAAAAABBBAAB
AABAAABABAAABBAAABAA
AAAAABAABAAABBAAABBA
ABBBAAABAAAAAAAAAAAB
ABABBABABABBBAAAAAAB
BBABBABABBBAABBBABBA
BBAAABBAAABABBBBAABB
ABBAABABAABBAABABABA
BBBAABABABBBBBABAABA
AABAAAAAAAAABAAABBBA
BAAAABABBBABAAAABABA
BAAAAABBBA...

output:

148743

result:

ok 1 number(s): "148743"

Test #19:

score: 0
Accepted
time: 55ms
memory: 19864kb

input:

5000 20 12302677
BBAABBBAAAAABAAAAAAB
AABBBAAAAABAAABBAAAB
AABABAABBBAAAABAAABB
BBBBBABAABAAAAAABBBA
AABBAAAAABBAABABABBB
BBAABAAABABBBBBAABAB
BBAAABAAABBBBBAABBBA
BBABBAABAABBABBABBAA
ABABBABABBBAAABBBBBB
BAABBAABBBAABBBAAABB
ABBBBAABBABBBAAABBBA
AAABABAAAAAAABBBAABB
AAAABBBBAABBBBABBBAA
AAABBBAAAA...

output:

993237

result:

ok 1 number(s): "993237"

Test #20:

score: -100
Wrong Answer
time: 4ms
memory: 9388kb

input:

200000 1 9999998911
A
B
B
A
B
B
A
A
A
B
B
B
B
B
A
B
B
A
B
B
A
A
A
A
B
B
A
A
A
B
A
B
B
A
A
B
B
B
A
A
A
B
A
A
A
B
A
A
B
A
B
B
B
A
A
B
B
B
A
B
B
A
A
B
B
A
B
B
B
A
A
B
B
A
B
A
A
B
A
A
A
B
A
B
B
B
A
B
A
B
B
B
B
A
A
B
A
B
B
B
A
B
A
A
B
B
B
B
B
A
A
B
B
A
A
B
A
B
A
B
A
B
B
A
B
B
A
A
B
B
B
A
B
A
A
B
B
B
B
B
...

output:

0

result:

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