Submission #199694

# Submission time Handle Problem Language Result Execution time Memory
199694 2020-02-02T20:44:19 Z mohamedsobhi777 Password (RMI18_password) C++17
Compilation error
0 ms 0 KB
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:1:1: error: 'string' does not name a type; did you mean 'struct'?
 string a[1000];
 ^~~~~~
 struct
password.cpp:3:1: error: 'vector' does not name a type
 vector<int> acc(26 , 0);
 ^~~~~~
password.cpp:7:1: error: 'string' does not name a type; did you mean 'struct'?
 string merg(string aa , string bb)
 ^~~~~~
 struct
password.cpp:34:1: error: 'string' does not name a type; did you mean 'struct'?
 string build(int l, int r )
 ^~~~~~
 struct
password.cpp:53:1: error: 'string' does not name a type; did you mean 'struct'?
 string guess(int n, int s)
 ^~~~~~
 struct