QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#550102#2481. PickpocketsXfJbUhpyzgaW#WA 2ms8252kbC++141.4kb2024-09-07 09:46:492024-09-07 09:46:50

Judging History

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

  • [2024-09-07 09:46:50]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:8252kb
  • [2024-09-07 09:46:49]
  • 提交

answer

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

const int N = 100100;
using ll = long long;

int n, p, m, k;
char str[N];

int value[28];

vector<ll> dp[N];
vector<int> col[N];
ll pw[N];

int merge(int x, int y) {
    if (x == 26 || y == 26) return x ^ y ^ 26;
    if (x == y) return x;
    return 27;
}

int main() {
    cin >> n >> str >> k;
    for (int i = 0; i < k; i++) {
        string ch;
        int val;
        cin >> ch >> val;
        value[ch[0] - 'A'] = val;
        value[26] = max(value[26], value[i]);
    }
    for (int i = 2; i <= n; i++) if (n % i == 0) { p = i; break; }

    for (int x = 1; x <= n; x *= p)
        pw[m++] = x;
    m--;

    for (int i = 0; i <= m; i++) {
        dp[i].resize(pw[i]);
        col[i].resize(pw[i]);
    }

    for (int i = 0; i < n; i++) {
        col[m][i] = (str[i] == '?' ? 26 : str[i] - 'A');
        dp[m][i] = value[col[m][i]];
    }
    
    for (int i = m - 1; i >= 0; i--) {
        for (int j = 0; j < pw[i]; j++) {
            col[i][j] = 26, dp[i][j] = 0;
            for (int k = 0; k < pw[i + 1]; k += pw[i]) {
                col[i][j] = merge(col[i][j], col[i + 1][j + k]);
                dp[i][j] += dp[i + 1][j + k];
            }
            dp[i][j] = max(dp[i][j], value[col[i][j]] * pw[m - i] * (m - i + 1));
        }
    }

    cout << dp[0][0] << "\n";
}

详细

Test #1:

score: 0
Wrong Answer
time: 2ms
memory: 8252kb

input:

2 2
1 2
1 5
2 5

output:

1

result:

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