# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
251368 | dwsc | Password (RMI18_password) | C++14 | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
vector<string> mergevector(vector<string> v){
vector<string> newvector;
for (int i = 0; i < v.size(); i+= 2){
if (i == v.size()-1){
newvector.push_back(v[i]);
break;
}
string s1 = v[i],s2 = v[i+1];
//cout << s1 << " " << s2 << "hi\n";
string newstring = s1;
int insertionpos = 0;
int curpos = 0;
while (curpos < s2.length()){
string temp = "";
for (int j = 0; j < newstring.length(); j++){
if (j == insertionpos) temp += s2[curpos];
temp += newstring[j];
}
if (insertionpos == newstring.length()) temp += s2[curpos];
if (query(temp) == temp.size()){
newstring = temp;
curpos++;
insertionpos++;
}
else{
insertionpos++;
}
}
//cout << newstring << "\n";
newvector.push_back(newstring);
}
return newvector;
}
string guess(int n, int s){
vector<string> letters;
for (int i = 0; i < s; i++){
int ans = 0;
char c = (char)(i+97);
string act = "";
for (int j = 1; j <= n; j++){
string temp = act+c;
if (query(temp) == ans) break;
act = temp;
ans++;
}
//cout << act << "\n";
if (ans) letters.push_back(act);
}
while (letters.size() > 1)letters = mergevector(letters);
return letters[0];
}