QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#168227#2476. Pizzo CollectorsLaStataleBlue#WA 1ms3560kbC++201.6kb2023-09-08 00:04:532023-09-08 00:04:55

Judging History

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

  • [2023-09-08 00:04:55]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3560kb
  • [2023-09-08 00:04:53]
  • 提交

answer

#pragma ide diagnostic ignored "misc-no-recursion"

#include "bits/stdc++.h"

using namespace std;
typedef long long ll;
typedef double db;

#define TESTCASE 0

static constexpr ll INF = 1e11;

static array<ll, 27> f(int d, int o, int p, const string &S, const array<ll, 27> &V) {
    if (d == S.size()) {
        if (S[o] == '?') return V;

        array<ll, 27> res{};
        res.fill(-INF);
        res[S[o] - 'A'] = V[S[o] - 'A'];
        return res;
    }

    array<ll, 27> res{};
    for (int i = 0; i < 26; i++) {
        res[i] += V[i] * (ll)S.size() / d;
    }
    for (int i = 0; i < p; i++) {
        auto rec = f(p * d, o + d * i, p, S, V);
        for (int j = 0; j < 27; j++) {
            res[j] += rec[j];
        }
    }

    res.back() = *max_element(res.begin(), res.end());
    return res;
}

static void solve([[maybe_unused]] int tc) {
    int N, K;
    string S;
    cin >> N >> S >> K;

    array<ll, 27> V{};
    V.fill(-INF);

    for (int i = 0; i < K; i++) {
        char c;
        int x;
        cin >> c >> x;
        V[c - 'A'] = x;
    }

    V.back() = *max_element(V.begin(), V.end());

    int p = N;
    for (int i = 2; i < N; i++) {
        if (N % i == 0) {
            p = i;
            break;
        }
    }

    cout << f(1, 0, p, S, V).back() << endl;
}

int main() {
    ios::sync_with_stdio(false);

    if (const char *f = getenv("REDIRECT_STDOUT"); f) {
        freopen(f, "w", stdout);
    }

    int T = 1;
#if TESTCASE
    cin >> T;
#endif

    for (int t = 1; t <= T; t++) {
        solve(t);
    }

    return 0;
}

詳細信息

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 3560kb

input:

8
?A?B?A?C
3
A 1
B 1000
C 100000

output:

-99998499996

result:

wrong answer 1st lines differ - expected: '1301004', found: '-99998499996'