# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
722068 | nguyentunglam | Password (RMI18_password) | C++17 | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
const int N = 5010;
int cnt[N];
char a[N], b[N];
int query(string q)
string guess(int n, int s) {
vector<pair<int, char> > lst;
for(int j = 0; j < s; j++) {
char c = j + 'a';
string ask;
for(int i = 1; i <= n; i++) ask.push_back(c);
lst.emplace_back(query(ask), c);
}
sort(lst.begin(), lst.end());
int m; char c;
tie(m, c) = lst[0];
for(int i = 1; i <= m; i++) a[i] = c;
lst.erase(lst.begin());
for(auto &it : lst) {
int num; char c;
tie(num, c) = it;
for(int i = 0; i <= m; i++) {
string ask;
for(int j = 1; j <= i; j++) ask.push_back(a[j]);
cnt[i] = 0;
while (num > 0) {
ask.push_back(c);
string tmp;
for(int j = i + 1; j <= m; j++) tmp.push_back(a[j]);
if (query(ask + tmp) > m + cnt[i]) cnt[i]++, num--;
else break;
}
}
int m2 = 0;
for(int i = 0; i <= m; i++) {
if (i) b[++m2] = a[i];
while (cnt[i]--) b[++m2] = c;
}
for(int i = 1; i <= m2; i++) a[i] = b[i];
m = m2;
}
string ret;
for(int i = 1; i <= m; i++) ret.push_back(a[i]);
return ret;
}