Submission #722698

#TimeUsernameProblemLanguageResultExecution timeMemory
722698groshiPassword (RMI18_password)C++17
100 / 100
354 ms496 KiB
#include<bits/stdc++.h> using namespace std; int query(string str); priority_queue<pair<int,string> > kolejka; string marge(string a,string b) { string wypisz=""; int l=0,r=0; while(l<a.length() || r<b.length()) { if(l==a.length()) { wypisz+=b[r]; r++; continue; } if(r==b.length()) { wypisz+=a[l]; l++; continue; } string posiadam=""; for(int i=l;i<a.length();i++) posiadam+=a[i]; int ile=query(wypisz+b[r]+posiadam); if(ile==wypisz.length()+1+posiadam.length()) { wypisz+=b[r]; r++; continue; } else{ wypisz+=a[l]; l++; continue; } } return wypisz; } string guess(int n,int s) { for(int i=0;i<s;i++) { string pom=""; for(int j=1;j<=n;j++) pom+=(char)('a'+i); int ile=query(pom); string mam=""; for(int j=1;j<=ile;j++) mam+=(char)('a'+i); if(ile!=0) kolejka.push({-ile,mam}); } while(kolejka.size()>=2) { auto para1=kolejka.top(); kolejka.pop(); auto para2=kolejka.top(); kolejka.pop(); string mam=marge(para1.second,para2.second); kolejka.push({-mam.length(),mam}); } return kolejka.top().second; }

Compilation message (stderr)

password.cpp: In function 'std::string marge(std::string, std::string)':
password.cpp:10:12: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   10 |     while(l<a.length() || r<b.length())
      |           ~^~~~~~~~~~~
password.cpp:10:28: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   10 |     while(l<a.length() || r<b.length())
      |                           ~^~~~~~~~~~~
password.cpp:12:13: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   12 |         if(l==a.length())
      |            ~^~~~~~~~~~~~
password.cpp:18:13: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   18 |         if(r==b.length())
      |            ~^~~~~~~~~~~~
password.cpp:25:22: 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=l;i<a.length();i++)
      |                     ~^~~~~~~~~~~
password.cpp:28:15: 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(ile==wypisz.length()+1+posiadam.length())
      |            ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#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...