Submission #199697

# Submission time Handle Problem Language Result Execution time Memory
199697 2020-02-02T20:46:39 Z mohamedsobhi777 Password (RMI18_password) C++14
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;

string a[1000];

vector<int> acc(26 , 0);



string merg(string aa , string bb)
{
    int s1 = aa.size();
    int s2 = bb.size();
    string ret = aa;
    int j = s2-1;
    for(int i = s1;i>=0&&j>=0;i--)
    {
        string tmp ;
        bool ok = 1;
        while(ok && j>=0)
        {
            tmp = ret.substr(0 , i) + bb[j];
            tmp+=ret.substr( i , s1 - i );
            if(query(tmp)==tmp.size())
            {
                ret = tmp;
                s1++;
                j--;
            }else ok = 0;
        }


    }
    return ret ;
}

string build(int l, int r )
{

    if(l==r)
    {
        return string( acc[l] , char(l + 'a'));
    }
    else
    {
        int mid = (l + r) /2;
        string s1 = build(l , mid );
        string s2 = build(mid+1 , r);
        string ret = merg(s1 , s2);
        return ret;
    }
}



string guess(int n, int s)
{
    int sum = 0;
    for(int i = 'a';i<'a' + s -1 ;i++)
    {
        acc[i-'a'] = query(string(n , char(i)));
        sum+=acc[i-'a'];
    }
    acc[s - 1] =  n  - sum;
    return build(0 , s-1);
}

Compilation message

password.cpp: In function 'std::__cxx11::string merg(std::__cxx11::string, std::__cxx11::string)':
password.cpp:24:16: error: 'query' was not declared in this scope
             if(query(tmp)==tmp.size())
                ^~~~~
password.cpp: In function 'std::__cxx11::string guess(int, int)':
password.cpp:61:22: error: 'query' was not declared in this scope
         acc[i-'a'] = query(string(n , char(i)));
                      ^~~~~