Submission #773294

#TimeUsernameProblemLanguageResultExecution timeMemory
773294BT21tataPassword (RMI18_password)C++17
0 / 100
1 ms208 KiB
#include <bits/stdc++.h> using namespace std; struct cmp { bool operator()(const string &a, const string &b) { return a.size()>b.size(); } }; int query(string str); string mrg(string &a, string &b) { string ret; int pos1=0, pos2=0; while(true) { if(pos1==a.size() or pos2==b.size()) break; string cur=ret; cur+=a[pos1]; for(int i=pos2; i<b.size(); i++) cur+=b[i]; int q=query(cur); if(q==pos1+b.size()+1) ret+=a[pos1++]; else ret+=b[pos2++]; } while(pos1<a.size()) ret+=a[pos1++]; while(pos2<b.size()) ret+=b[pos2++]; return ret; } string guess(int n, int s) { priority_queue<string, vector<string>, cmp>q; for(int i=0; i<s; i++) { string s, sec; for(int j=0; j<n; j++) s+=(char)(i+'a'); int ret=query(s); if(!ret) continue; for(int i=0; i<ret; i++) sec+=(char)(i+'a'); q.push(sec); } while(q.size()>1) { string s1=q.top(); q.pop(); string s2=q.top(); q.pop(); string merged=mrg(s1, s2); q.push(merged); } return q.top(); }

Compilation message (stderr)

password.cpp: In function 'std::string mrg(std::string&, std::string&)':
password.cpp:22:12: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |     if(pos1==a.size() or pos2==b.size()) break;
      |        ~~~~^~~~~~~~~~
password.cpp:22:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |     if(pos1==a.size() or pos2==b.size()) break;
      |                          ~~~~^~~~~~~~~~
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=pos2; i<b.size(); i++)
      |                     ~^~~~~~~~~
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(q==pos1+b.size()+1)
      |        ~^~~~~~~~~~~~~~~~~
password.cpp:32:13: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |   while(pos1<a.size()) ret+=a[pos1++];
      |         ~~~~^~~~~~~~~
password.cpp:33:13: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |   while(pos2<b.size()) ret+=b[pos2++];
      |         ~~~~^~~~~~~~~
#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...