답안 #709081

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
709081 2023-03-13T06:00:48 Z zaneyu Password (RMI18_password) C++17
컴파일 오류
0 ms 0 KB
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using pii=pair<int,int>;
#define f first
#define s second
#define pb push_back
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define FILL(n,x) memset(n,x,sizeof(n))
#define ALL(_a) _a.begin(),_a.end()
#define sz(x) (int)x.size()
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()),c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
const ll maxn=500+5;
const ll maxlg=__lg(maxn)+2;
const ll INF64=4e18;
const int INF=0x3f3f3f3f;
const ll MOD=1e8+7;
const ld PI=acos(-1);
const ld eps=1e-4;
#define lowb(x) x&(-x)
#define MNTO(x,y) x=min(x,(__typeof__(x))y)
#define MXTO(x,y) x=max(x,(__typeof__(x))y)
namespace {
int n,s;
}
string rec(string pf,string sf,int cur){
	bool hv=0;
	for(int i=cur;i<s;i++){
		string z=pf;
		z.pb(i+'a');
		z+=sf;
		if(query(z)!=sz(pf)){
			hv=1;
			cur=i;
			break;
		}
	}
	if(!hv) return "";
	int a=1,b=n-sz(pf)-sz(sf);
	while(a<b){
		int m=(a+b+1)/2;
		string z=pf;
		REP(j,m) z.pb(cur+'a');
		z+=sf;
		if(query(z)==sz(z)) a=m;
		else b=m-1;
	}
	string ans="";
	REP(x,a){
		string z;
		REP(y,a-x+1) z.pb(cur+'a');
		z+=sf;
		string tmp=rec(pf+ans,z,cur+1);
		ans+=tmp;
		ans.pb(cur+'a');
	}
	return ans;
}
string guess(int N, int S){
	n=N,s=S;
	return rec("","",0);
}

Compilation message

password.cpp: In function 'std::string rec(std::string, std::string, int)':
password.cpp:34:6: error: 'query' was not declared in this scope
   34 |   if(query(z)!=sz(pf)){
      |      ^~~~~
password.cpp:47:6: error: 'query' was not declared in this scope
   47 |   if(query(z)==sz(z)) a=m;
      |      ^~~~~