답안 #709141

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
709141 2023-03-13T06:41:03 Z salmon Password (RMI18_password) C++14
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;

//int query(string str);

string guess(int N, int S){
    string aas = "";

    for(int i = 1; i <= N - 30; i++){
        int s = 'a';
        int e = 'a' + S - 1;

        while(s != e){
            int m = (s + e)/2;

            string temp = aas;

            for(int i = s; i <= m; i++){
                temp.push_back(s);
            }

            if(query(temp) >= i){
                e = m;
            }
            else{
                s = m + 1;
            }
        }

        aas.push_back(s);
    }

    for(int i = max(1,N - 29); i <= N; i++){

        int s = 'a';
        int e = 'a' + S - 1;

        for(char j = s; j <= e; j++){
            aas.push_back(j);
            if(query(aas) == i){
                break;
            }
            else{
                aas.pop_back();
            }
        }
    }

    return aas;

}

Compilation message

password.cpp: In function 'std::string guess(int, int)':
password.cpp:22:16: error: 'query' was not declared in this scope
   22 |             if(query(temp) >= i){
      |                ^~~~~
password.cpp:40:16: error: 'query' was not declared in this scope
   40 |             if(query(aas) == i){
      |                ^~~~~