Submission #630254

#TimeUsernameProblemLanguageResultExecution timeMemory
630254GoodkNightMutating DNA (IOI21_dna)C++17
100 / 100
39 ms6248 KiB
#include <string> #include<iostream> using namespace std; int presum[100008][6]; void init(string a, string b){ for(int i=0; i<a.size(); i++){ if(i>0){ for(int j=0; j<6; j++){ presum[i][j]=presum[i-1][j]; } } if(a[i]=='A'){ if(b[i]=='C'){ presum[i][0]++; } if(b[i]=='T'){ presum[i][1]++; } } if(a[i]=='C'){ if(b[i]=='A'){ presum[i][2]++; } if(b[i]=='T'){ presum[i][3]++; } } if(a[i]=='T'){ if(b[i]=='A'){ presum[i][4]++; } if(b[i]=='C'){ presum[i][5]++; } } } } int get_distance(int x, int y){ int mut[6]; for(int i=0; i<6; i++){ if(x>0){ mut[i]=presum[y][i]-presum[x-1][i]; } else{ mut[i]=presum[y][i]; } } if(mut[0]-mut[2]==mut[3]-mut[5]&&mut[0]-mut[2]==mut[4]-mut[1]){ return (2*max(mut[0], mut[2])+min(mut[1], mut[4])+min(mut[3], mut[5])-min(mut[0], mut[2])); } else{ return(-1); } }

Compilation message (stderr)

dna.cpp: In function 'void init(std::string, std::string)':
dna.cpp:6:19: 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++){
      |                  ~^~~~~~~~~
#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...