Submission #1117171

#TimeUsernameProblemLanguageResultExecution timeMemory
1117171allin27xPassword (RMI18_password)C++17
50 / 100
1026 ms1480 KiB
#include <bits/stdc++.h> using namespace std; int query(string str); string guess(int n, int s){ mt19937 rng(time(nullptr)); string res; vector<int> nc(s, 0); vector<int> to(s, -1); for (int i=0; i<s; i++) nc[i] = query(string(n,'a'+i)); int last = -1; while (res.size()<n){ string rev = res; reverse(rev.begin(), rev.end()); vector<int> rel; for (int i=0; i<s; i++) if (nc[i] && (i==last || to[i] == last)) rel.push_back(i); int mx = rel[0]; for (int i: rel){ if (i== rel[0]) continue; if (!nc[i] || (i!=last && to[i]!=last)) continue; if (query(string(nc[i], 'a'+i) + string(1,'a'+mx) + rev) != nc[i] + 1 + res.size()) { to[mx] = i; mx = i; } else { to[i] = mx; } } nc[mx] --; res += 'a' + mx; last = mx; } reverse(res.begin(), res.end()); return res; }

Compilation message (stderr)

password.cpp: In function 'std::string guess(int, int)':
password.cpp:13:22: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   13 |     while (res.size()<n){
      |            ~~~~~~~~~~^~
password.cpp:22:70: 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 (query(string(nc[i], 'a'+i) + string(1,'a'+mx) + rev) != nc[i] + 1 + res.size()) {
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
#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...