Submission #873077

#TimeUsernameProblemLanguageResultExecution timeMemory
873077vjudge1Password (RMI18_password)C++17
0 / 100
256 ms444 KiB
#include<bits/stdc++.h> using namespace std; int a[26]; 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 s; for(int i=1; i<=n; i++) s += c; cnt[c-'a'] = query(s); while(s.size() > cnt[c-'a']) s.pop_back(); if(s.size()) st.insert({s.size(), s}); } 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(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(); 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:17:18: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   17 |   while(s.size() > cnt[c-'a'])
      |         ~~~~~~~~~^~~~~~~~~~~~
password.cpp:28:9: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |    if(r < b.size()){
      |       ~~^~~~~~~~~~
password.cpp:31:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |    for(int j=l; j<a.size(); j++)
      |                 ~^~~~~~~~~
password.cpp:33:16: 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(c) == c.size()){
      |       ~~~~~~~~~^~~~~~~~~~~
password.cpp:35:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   35 |     for(int j=l; j<a.size(); j++)
      |                  ~^~~~~~~~~
password.cpp:38:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |     for(int j=l; j<=a.size(); 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...