이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
// Sample grader for contestants' use.
//
// Usage: place your input data in the file password.in in the format
//
// line 1: N S
// line 2: hidden_password
//
// Then compile this grader together with your implementation.
// Run the binary to see your guessing strategy at work!
// Set DEBUG to 1 to print all queries.
#include <bits/stdc++.h>
using namespace std;
int query(string q);
#define fi first
#define se second
#define pb push_back
#define mp make_pair
/*
map<string,int> ma;
int qry(string q){
if(ma.find(q)!=ma.end())return ma[q];
return ma[q]=query(q);
}
*/
string join(string a,string b){
int la=a.length(),lb=b.length();
string ans=a;
int idx=0;
for(int i=0;i<lb;i++){
string q="";
for(int j=0;j<idx;j++)q.pb(ans[j]);
q.pb(b[i]);
for(int j=idx;j<(int)ans.size();j++)q.pb(ans[j]);
while(query(q)!=(int)q.size()){
swap(q[idx],q[idx+1]);
idx++;
}
ans=q;idx++;
}
return ans;
}
string guess(int n, int s){
priority_queue<pair<int,string>,vector<pair<int,string> >,greater<pair<int,string> > > pq;
int occ[26];
int sum=0;
for(int i=0;i<s-1;i++){
string q="";
for(int j=0;j<n;j++)q.pb(i+'a');
occ[i]=query(q);
q="";
for(int j=0;j<occ[i];j++)q.pb(i+'a');
if(occ[i]>0)pq.push(mp(occ[i],q));
sum+=occ[i];
}
occ[s-1]=n-sum;
string q="";for(int j=0;j<occ[s-1];j++)q.pb(s-1+'a');if(occ[s-1]>0)pq.push(mp(occ[s-1],q));
while((int)pq.size()>1){
pair<int,string> cur1=pq.top();pq.pop();
pair<int,string> cur2=pq.top();pq.pop();
pq.push(mp(cur1.fi+cur2.fi,join(cur1.se,cur2.se)));
}
return pq.top().se;
}
컴파일 시 표준 에러 (stderr) 메시지
password.cpp: In function 'std::__cxx11::string join(std::__cxx11::string, std::__cxx11::string)':
password.cpp:28:6: warning: unused variable 'la' [-Wunused-variable]
int la=a.length(),lb=b.length();
^~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |