제출 #1156778

#제출 시각아이디문제언어결과실행 시간메모리
1156778SmuggingSpunPassword (RMI18_password)C++20
컴파일 에러
0 ms0 KiB
#include<bits/stdc++.h>
using namespace std;
string guess(int n, int s){
	if(n <= s || (n <= 100 && s <= 4)){
		string ans = "";
		for(int i = 0, bef = 0; i < n; i++){
			for(int j = 0; j <= i; j++){
				for(int k = 0; k < s; k++){
					string candidate = ans.substr(0, j) + char('a' + k) + ans.substr(j, i - j);
					if(query(ans.substr(0, j) + char('a' + k) + ans.substr(j, i - j)) == bef + 1){
						bef++;
						swap(ans, candidate);
						j = i;
						break;
					} 
				}
			}
		}
		return ans;
	}
}

컴파일 시 표준 에러 (stderr) 메시지

password.cpp: In function 'std::string guess(int, int)':
password.cpp:10:44: error: 'query' was not declared in this scope
   10 |                                         if(query(ans.substr(0, j) + char('a' + k) + ans.substr(j, i - j)) == bef + 1){
      |                                            ^~~~~
password.cpp:21:1: warning: control reaches end of non-void function [-Wreturn-type]
   21 | }
      | ^