답안 #859805

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
859805 2023-10-10T17:29:33 Z Andrei_Calota Password (RMI18_password) C++17
컴파일 오류
0 ms 0 KB
#include <iostream>

using namespace std;

/**int query (string candidate) {
   cout << candidate << "\n";
   int ret; cin >> ret;
   return ret;
}**/

int query (string str);

string getCopy (int letter, int f) {
    string ret = "";
    for (int i = 0; i < f; i ++)
       ret = ret + char (letter + 'a');
    return ret;
}


int freq[SIGMA_MAX];
string guess (int n, int s) {
    int N = n, SIGMA = s;
    string aux;
    for (int letter = 0; letter < SIGMA; letter ++) {
       aux = getCopy (letter, N);
       freq[letter] = query (aux);
    }

    string done = "";
    for (int pos = N - 1; pos >= 0; pos --) {
       int left = 0, right = 1;
       while (right < SIGMA) {
          if (freq[left] == 0) {
            left ++;
            right = max (right, left + 1);
            continue;
          }
          if (freq[right] == 0) {
            right ++;
            continue;
          }

          aux = getCopy (left, freq[left]);
          aux = aux + char (right + 'a');
          aux = aux + done;
          if (query (aux) == freq[left])
            right ++;
          else
            left ++, right ++;
       }
       done = char (left + 'a') + done;
       freq[left] --;
    }

    return done;
}

Compilation message

password.cpp:21:10: error: 'SIGMA_MAX' was not declared in this scope; did you mean 'SIZE_MAX'?
   21 | int freq[SIGMA_MAX];
      |          ^~~~~~~~~
      |          SIZE_MAX
password.cpp: In function 'std::string guess(int, int)':
password.cpp:27:8: error: 'freq' was not declared in this scope; did you mean 'free'?
   27 |        freq[letter] = query (aux);
      |        ^~~~
      |        free
password.cpp:34:15: error: 'freq' was not declared in this scope; did you mean 'free'?
   34 |           if (freq[left] == 0) {
      |               ^~~~
      |               free
password.cpp:39:15: error: 'freq' was not declared in this scope; did you mean 'free'?
   39 |           if (freq[right] == 0) {
      |               ^~~~
      |               free
password.cpp:44:32: error: 'freq' was not declared in this scope; did you mean 'free'?
   44 |           aux = getCopy (left, freq[left]);
      |                                ^~~~
      |                                free
password.cpp:53:8: error: 'freq' was not declared in this scope; did you mean 'free'?
   53 |        freq[left] --;
      |        ^~~~
      |        free