Submission #866674

#TimeUsernameProblemLanguageResultExecution timeMemory
866674sofija6Password (RMI18_password)C++14
10 / 100
224 ms952 KiB
#include <bits/stdc++.h> using namespace std; int query(string str); string guess(int n, int s) { string ans=""; vector<pair<int,int> > cnt; for (int i=0;i<s;i++) { string S=""; for (int j=1;j<=n;j++) S+=(char)(i+'a'); cnt.push_back({query(S),i}); } sort(cnt.begin(),cnt.end(),greater<pair<int,int> >()); for (int i=1;i<=cnt[0].first;i++) ans+=(char)(cnt[0].second+'a'); int cur=1; while (ans.size()!=n) { int p=0; for (int i=1;i<=cnt[cur].first;i++) { while (true) { string S=""; for (int j=0;j<p;j++) S+=ans[j]; S+=(char)(cnt[cur].second+'a'); for (int j=p;j<ans.size();j++) S+=ans[j]; if (query(S)==S.size()) { ans=S; break; } else p++; } } cur++; } return ans; }

Compilation message (stderr)

password.cpp: In function 'std::string guess(int, int)':
password.cpp:22:22: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   22 |     while (ans.size()!=n)
      |            ~~~~~~~~~~^~~
password.cpp:33:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |                 for (int j=p;j<ans.size();j++)
      |                              ~^~~~~~~~~~~
password.cpp:35:29: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   35 |                 if (query(S)==S.size())
      |                     ~~~~~~~~^~~~~~~~~~
#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...