Submission #251370

#TimeUsernameProblemLanguageResultExecution timeMemory
251370dwscPassword (RMI18_password)C++14
100 / 100
929 ms760 KiB
#include <bits/stdc++.h> using namespace std; int query(string str); vector<string> mergevector(vector<string> v){ vector<string> newvector; for (int i = 0; i < v.size(); i+= 2){ if (i == v.size()-1){ newvector.push_back(v[i]); break; } string s1 = v[i],s2 = v[i+1]; //cout << s1 << " " << s2 << "hi\n"; string newstring = s1; int insertionpos = 0; int curpos = 0; while (curpos < s2.length()){ string temp = ""; for (int j = 0; j < newstring.length(); j++){ if (j == insertionpos) temp += s2[curpos]; temp += newstring[j]; } if (insertionpos == newstring.length()) temp += s2[curpos]; if (query(temp) == temp.length()){ newstring = temp; curpos++; insertionpos++; } else{ insertionpos++; } } //cout << newstring << "\n"; newvector.push_back(newstring); } return newvector; } string guess(int n, int s){ vector<string> letters; for (int i = 0; i < s; i++){ int ans = 0; char c = (char)(i+97); string act = ""; for (int j = 1; j <= n; j++){ string temp = act+c; if (query(temp) == ans) break; act = temp; ans++; } //cout << act << "\n"; if (ans) letters.push_back(act); } while (letters.size() > 1)letters = mergevector(letters); return letters[0]; }

Compilation message (stderr)

password.cpp: In function 'std::vector<std::__cxx11::basic_string<char> > mergevector(std::vector<std::__cxx11::basic_string<char> >)':
password.cpp:6:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i = 0; i < v.size(); i+= 2){
                     ~~^~~~~~~~~~
password.cpp:7:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         if (i == v.size()-1){
             ~~^~~~~~~~~~~~~
password.cpp:16:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         while (curpos < s2.length()){
                ~~~~~~~^~~~~~~~~~~~~
password.cpp:18:31: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             for (int j = 0; j < newstring.length(); j++){
                             ~~^~~~~~~~~~~~~~~~~~~~
password.cpp:22:30: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             if (insertionpos == newstring.length()) temp += s2[curpos];
                 ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~
password.cpp:23:29: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             if (query(temp) == temp.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...