QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#602082#8776. Not Another Constructive!ucup-team3691Compile Error//C++142.6kb2024-09-30 19:05:532024-09-30 19:05:53

Judging History

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

  • [2024-09-30 19:05:53]
  • 评测
  • [2024-09-30 19:05:53]
  • 提交

answer

#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <deque>
#include <set>
#include <map>
#include <unordered_map>
#include <cassert>
#include <algorithm>
#include <cmath>
#include <random>
#include <ctime>
#include <cstdlib>
#include <chrono>

using namespace std;

void solve() {
  int n, k;
  cin >> n >> k;

  string s;
  cin >> s;

  vector<vector<vector<bitset<2500>>>> dp(n + 1, (vector<vector<bitset<2500>>> (n + 1, vector<bitset<2500>>(n + 1))));

  int tc = count(s.begin(), s.end(), 'C'); 
  int tf = count(s.begin(), s.end(), '?'); 

  for (int i = tc; i <= tc + tf; ++i) {
    dp[0][0][i] = 1;
  }

  s = " " + s;
  for (int i = 1; i <= n; ++i) {
    bool nac = false;
    if (s[i] == 'C' || s[i] == '?') {
      nac = true;
      for (int nn = 0; nn <= i; ++nn) {
        for (int nc = 0; nc <= n - i; ++nc) {
          dp[i][nn][nc] |= dp[i - 1][nn][nc + 1];
        }
      }
    }

    if (s[i] == 'N' || s[i] == '?') {
      nac = true;
      for (int nn = 0; nn < i; ++nn) {
        for (int nc = 0; nc <= n - i; ++nc) {
          dp[i][nn + 1][nc] |= dp[i - 1][nn][nc];
        }
      }
    }

    if (s[i] == 'A' || s[i] == '?') {
      for (int nn = 0; nn <= i; ++nn) {
        for (int nc = 0; nc <= n - i; ++nc) {
          dp[i][nn][nc] |= dp[i - 1][nn][nc] << (nn * nc);
        }
      }
    }

    if (!nac || s[i] == '?') {
      for (int nn = 0; nn <= i; ++nn) {
        for (int nc = 0; nc <= n - i; ++nc) {
          dp[i][nn][nc] |= dp[i - 1][nn][nc];
        }
      }
    }
  }

  string ans;
  for (int nn = 0; nn <= n; ++nn) {
    if (dp[n][nn][0].test(k)) {
      int i = n;
      int nc = 0;

      while (i > 0) {
        char ch;
        if (s[i] == 'N' || (s[i] == '?' && nn > 0 && dp[i - 1][nn - 1][nc].test(k))) {
          ch = 'N';
          nn -= 1;
        } else if (s[i] == 'C' || (s[i] == '?' && nc + 1 <= n && dp[i - 1][nn][nc + 1].test(k))) {
          ch = 'C';
          nc += 1;
        } else if (s[i] == 'A' || (s[i] == '?' && nn * nc <= k && dp[i - 1][nn][nc].test(k - nn * nc))) {
          ch = 'A';
          k -= nn * nc;
        } else {
          ch = s[i];
          if (s[i] == '?')
            s[i] = 'X';
        }
         
        ans.push_back(ch);
        --i;
      }
      reverse(ans.begin(), ans.end());
      cout << ans << "\n";
      return;
    }
  }


  cout << "-1\n";
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);

  int t = 1;
  while (t--)
    solve();

  return 0;
}

Details

answer.code: In function ‘void solve()’:
answer.code:26:24: error: ‘bitset’ was not declared in this scope
   26 |   vector<vector<vector<bitset<2500>>>> dp(n + 1, (vector<vector<bitset<2500>>> (n + 1, vector<bitset<2500>>(n + 1))));
      |                        ^~~~~~
answer.code:16:1: note: ‘std::bitset’ is defined in header ‘<bitset>’; did you forget to ‘#include <bitset>’?
   15 | #include <chrono>
  +++ |+#include <bitset>
   16 | 
answer.code:26:31: error: template argument 1 is invalid
   26 |   vector<vector<vector<bitset<2500>>>> dp(n + 1, (vector<vector<bitset<2500>>> (n + 1, vector<bitset<2500>>(n + 1))));
      |                               ^~~~
answer.code:26:31: error: template argument 2 is invalid
answer.code:26:35: error: template argument 1 is invalid
   26 |   vector<vector<vector<bitset<2500>>>> dp(n + 1, (vector<vector<bitset<2500>>> (n + 1, vector<bitset<2500>>(n + 1))));
      |                                   ^~
answer.code:26:35: error: template argument 2 is invalid
answer.code:26:10: error: template argument 1 is invalid
   26 |   vector<vector<vector<bitset<2500>>>> dp(n + 1, (vector<vector<bitset<2500>>> (n + 1, vector<bitset<2500>>(n + 1))));
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~
answer.code:26:10: error: template argument 2 is invalid
answer.code:26:37: error: expected unqualified-id before ‘>’ token
   26 |   vector<vector<vector<bitset<2500>>>> dp(n + 1, (vector<vector<bitset<2500>>> (n + 1, vector<bitset<2500>>(n + 1))));
      |                                     ^~
answer.code:32:5: error: ‘dp’ was not declared in this scope
   32 |     dp[0][0][i] = 1;
      |     ^~
answer.code:42:11: error: ‘dp’ was not declared in this scope
   42 |           dp[i][nn][nc] |= dp[i - 1][nn][nc + 1];
      |           ^~
answer.code:51:11: error: ‘dp’ was not declared in this scope
   51 |           dp[i][nn + 1][nc] |= dp[i - 1][nn][nc];
      |           ^~
answer.code:59:11: error: ‘dp’ was not declared in this scope
   59 |           dp[i][nn][nc] |= dp[i - 1][nn][nc] << (nn * nc);
      |           ^~
answer.code:67:11: error: ‘dp’ was not declared in this scope
   67 |           dp[i][nn][nc] |= dp[i - 1][nn][nc];
      |           ^~
answer.code:75:9: error: ‘dp’ was not declared in this scope
   75 |     if (dp[n][nn][0].test(k)) {
      |         ^~