Submission #373409

# Submission time Handle Problem Language Result Execution time Memory
373409 2021-03-04T13:41:27 Z Ahmad_Hasan Martian DNA (IOI16_dna) C++17
Compilation error
0 ms 0 KB
string analyse(int n, int t) {
    make_test("0");
    string ons="";
    for(int i=0;i<n;i++)
        ons+='1';
    int l=0,r=n;
    int cnt1=0;
    ///cout<<ons<<'\n';
    while(l<=r){
        int mid=(r-l)/2+l;
        ///cout<<ons.substr(0,mid)<<'\n';
        if(make_test(ons.substr(0,mid))){
            l=mid+1;
            cnt1=mid;
        }else{
            r=mid-1;
        }
    }
    ///cout<<cnt1<<'\n';

    ons=ons.substr(0,cnt1);

    int cnt=0;
    while(cnt<=cnt1){
        if(make_test(ons+'0')){
            cnt=0;
            ons+='0';
        }else{
            cnt++;
            ons+='1';
        }
    }
    l=cnt1,r=n;
    int lst=0;
    ///cout<<ons<<'\n';
    while(l<=r){
        int mid=(r-l)/2+l;
        ///cout<<ons.substr(0,mid)<<'\n';
        if(make_test(ons.substr(0,mid))){
            l=mid+1;
            lst=mid;
        }else{
            r=mid-1;
        }
    }

    ons=ons.substr(0,lst);
    while(ons.size()<n){
        if(make_test("0"+ons)){
            ons.insert(0,'0',1);
        }else{
            ons.insert(0,'1',1);
        }
    }


    return ons;
}

Compilation message

dna.cpp:1:1: error: 'string' does not name a type
    1 | string analyse(int n, int t) {
      | ^~~~~~
grader.cpp: In function 'bool make_test(std::string)':
grader.cpp:14:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   14 |  for (int i = 0; i < p.size(); i++) {
      |                  ~~^~~~~~~~~~
grader.cpp:23:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   23 |  for (int i = 1; i <= ss.size(); i++) {
      |                  ~~^~~~~~~~~~~~
grader.cpp:28:13: warning: comparison of integer expressions of different signedness: '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'} and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |   if (pr[i] == p.size()) {