Submission #201352

#TimeUsernameProblemLanguageResultExecution timeMemory
201352theStaticMindPassword (RMI18_password)C++14
100 / 100
259 ms700 KiB
#include<bits/stdc++.h> #define pb push_back #define ii pair<int, int> #define all(x) (x).begin(),(x).end() #define INF 100000000000000000 #define modulo 1000000007 #define mod 998244353 //#define int long long int using namespace std; int query(string s); string merge(string a, string b){ int j = 0; if(a.length() > b.length())swap(a, b); for(int i = 0; i <= a.length() && j < b.length(); i++){ string w = a; string::iterator itr = a.insert(a.begin() + i, b[j]); if(query(a) == a.length()){ j++; } else { a.erase(itr); } } return a; } string guess(int n, int k){ vector<string> seg; for(int i = 0; i < k; i++){ string s; for(int j = 0; j < n; j++) s.pb('a' + i); int l = query(s); s.clear(); for(int j = 0; j < l; j++) s.pb('a' + i); seg.pb(s); } while(seg.size() != 1){ vector<string> temp; for(int i = 1; i < seg.size(); i += 2){ temp.pb(merge(seg[i - 1], seg[i])); } if(seg.size() % 2)temp.pb(seg.back()); swap(temp, seg); } return seg[0]; }

Compilation message (stderr)

password.cpp: In function 'std::__cxx11::string merge(std::__cxx11::string, std::__cxx11::string)':
password.cpp:14:24: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
       for(int i = 0; i <= a.length() && j < b.length(); i++){
                      ~~^~~~~~~~~~~~~
password.cpp:14:43: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
       for(int i = 0; i <= a.length() && j < b.length(); i++){
                                         ~~^~~~~~~~~~~~
password.cpp:17:25: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             if(query(a) == a.length()){
                ~~~~~~~~~^~~~~~~~~~~~~
password.cpp: In function 'std::__cxx11::string guess(int, int)':
password.cpp:38:30: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             for(int i = 1; i < seg.size(); i += 2){
                            ~~^~~~~~~~~~~~
#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...