Submission #712498

#TimeUsernameProblemLanguageResultExecution timeMemory
712498KriptonMutating DNA (IOI21_dna)C++17
0 / 100
33 ms6284 KiB
#include <bits/stdc++.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 = 0; i < a.size(); i++) { c1[i] = c1[i - 1] + (a[i] == 'c'); a1[i] = a1[i - 1] + (a[i] == 'a'); t1[i] = t1[i - 1] + (a[i] == 't'); c2[i] = c2[i - 1] + (b[i] == 'c'); a2[i] = a2[i - 1] + (b[i] == 'a'); t2[i] = t2[i - 1] + (b[i] == 't'); diff[i] = diff[i - 1] + (a[i] != b[i]); } } 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]) / 2; }

Compilation message (stderr)

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