Submission #669801

#TimeUsernameProblemLanguageResultExecution timeMemory
669801MarszpaceMutating DNA (IOI21_dna)C++17
Compilation error
0 ms0 KiB
#include<bits/stdc++.h> using namespace std; vector<bool> diff; string aGlobal,bGlobal; void init(string a, string b){ for(int i=0;i<a.size();i++){ diff.push_back(!(a[i]==b[i])); } strcpy(a,aGlobal); strcpy(b,bGlobal); } int get_distance(int x, int y){ int a[3],b[3]; for(int i=x;i<=y;i++){ if(aGlobal[i]=='A'){a[0]++;} else if(aGlobal[i]=='T'){a[1]++;} else if(aGlobal[i]=='C'){a[2]++;} if(bGlobal[i]=='A'){b[0]++;} else if(bGlobal[i]=='T'){b[1]++;} else if(bGlobal[i]=='C'){b[2]++;} } if(a[0]!=b[0]||a[1]!=b[1]||a[2]!=b[2]){return -1;} int res=0; for(int i=x;i<=y;i++){ if(diff[i]){res++;} } return res/2; }

Compilation message (stderr)

dna.cpp: In function 'void init(std::string, std::string)':
dna.cpp:6:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    6 |     for(int i=0;i<a.size();i++){
      |                 ~^~~~~~~~~
dna.cpp:9:12: error: cannot convert 'std::string' {aka 'std::__cxx11::basic_string<char>'} to 'char*'
    9 |     strcpy(a,aGlobal);
      |            ^
      |            |
      |            std::string {aka std::__cxx11::basic_string<char>}
In file included from /usr/include/features.h:461,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/os_defines.h:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/c++config.h:518,
                 from /usr/include/c++/10/cassert:43,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:33,
                 from dna.cpp:1:
/usr/include/x86_64-linux-gnu/bits/string_fortified.h:88:1: note:   initializing argument 1 of 'char* strcpy(char*, const char*)'
   88 | __NTH (strcpy (char *__restrict __dest, const char *__restrict __src))
      | ^~~~~
dna.cpp:10:12: error: cannot convert 'std::string' {aka 'std::__cxx11::basic_string<char>'} to 'char*'
   10 |     strcpy(b,bGlobal);
      |            ^
      |            |
      |            std::string {aka std::__cxx11::basic_string<char>}
In file included from /usr/include/features.h:461,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/os_defines.h:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/c++config.h:518,
                 from /usr/include/c++/10/cassert:43,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:33,
                 from dna.cpp:1:
/usr/include/x86_64-linux-gnu/bits/string_fortified.h:88:1: note:   initializing argument 1 of 'char* strcpy(char*, const char*)'
   88 | __NTH (strcpy (char *__restrict __dest, const char *__restrict __src))
      | ^~~~~