Submission #930426

#TimeUsernameProblemLanguageResultExecution timeMemory
930426SmuggingSpunMutating DNA (IOI21_dna)C++17
0 / 100
23 ms4884 KiB
#include "dna.h" #include<bits/stdc++.h> using namespace std; const int lim = 1e5 + 5; int A[lim], T[lim], C[lim], _A[lim], _T[lim], _C[lim]; void init(string a, string b){ for(int i = A[0] = T[0] = C[0] = 0; i < a.size(); i++){ A[i + 1] = A[i]; T[i + 1] = T[i]; C[i + 1] = C[i]; _A[i + 1] = _A[i]; _T[i + 1] = _T[i]; _C[i + 1] = _C[i]; if(a[i] != b[i]){ if(a[i] == 'A'){ A[i + 1]++; } else if(a[i] == 'T'){ T[i + 1]++; } else{ C[i + 1]++; } if(b[i] == 'A'){ _A[i + 1]++; } else if(b[i] == 'T'){ _T[i + 1]++; } else{ _C[i + 1]++; } } } } int get_distance(int x, int y) { x++; y++; int count_a = A[y] - A[x - 1], count_t = T[y] - T[x - 1], count_c = C[y] - C[x - 1]; if(count_a == _A[y] - _A[x - 1] && count_t == _T[y] - T[x - 1] && count_c == _C[y] - _C[x - 1]){ int cnt = min({count_a, count_t, count_c}); return (cnt << 1) + (((count_a + count_t + count_c) - 3 * cnt) >> 1); } return -1; }

Compilation message (stderr)

dna.cpp: In function 'void init(std::string, std::string)':
dna.cpp:7:40: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    7 |  for(int i = A[0] = T[0] = C[0] = 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...