답안 #755851

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
755851 2023-06-10T16:50:50 Z vjudge1 Password (RMI18_password) C++17
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include "C:\GCC\debug.h"
#else
#define debug(...) void(42)
#endif

string guess(int n, int s) {
  string endChars;

  vector<int> freq(s);
  for (int i = 0; i < s; i++) {
    string str;
    for (int it = 0; it < n; it++) {
      str += (i + 'a');
    }
    freq[i] = query(str);
    if (freq[i] == n) {
      return str;
    }
  }

  for (int pos = n - 1; pos >= 0; pos--) {
    for (int i = 0; i < s; i++) {
      string build;
      for (int it = 0; it < freq[i]; it++) {
        build += (i + 'a');
      }
      bool work = true;
      for (int j = 0; j < s; j++) {
        string tmp;
        tmp += build;
        tmp += (j + 'a');
        tmp += endChars;

        if (query(tmp) == (int) tmp.length()) {
          work = false;
          break;
        }
      }

      if (work) {
        endChars.insert(endChars.begin(), i + 'a');
        break;
      }
    }
  }
  return endChars;
}
/*

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
   
  return 0;
}
*/

Compilation message

password.cpp: In function 'std::string guess(int, int)':
password.cpp:20:15: error: 'query' was not declared in this scope
   20 |     freq[i] = query(str);
      |               ^~~~~
password.cpp:39:13: error: 'query' was not declared in this scope
   39 |         if (query(tmp) == (int) tmp.length()) {
      |             ^~~~~