Submission #712499

#TimeUsernameProblemLanguageResultExecution timeMemory
712499KriptonMutating DNA (IOI21_dna)C++17
56 / 100
35 ms6584 KiB
#include <bits/stdc++.h> #include "dna.h" using namespace std; int a1[100001], a2[100001]; int c1[100001], c2[100001]; int t1[100001], t2[100001]; int diff[100001]; void init(string a, string b) { for(int i = 1; i <= a.size(); i++) { c1[i] = c1[i - 1] + (a[i - 1] == 'C'); a1[i] = a1[i - 1] + (a[i - 1] == 'A'); t1[i] = t1[i - 1] + (a[i - 1] == 'T'); c2[i] = c2[i - 1] + (b[i - 1] == 'C'); a2[i] = a2[i - 1] + (b[i - 1] == 'A'); t2[i] = t2[i - 1] + (b[i - 1] == 'T'); diff[i] = diff[i - 1] + (a[i - 1] != b[i - 1]); } } int get_distance(int x, int y) { x++; y++; if(c1[y] - c1[x - 1] != c2[y] - c2[x - 1]) return -1; if(a1[y] - a1[x - 1] != a2[y] - a2[x - 1]) return -1; if(t1[y] - t1[x - 1] != t2[y] - t2[x - 1]) return -1; return (diff[y] - diff[x - 1] + 1) / 2; }

Compilation message (stderr)

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