Submission #541298

#TimeUsernameProblemLanguageResultExecution timeMemory
541298AlesL0Mutating DNA (IOI21_dna)C++17
56 / 100
34 ms5396 KiB
#include <iostream> using namespace std; int a1[100001], a2[100001], t1[100001], t2[100001], c1[100001], c2[100001], f[100001]; void init(string a, string b){ //a1.resize(n+1); a2.resize(n+1); t1.resize(n+1); t2.resize(n+1); c1.resize(n+1); c2.resize(n+1); f.resize(n+1); a1[0] = 0; a2[0] = 0; t1[0] = 0; t2[0] = 0; c1[0] = 0; c2[0] = 0; f[0] = 0; for (int i = 0; i < a.size(); i++){ a1[i+1] = a1[i]; a2[i+1] = a2[i]; t1[i+1] = t1[i]; t2[i+1] = t2[i]; c1[i+1] = c1[i]; c2[i+1] = c2[i]; f[i+1] = f[i]; if (a[i] == 'A')a1[i+1]++; else if (a[i] == 'T')t1[i+1]++; else c1[i+1]++; if (b[i] == 'A')a2[i+1]++; else if (b[i] == 'T')t2[i+1]++; else c2[i+1]++; if (a[i] != b[i])f[i+1]++; } } int get_distance(int x, int y){ if (((a1[y+1]-a1[x])==(a2[y+1]-a2[x])) && ((t1[y+1]-t1[x])==(t2[y+1]-t2[x])) && ((c1[y+1]-c1[x])==(c2[y+1]-c2[x]))){ int h = f[y+1]-f[x]; if (h%2 == 0)return (h/2); else return ((h+1)/2); } else return -1; }

Compilation message (stderr)

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