Submission #709094

#TimeUsernameProblemLanguageResultExecution timeMemory
709094jamezzzPassword (RMI18_password)C++17
30 / 100
267 ms368 KiB
#include <bits/stdc++.h> using namespace std; mt19937 rng(time(0)); int query(string str); string guess(int n,int s){ string ans=""; int pv=0; vector<int> v; for(int i=0;i<s;++i)v.push_back(i); shuffle(v.begin(),v.end(),rng); for(int i:v){ char c='a'+i; for(int j=0;j<ans.length();++j){ string tmp=ans; tmp.insert(j,1,c); int res=query(tmp); if(res>pv){ pv=res; swap(tmp,ans); tmp.clear(); if(pv==n)return ans; continue; } else{ tmp.clear(); if(res==j)break; } } string tmp=ans; tmp.insert(tmp.length(),n-tmp.length(),c); pv=query(tmp); tmp.resize(pv); swap(ans,tmp); tmp.clear(); if(pv==n)return ans; } return ans; }

Compilation message (stderr)

password.cpp: In function 'std::string guess(int, int)':
password.cpp:16:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   16 |   for(int j=0;j<ans.length();++j){
      |               ~^~~~~~~~~~~~~
#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...