Submission #755924

#TimeUsernameProblemLanguageResultExecution timeMemory
755924vjudge1Password (RMI18_password)C++17
0 / 100
1 ms208 KiB
#include <bits/stdc++.h> using namespace std; #define vi vector<int> #define vl vector<long long> #define vii vector<pair<int,int>> #define vll vector<pair<long long,long long>> #define pb push_back #define ll long long #define ld long double #define nl '\n' #define boost ios::sync_with_stdio(false) #define mp make_pair #define se second #define fi first #define fore(i, y) for(ll i = 0; i < y; i++) #define forr(i,x,y) for(int i = x;i<=y;i++) #define forn(i,y,x) for(ll i = y; i >= x; i--) #define all(v) v.begin(),v.end() #define sz(v) v.size() #define clr(v,k) memset(v,k,sizeof(v)) #define rall(v) v.rbegin() , v.rend() #define pii pair<int,int> #define pll pair<ll , ll> const ll MOD = 1e9 + 7; const ll INF = 1e18 + 1; ll gcd(ll a , ll b) {return b ? gcd(b , a % b) : a ;} // greatest common divisor (PGCD) ll lcm(ll a , ll b) {return a * (b / gcd(a , b));} // least common multiple (PPCM) // HERE IS THE SOLUTION vector<vector<string>> possible(5); void brute(int t) { forr(i , 'a' , 'd') { string s = ""; s+=i; forr(j , 'a' , 'd') { s+= j; possible[2].pb(s); forr(k , 'a' , 'd') { s+= k; possible[3].pb(s); forr(l , 'a' , 'd') { s+= l; possible[4].pb(s); } } } } } int query(string str); string guess(int n,int s ) { string t = ""; do { if(sz(t) + s > n) { if(sz(t) + s - 1 == n) { for(auto str : possible[s-1]) { if(query(str + t) == sz(t) + s - 1) { t = str + t; break; } } } else if(sz(t) + s - 2 == n) { for(auto str : possible[s-2]) { if(query(str + t) == sz(t) + s-2) { t = str + t; break; } } } } for(auto str : possible[s]) { if(query(str + t) == sz(t) + s) { t = str + t; break; } } } while(query(t) != n); cout<<t<<nl; }

Compilation message (stderr)

password.cpp: In function 'std::string guess(int, int)':
password.cpp:62:22: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   62 |         if(sz(t) + s > n)
      |                      ^
password.cpp:64:30: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   64 |             if(sz(t) + s - 1 == n)
      |                              ^
password.cpp:68:39: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   68 |                     if(query(str + t) == sz(t) + s - 1)
      |                        ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~
password.cpp:75:36: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   75 |             else if(sz(t) + s  - 2 == n)
      |                                    ^
password.cpp:79:39: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   79 |                     if(query(str + t) == sz(t) + s-2)
      |                        ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~
password.cpp:89:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   89 |             if(query(str + t) == sz(t) + s)
      |                ~~~~~~~~~~~~~~~^~~~~~~~~~~~
password.cpp:98:1: warning: no return statement in function returning non-void [-Wreturn-type]
   98 | }
      | ^
#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...