QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#706640#8776. Not Another Constructive!hejinming983282#Compile Error//C++142.4kb2024-11-03 12:45:122024-11-03 12:45:14

Judging History

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

  • [2024-11-03 12:45:14]
  • 评测
  • [2024-11-03 12:45:12]
  • 提交

answer

// Author : hejinming2012
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define dbg(x) cout << #x " = " << (x) << endl
#define quickio ios::sync_with_stdio(false);
#define quickin cin.tie(0);
#define quickout cout.tie(0);
#define K 2500
using namespace std;
inline int read() {
    int now = 0, nev = 1; char c = getchar();
    while(c < '0' || c > '9') { if(c == '-') nev = -1; c = getchar(); }
    while(c >= '0' && c <= '9') { now = (now << 1) + (now << 3) + (c & 15); c = getchar(); }
    return now * nev;
}
void write(int x) {
    if(x < 0) putchar('-'), x = -x;
    if(x > 9) write(x / 10);
    putchar(x % 10 + '0');
}

signed main() {
    quickio
    quickin
    quickout
    int n, k; cin >> n >> k;
    string s; cin >> s;
    vector dp(n + 1, vector (n + 1, vector (n + 1, bitset < K + 1 > {})));
    for(int i = 0; i <= n; i++)
        dp[0][0][i][0] = 1;
    for(int i = 0; i < n; i++) {
        if(s[i] == '?' || s[i] == 'N') {
            for(int N = 0; N <= i; N++)
                for(int C = 0; C <= n - i; C++)
                    dp[i + 1][N + 1][C] |= dp[i][N][C];
        }
        if(s[i] == '?' || s[i] == 'A') {
            for(int N = 0; N <= i; N++)
                for(int C = 0; C <= n - i; C++)
                    dp[i + 1][N][C] |= dp[i][N][C] << (N * C);
        }
        if(s[i] == '?' || s[i] == 'C') {
            for(int N = 0; N <= i; N++)
                for(int C = 1; C <= n - i; C++)
                    dp[i + 1][N][C - 1] |= dp[i][N][C];
        }
        if(s[i] == '?' || s[i] != 'N' && s[i] != 'A' && s[i] != 'C') {
            for(int N = 0; N <= i; N++)
                for(int C = 0; C <= n - i; C++)
                    dp[i + 1][N][C] |= dp[i][N][C];
        }
    }
    int N = -1;
    for(int i = 0; i <= n; i++)
        if(dp[n][i][0][k]) N = i;
    if(N == -1) {
        cout << -1 << endl;
        return 0;
    }
    int C = 0;
    for(int i = n - 1; i >= 0; i--)
        if((s[i] == '?' || s[i] == 'N' && n > 0 && dp[i][N - 1][C][k]))
            s[i] = 'N', N--;
        else if((s[i] == '?' || s[i] == 'A') && k >= N * C && dp[i][N][C][k - N * C])
            s[i] = 'A', k -= N * C;
        else if((s[i] == '?' || s[i] == 'C') && dp[i][N][C + 1][k])
            s[i] == 'C', C++;
        else if(s[i] == '?') s[i] = 'B';
    cout << s << endl;
    return 0;
}

Details

answer.code: In function ‘int main()’:
answer.code:29:12: error: missing template arguments before ‘dp’
   29 |     vector dp(n + 1, vector (n + 1, vector (n + 1, bitset < K + 1 > {})));
      |            ^~
answer.code:29:71: error: expected primary-expression before ‘)’ token
   29 |     vector dp(n + 1, vector (n + 1, vector (n + 1, bitset < K + 1 > {})));
      |                                                                       ^
answer.code:31:9: error: ‘dp’ was not declared in this scope
   31 |         dp[0][0][i][0] = 1;
      |         ^~
answer.code:36:21: error: ‘dp’ was not declared in this scope
   36 |                     dp[i + 1][N + 1][C] |= dp[i][N][C];
      |                     ^~
answer.code:41:21: error: ‘dp’ was not declared in this scope
   41 |                     dp[i + 1][N][C] |= dp[i][N][C] << (N * C);
      |                     ^~
answer.code:46:21: error: ‘dp’ was not declared in this scope
   46 |                     dp[i + 1][N][C - 1] |= dp[i][N][C];
      |                     ^~
answer.code:51:21: error: ‘dp’ was not declared in this scope
   51 |                     dp[i + 1][N][C] |= dp[i][N][C];
      |                     ^~
answer.code:56:12: error: ‘dp’ was not declared in this scope
   56 |         if(dp[n][i][0][k]) N = i;
      |            ^~
answer.code:63:52: error: ‘dp’ was not declared in this scope
   63 |         if((s[i] == '?' || s[i] == 'N' && n > 0 && dp[i][N - 1][C][k]))
      |                                                    ^~