이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
#include <bits/stdc++.h>
using namespace std;
#define db long double
#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vl vector<ll>
#define vii vector<pii>
#define vll vector<pll>
// #define endl '\n'
#define all(x) x.begin(), x.end()
#define fastio\
ios_base::sync_with_stdio(0);\
cin.tie(0);\
cout.tie(0)\
int query(string str);
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
#define pci pair<char, int>
int memo[26][26][5001];
map<char, int> cnt;
int N;
bool comp(pair<char, int> a, pair<char, int> b){
if(a.first == b.first){
return a.second < b.second;
}
for(int i=a.second;i<=N;i++){
if(memo[a.first-'a'][b.first-'a'][i]<=b.second){
return true;
}
}
for(int i=b.second;i<=N;i++){
if(memo[b.first-'a'][a.first-'a'][i]<=a.second){
return false;
}
}
string s = "";
for(int i = 1; i <= a.second; i++){
s += a.first;
}
for(int i = 1; i <= cnt[b.first] - b.second + 1; i++){
s += b.first;
}
bool ok=(query(s)==(int)s.size());
if(ok){
memo[a.first-'a'][b.first-'a'][a.second]=min(memo[a.first-'a'][b.first-'a'][a.second],b.second);
}
else{
memo[b.first-'a'][a.first-'a'][b.second]=min(memo[b.first-'a'][a.first-'a'][b.second],a.second);
}
return ok;
}
string guess(int n, int s){
N=n;
for(int i=0;i<s;i++){
for(int j=0;j<s;j++){
for(int z=1;z<=n;z++){
memo[i][j][z]=n+1;
}
}
}
vector<pci> v;
for(char c = 'a'; c <= char('a'+s-1); c++){
string s1 = "";
for(int j = 1; j <= n; j++){
s1 += c;
}
cnt[c] = query(s1);
for(int j = 1; j <= cnt[c]; j++){
v.push_back({c, j});
}
// cout << c << " : " << cnt[c] << endl;
}
shuffle(all(v), rng);
sort(all(v), comp);
string res = "";
for(auto i : v){
res += i.first;
}
return res;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |