답안 #433910

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
433910 2021-06-20T12:09:31 Z AmineTrabelsi Password (RMI18_password) C++14
컴파일 오류
0 ms 0 KB
#include "bits/stdc++.h"
using namespace std;
// Hi 
//int query(string s);

string guess(int n,int s){
    string res = "";
    for(int i=0;i<n;i++){
        bool found = 0;
        for(int c=0;c<s;c++){
            char ch = 'a'+c;
            //cout << i<<" first "<<ch+res<<'\n';
            int pref = query((ch+res));
            if(pref == i+1){
                res = ch+res;
                found = 1;
                break;
            }
        }
        if(found)continue;
        for(int ind=0;ind<i;ind++){
            for(int c=0;c<s;c++){
                char ch = 'a'+c;
                string temp = res.substr(0,ind+1)+ch+res.substr(ind+1,n-ind-1);
                //cout << i<<" "<<ind<<" "<<temp <<'\n';
                int pref = query((temp));
                if(pref == i+1){
                    res = temp;
                    found = 1;
                    break;
                }
            }
            if(found)break;
        }
    }
    return res;
}

Compilation message

password.cpp: In function 'std::string guess(int, int)':
password.cpp:13:24: error: 'query' was not declared in this scope
   13 |             int pref = query((ch+res));
      |                        ^~~~~
password.cpp:26:28: error: 'query' was not declared in this scope
   26 |                 int pref = query((temp));
      |                            ^~~~~