Submission #646481

#TimeUsernameProblemLanguageResultExecution timeMemory
646481kkkkkkkkMutating DNA (IOI21_dna)C++17
0 / 100
30 ms2492 KiB
#include "dna.h" #include <iostream> using namespace std; string a,b; void init(string A,string B) { a=A; b=B; } int get_distance(int x,int y) { string a1,b1; for (int i=x;i<=y;i++) { a1+=a[i]; b1+=b[i]; } int aA=0,aC=0,aT=0,bA=0,bC=0,bT=0; for (int i=0;i<a1.size();i++) { if (a1[i]=='A') aA++; else if (a1[i]=='C') aC++; else aT++; if (b1[i]=='A') bA++; else if (b1[i]=='C') bC++; else bT++; } int br=0; if (aA==bA&&aC==bC&&aT==bT) { for (int i=0;i<a1.size();i++) if (a1[i]!=b1[i]) br++; return br-1; } else return -1; } /* int main() { init("ATACAT", "ACTATA"); cout << get_distance(1,3) << endl; cout << get_distance(4,5) << endl; cout << get_distance(3,5) << endl; return 0; }*/

Compilation message (stderr)

dna.cpp: In function 'int get_distance(int, int)':
dna.cpp:23:19: 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=0;i<a1.size();i++)
      |                  ~^~~~~~~~~~
dna.cpp:35:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   35 |         for (int i=0;i<a1.size();i++)
      |                      ~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...