Submission #669802

#TimeUsernameProblemLanguageResultExecution timeMemory
669802MarszpaceMutating DNA (IOI21_dna)C++17
0 / 100
30 ms3916 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])); } aGlobal=a; bGlobal=b; } 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: In function 'int get_distance(int, int)':
dna.cpp:24:18: warning: 'a[1]' may be used uninitialized in this function [-Wmaybe-uninitialized]
   24 |     if(a[0]!=b[0]||a[1]!=b[1]||a[2]!=b[2]){return -1;}
      |        ~~~~~~~~~~^~~~~~~~~~~~
dna.cpp:24:18: warning: 'b[1]' may be used uninitialized in this function [-Wmaybe-uninitialized]
dna.cpp:24:5: warning: 'a[0]' may be used uninitialized in this function [-Wmaybe-uninitialized]
   24 |     if(a[0]!=b[0]||a[1]!=b[1]||a[2]!=b[2]){return -1;}
      |     ^~
dna.cpp:24:5: warning: 'b[0]' may be used uninitialized in this function [-Wmaybe-uninitialized]
dna.cpp:24:30: warning: 'a[2]' may be used uninitialized in this function [-Wmaybe-uninitialized]
   24 |     if(a[0]!=b[0]||a[1]!=b[1]||a[2]!=b[2]){return -1;}
      |        ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~
dna.cpp:24:30: warning: 'b[2]' may be used uninitialized in this function [-Wmaybe-uninitialized]
#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...