QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#346437#8330. Count off 3ucup-team055#WA 484ms11692kbC++232.2kb2024-03-08 15:14:292024-03-08 15:14:30

Judging History

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

  • [2024-04-17 10:54:24]
  • hack成功,自动添加数据
  • (/hack/598)
  • [2024-04-16 16:08:54]
  • hack成功,自动添加数据
  • (/hack/597)
  • [2024-03-10 15:17:34]
  • hack成功,自动添加数据
  • (/hack/559)
  • [2024-03-08 15:14:30]
  • 评测
  • 测评结果:WA
  • 用时:484ms
  • 内存:11692kb
  • [2024-03-08 15:14:29]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = LLONG_MAX / 4;
#define rep(i, a, b) for(ll i = a; i < b; i++)
#define all(a) begin(a), end(a)
ll sz(auto& a) { return size(a); }
template<class T> bool chmin(T& a, T b) { if(a <= b) return 0; a = b; return 1; }
template<class T> bool chmax(T& a, T b) { if(a >= b) return 0; a = b; return 1; }

ll solve() {
    string S;
    cin >> S;
    ranges::reverse(S);
    for(char& c : S) c -= '0';
    const ll N = sz(S);
    if(S[0] == 0) {
        rep(i, 0, N) {
            if(S[i] == 1) {
                S[i]--;
                break;
            }
            else S[i]++;
        }
    }
    vector<ll> dp(1 << 19);
    dp[0] = 1;
    for(ll i = N; --i; ) {
        vector<ll> dp2(1 << 19);
        rep(bit, 0, 1 << 19) if(const ll x = dp[bit]; x) {
            { // add 0
                ll bit2 = bit;
                if(S[i] == 1) bit2 |= 1 << 18;
                dp2[bit2] += x;
            }
            if(bit & 1 << 18 || S[i] == 1) { // add 1
                ll bit2 = bit;
                const ll one = 1 << (i % 6 * 3), mask = 7 << (i % 6 * 3);
                bit2 += one;
                if((bit2 & mask) == mask) bit2 &= ~mask;
                dp2[bit2] += x;
            }
        }
        dp.swap(dp2);
    }

    {
        vector<ll> dp2(1 << 18);
        rep(bit, 0, 1 << 19) if(const ll x = dp[bit]; x) {
            { // add 1
                ll bit2 = bit & 0x3ffff;
                const ll one = 1, mask = 7;
                bit2 += one;
                if((bit2 & mask) == mask) bit2 &= ~mask;
                dp2[bit2] += x;
            }
        }
        dp.swap(dp2);
    }

    ll ans = 0;
    rep(bit, 0, 1 << 18) if(const ll x = dp[bit]; x) {
        vector<ll> X(6);
        rep(i, 0, 6) X[i] = (bit >> i * 3) & 7;
        if([&]() -> bool {
            rep(b, 1, 7) {
                ll sum = 0;
                for(ll i = 6; i--; ) sum = sum * b + X[i];
                if(sum % 7 == 0) return 0;
            }
            return 1;
        }()) ans += x;
    }
    return ans;
}
int main() {
    cin.tie(0)->sync_with_stdio(0);
    ll T;
    cin >> T;
    while(T--) cout << solve() << endl;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 13ms
memory: 11644kb

input:

5
1
1010
110101
1000111000
101101001000

output:

1
2
15
114
514

result:

ok 5 number(s): "1 2 15 114 514"

Test #2:

score: -100
Wrong Answer
time: 484ms
memory: 11692kb

input:

10
1
11
1000
10111011
1000110100101001
11101110000001000011010011011000
110011000111110001101010101100100011010010101000011111001101011
11010111011101000010101111011111011011100001001101010011101011111111011011111101110110010011001101000001000111100010010111000010
10000000000000000000000000000000000...

output:

1
1
2
45
6591
814196699
1467268740463969238
-2827488843923170670
-7163393391649212495
-3477465543417323940

result:

wrong answer 7th numbers differ - expected: '193088128', found: '1467268740463969238'