제출 #476230

#제출 시각아이디문제언어결과실행 시간메모리
476230iulia13Password (RMI18_password)C++14
50 / 100
398 ms300 KiB
#include <bits/stdc++.h> using namespace std; const int N = 5005; string ans, prov; int cnt[N], nn, ss; int query(string str); string p, password;/* int query(string q) { int len = q.size(); // validation // while possible, advance one character in q and find its next // occurrence in password int i = 0, j = 0, plen = password.size(); while (i < plen && j < len) { while ((i < plen) && (password[i] != q[j])) { i++; } if (i < plen) { i++; j++; } } return j; }*/ string guess(int n, int s) { char a; int q = 0; for (int i = 0; i < s; i++) { a = 'a' + i; p = ans; for (int j = q; j < n; j++) p += a; for (int h = q; h >= 0; h--) { cnt[h] = query(p) - h; if (h) p[h - 1] = a; } int nq = 0; prov = ""; for (int j = 0; j <= q; j++) { int x = cnt[j] - cnt[j + 1]; while(x--) { prov += a; nq++; } if (j != q) { prov += ans[j]; nq++; } } q = nq; ans = prov; } return ans; }/* int main() { freopen("x.in", "r", stdin); freopen("x.out", "w", stdout); int nn, ss; cin >> nn >> ss; cin >> password; cout << guess(nn, ss); return 0; }*/
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...