Submission #755944

# Submission time Handle Problem Language Result Execution time Memory
755944 2023-06-10T18:11:00 Z vjudge1 Password (RMI18_password) C++17
0 / 100
1 ms 208 KB
#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()
{
    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);
                    s.erase(s.begin() + 3);
                }
                s.erase(s.begin() + 2);
            }
            s.erase(s.begin() + 1);
        }
        s.erase(s.begin());
    }
}
int query(string str);
string guess(int n,int s )
{
    brute();
    string t = "";
    do
    {
        if(sz(t) + s > n)
        {
            if(sz(t) + s - 1 == n)
            {
                for(auto str : possible[s-1])
                {
                    if(query(t + str) == sz(t) + s - 1)
                    {
                        t = t+ str;
                        break;
                    }
                }
            }
            else if(sz(t) + s  - 2 == n)
            {
                for(auto str : possible[s-2])
                {
                    if(query(t + str) == sz(t) + s-2)
                    {
                        t = t + str;
                        break;
                    }
                }
            }
        }
        for(auto str : possible[s])
        {
            if(query(t + str) == sz(t) + s)
            {
                t = t+str;
                break;
            }
        }
    }
    while(query(t) != n);
    return t;
}



Compilation message

password.cpp: In function 'std::string guess(int, int)':
password.cpp:69:22: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   69 |         if(sz(t) + s > n)
      |                      ^
password.cpp:71:30: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   71 |             if(sz(t) + s - 1 == n)
      |                              ^
password.cpp:75:39: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   75 |                     if(query(t + str) == sz(t) + s - 1)
      |                        ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~
password.cpp:82:36: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   82 |             else if(sz(t) + s  - 2 == n)
      |                                    ^
password.cpp:86:39: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   86 |                     if(query(t + str) == sz(t) + s-2)
      |                        ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~
password.cpp:96:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   96 |             if(query(t + str) == sz(t) + s)
      |                ~~~~~~~~~~~~~~~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Execution timed out 1 ms 208 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 208 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1 ms 208 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1 ms 208 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1 ms 208 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -