#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <unordered_set>
#include <complex>
#include <list>
#include <chrono>
#include <random>
#include <stack>
#include <iomanip>
#include <fstream>
using namespace std;
#define endl "\n"
// #define int long long
const int INF = 2 * 1e5 + 5;
const int MOD = 1e9 + 7;
// int query(string s){
// int n;
// cout << s;
// cin >> n;
// return n;
// }
int query(string s);
string guess(int n, int s){
bool pass = false;
string sol = "";
for(char i = 'a'; i < 'a'+s; i++){
string letter = string(n, i);
int amount = query(letter);
int initAmount = amount;
if(amount == 0) continue;
if(!pass){
sol += string(amount, i);
pass = true;
} else {
int len = sol.length();
vector<pair<int, int>> add;
for(int j = 0; j <= len; j++){
string curr = sol.substr(0, len-j) + string(n-(len-j), i);
amount = query(curr);
int pos = len - j;
int diff = amount - pos;
if(diff > 0){
add.push_back({pos, diff});
initAmount -= diff;
if(initAmount <= 0) break;
}
}
int k = 0;
for(auto &j : add){
sol.insert(j.first + k, string(j.second, i));
k+=j.second;
// cout << "{" << j.first << " " << j.second << "}" << endl;
}
// cout << "| " << temp << " |" << endl;
}
}
return sol;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
336 KB |
Guessed the password with 88 queries. |
2 |
Correct |
4 ms |
336 KB |
Guessed the password with 157 queries. |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
508 KB |
Token "aaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbaaaa" doesn't correspond to pattern "[a-b]{1,50}" |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
76 ms |
464 KB |
Token "acccdeeeeeeeeeeeeeeeeeeeeeeeee...dcccccccccccccccccccccccccccccb" doesn't correspond to pattern "[a-l]{1,1000}" |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
336 KB |
Guessed the password with 88 queries. |
2 |
Correct |
4 ms |
336 KB |
Guessed the password with 157 queries. |
3 |
Incorrect |
1 ms |
508 KB |
Token "aaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbaaaa" doesn't correspond to pattern "[a-b]{1,50}" |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
336 KB |
Guessed the password with 88 queries. |
2 |
Correct |
4 ms |
336 KB |
Guessed the password with 157 queries. |
3 |
Incorrect |
1 ms |
508 KB |
Token "aaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbaaaa" doesn't correspond to pattern "[a-b]{1,50}" |
4 |
Halted |
0 ms |
0 KB |
- |