Submission #873083

#TimeUsernameProblemLanguageResultExecution timeMemory
873083vjudge1Password (RMI18_password)C++17
100 / 100
176 ms1928 KiB
#include<bits/stdc++.h> using namespace std; int cnt[26]; set<char>st[26]; int query(string q); string guess(int n, int s) { set<pair<int, string>>st; for(char c='a'; c<'a'+s; c++){ string d; for(int i=1; i<=n; i++) d += c; cnt[c-'a'] = query(d); while(d.size() > cnt[c-'a']) d.pop_back(); if(cnt[c-'a']) st.insert({d.size(), d}); } while(st.size() > 1){ string a = st.begin()->second; st.erase(st.begin()); string b = st.begin()->second; st.erase(st.begin()); string c; int l = 0, r = 0; while(c.size() < a.size()+b.size()){ if(r < b.size()){ c += b[r]; } for(int j=l; j<a.size(); j++) c += a[j]; if(r < b.size() && query(c) == c.size()){ r++; for(int j=l; j<a.size(); j++) c.pop_back(); } else{ for(int j=l; j<a.size(); j++) c.pop_back(); if(r < b.size()) c.pop_back(); c += a[l++]; } } st.insert({c.size(), c}); } return st.begin()->second; }

Compilation message (stderr)

password.cpp: In function 'std::string guess(int, int)':
password.cpp:16:18: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   16 |   while(d.size() > cnt[c-'a'])
      |         ~~~~~~~~~^~~~~~~~~~~~
password.cpp:27:9: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   27 |    if(r < b.size()){
      |       ~~^~~~~~~~~~
password.cpp:30:18: 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 j=l; j<a.size(); j++)
      |                 ~^~~~~~~~~
password.cpp:32:9: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |    if(r < b.size() && query(c) == c.size()){
      |       ~~^~~~~~~~~~
password.cpp:32:32: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |    if(r < b.size() && query(c) == c.size()){
      |                       ~~~~~~~~~^~~~~~~~~~~
password.cpp:34:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |     for(int j=l; j<a.size(); j++)
      |                  ~^~~~~~~~~
password.cpp:37:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   37 |     for(int j=l; j<a.size(); j++)
      |                  ~^~~~~~~~~
password.cpp:39:10: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |     if(r < b.size()) c.pop_back();
      |        ~~^~~~~~~~~~
#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...