Submission #918467

#TimeUsernameProblemLanguageResultExecution timeMemory
918467Huseyn123Password (RMI18_password)C++17
80 / 100
468 ms14168 KiB
#include <bits/stdc++.h> using namespace std; int query(string str); int N; vector<int> a; int c[26][26][5001]; bool comp(pair<int,int> x,pair<int,int> y){ if(x.first==y.first){ return x.second<y.second; } string s2=""; for(int i=0;i<x.second;i++){ s2+=char('a'+x.first); } for(int i=0;i<a[y.first]-y.second+1;i++){ s2+=char('a'+y.first); } for(int i=x.second;i<=N;i++){ if(c[x.first][y.first][i]<=y.second){ return true; } } for(int i=y.second;i<=N;i++){ if(c[y.first][x.first][i]<=x.second){ return false; } } bool ok=false; if(query(s2)==(int)s2.size()){ c[x.first][y.first][x.second]=min(c[x.first][y.first][x.second],y.second); ok=true; } else{ c[y.first][x.first][y.second]=min(c[y.first][x.first][y.second],x.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++){ c[i][j][z]=n+1; } } } a.resize(s); string s1=""; for(int i=0;i<s;i++){ s1=""; for(int j=0;j<n;j++){ s1+=char('a'+i); } a[i]=query(s1); } vector<pair<int,int>> b; for(int i=0;i<s;i++){ for(int j=0;j<a[i];j++){ b.push_back(make_pair(i,j+1)); } } sort(b.begin(),b.end(),comp); s1=""; for(int i=0;i<n;i++){ s1+=char('a'+b[i].first); } return s1; }
#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...