Submission #872947

#TimeUsernameProblemLanguageResultExecution timeMemory
872947vjudge1Password (RMI18_password)C++17
30 / 100
52 ms1224 KiB
#include <bits/stdc++.h> using namespace std; int query(string q); string guess(int n, int s) { queue < pair<int, string> > S; for(char c = 'a'; c < 'a'+s; c++) { string cur; for(int i = 0; i < n; i++) cur += c; int m = query(cur); if(m > 0) { cur = ""; for(int i = 0; i < m; i++) { cur += c; } S.push({cur.size(), cur}); } } while(S.size() > 1) { string a = S.front().second; S.pop(); string b = S.front().second; S.pop(); string ans = ""; int j = 0; for(int i = 0; i <= a.size(); i++) { while(j < b.size()) { string cur = ans; cur += b[j]; for(int k = i; k < a.size(); k++) { cur += a[k]; } if(query(cur) == cur.size()) { ans+=b[j]; j++; continue; } break; } if(i < a.size()) ans += a[i]; } S.push({ans.size(), ans}); } return S.front().second; }

Compilation message (stderr)

password.cpp: In function 'std::string guess(int, int)':
password.cpp:25:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |         for(int i = 0; i <= a.size(); i++) {
      |                        ~~^~~~~~~~~~~
password.cpp:27:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   27 |             while(j < b.size()) {
      |                   ~~^~~~~~~~~~
password.cpp:30:34: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |                 for(int k = i; k < a.size(); k++) {
      |                                ~~^~~~~~~~~~
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 |                 if(query(cur) == cur.size()) {
      |                    ~~~~~~~~~~~^~~~~~~~~~~~~
password.cpp:40:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   40 |             if(i < a.size()) ans += a[i];
      |                ~~^~~~~~~~~~
#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...