QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#191365#7531. Hacking the ProjectDays_of_Future_Past#WA 0ms3788kbC++141.6kb2023-09-29 22:14:312023-09-29 22:14:32

Judging History

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

  • [2023-09-29 22:14:32]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3788kb
  • [2023-09-29 22:14:31]
  • 提交

answer

#include <bits/stdc++.h>
#define SZ(c) ((int)(c).size())

using namespace std;

const int N = 1111;
const int INF = 1e9;

typedef pair<int, int> pii;

int dp[N][N];

void build() {
  for (int len = 2; len < N; ++len)
    for (int i = 0; i < N; ++i) {
      int r = i + len - 1;
      if (r >= N)
        break;
      dp[i][r] = INF;
      for (int m = i + 1; m <= r; ++m)
        dp[i][r] = min(dp[i][r], m + max(dp[i][m - 1], dp[m][r]));
    }
  printf("%d\n", dp[0][1000]);
}

vector<string> query(char c, int k) {
  static char buf[111];
  printf("%c %d\n", c, k);
  fflush(stdout);
  vector<string> res;
  int real_k;
  scanf("%d", &real_k);
  for (int i = 0; i < real_k; ++i) {
    scanf("%s", buf);
    res.push_back(buf);
  }
  return res;
}

void answer(const vector<string> &ss) {
  printf("answer");
  for (int i = 0; i < SZ(ss); ++i)
    printf(" %s", ss[i].c_str());
  printf("\n");
  fflush(stdout);
}

int n;

vector<string> ans[33];

void main2() {
  scanf("%d", &n);
  for (int c = 0; c < 26; ++c)
    ans[c].clear();
  int remaining = n;
  for (int c = 0; c < 26; ++c) {
    int guess = 1;
    while (guess <= remaining) {
      ans[c] = query('a' + c, guess);
      if (SZ(ans[c]) < guess || SZ(ans[c]) == remaining) {
        break;
      } else {
        guess = min(guess * 2, remaining);
      }
    }
    remaining -= SZ(ans[c]);
  }
  vector<string> all_ans;
  for (int c = 0; c < 26; ++c)
    for (auto s: ans[c])
      all_ans.push_back(s);
  answer(all_ans);
}

int main() {
  //build();
  int tc;
  scanf("%d", &tc);
  while (tc--) {
    main2();
  }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3788kb

input:

1
4

output:

a 1

result:

wrong answer Invalid query 'a'