# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
723241 | 2023-04-13T12:20:42 Z | tvladm2009 | Password (RMI18_password) | C++14 | 0 ms | 0 KB |
#include <bits/stdc++.h> using namespace std; typedef long long ll; int N; string solve(int l, int r) { int mid = (l + r) / 2; if (l == r) { string qry = ""; for (int j = 1; j <= N; j++) { qry += char('a' + l); } int resp = query(qry); string answer = ""; for (int j = 1; j <= resp; j++) { answer += char('a' + l); } return answer; } string a = solve(l, mid); string b = solve(mid + 1, r); string answer = ""; int posA = 0, posB = 0; while (posA < (int) a.size()) { while (true) { string qry = answer; qry += a[posA]; for (int j = posB; j < (int) b.size(); j++) { qry += b[j]; } int resp = query(qry); if (resp == (int) b.size() + posA + 1) { answer += a[posA]; break; } answer += b[posB]; posB++; } posA++; } for (int i = posB; i < (int) b.size(); i++) { answer += b[i]; } return answer; } string guess(int _N, int S) { N = _N; string answer = solve(0, S - 1); return answer; }