#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pull;
typedef pair<int, int> pii;
typedef pair<ld, ld> pld;
int query(string s);
string calc(int l, int r){
if(l == r){
string tmp;
for(int i = 0; i < 5000; ++i)
tmp.pb('a'+l);
int cnt = query(tmp);
return tmp.substr(0, cnt);
}
else{
int m = (l+r)/2;
string s1 = calc(l, m);
string s2 = calc(m+1, r);
string s;
reverse(s1.begin(), s1.end());
while(s1.size() && s2.size()){
if(s1.empty()){
s += s2;
break;
}
if(s2.empty()){
reverse(s1.begin(), s1.end());
s += s1;
break;
}
if(query(s+s1.back()+s2) == s.size()+s2.size()+1){
s += s1.back();
s1.pop_back();
}
else{
reverse(s2.begin(), s2.end());
s += s2.back();
s2.pop_back();
reverse(s2.begin(), s2.end());
}
}
return s;
}
}
string guess(int n, int s){
return calc(0, s-1);
}
Compilation message
password.cpp: In function 'std::__cxx11::string calc(int, int)':
password.cpp:39:38: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if(query(s+s1.back()+s2) == s.size()+s2.size()+1){
~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
384 KB |
Token "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" doesn't correspond to pattern "[a-o]{1,15}" |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
384 KB |
Token "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" doesn't correspond to pattern "[a-b]{1,50}" |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
372 KB |
Token "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" doesn't correspond to pattern "[a-l]{1,1000}" |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
384 KB |
Token "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" doesn't correspond to pattern "[a-o]{1,15}" |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
384 KB |
Token "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" doesn't correspond to pattern "[a-o]{1,15}" |
2 |
Halted |
0 ms |
0 KB |
- |