Submission #866641

# Submission time Handle Problem Language Result Execution time Memory
866641 2023-10-26T14:40:57 Z sofija6 Password (RMI18_password) C++14
Compilation error
0 ms 0 KB
// Sample grader for contestants' use.
//
// Usage: place your input data in the file password.in in the format
#include <bits/stdc++.h>

int query(string str);

string guess(int n, int s)
{
    string ans="";
    int cnt[26]={0};
    for (int i=0;i<s;i++)
    {
        int l=1,r=n,mid;
        while (l<=r)
        {
            mid=(l+r)/2;
            string S="";
            for (int j=1;j<=mid;j++)
                S+=(char)('a'+i);
            if (query(S)==mid)
            {
                cnt[i]=mid;
                l=mid+1;
            }
            else
                r=mid-1;
        }
    }
    for (int i=1;i<=n;i++)
    {
        int l=0,r=25,mid,lastt=-1;
        while (l<=r)
        {
            mid=(l+r)/2;
            string S=ans;
            for (int j=0;j<=mid;j++)
            {
                if (cnt[j])
                    S+=(char)(j+'a');
            }
            if (query(S)>i-1)
            {
                lastt=mid;
                r=mid-1;
            }
            else
                l=mid+1;
        }
        ans+=(char)(lastt+'a');
        cnt[lastt]--;
    }
    return ans;
}

Compilation message

password.cpp:6:11: error: 'string' was not declared in this scope; did you mean 'std::string'?
    6 | int query(string str);
      |           ^~~~~~
      |           std::string
In file included from /usr/include/c++/10/iosfwd:39,
                 from /usr/include/c++/10/ios:38,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from password.cpp:4:
/usr/include/c++/10/bits/stringfwd.h:79:33: note: 'std::string' declared here
   79 |   typedef basic_string<char>    string;
      |                                 ^~~~~~
password.cpp:8:1: error: 'string' does not name a type; did you mean 'stdin'?
    8 | string guess(int n, int s)
      | ^~~~~~
      | stdin