Submission #483596

#TimeUsernameProblemLanguageResultExecution timeMemory
483596ponytailMutating DNA (IOI21_dna)C++17
21 / 100
37 ms4488 KiB
#include "dna.h" #include <string> #include <bits/stdc++.h> using namespace std; void init(std::string a, std::string b); int get_distance(int x, int y); int ps[6][100000]; void init(std::string a, std::string b) { string patt[6] = {"CA", "AC", "TA", "AT", "CT", "TC"}; for(int i=0; i<a.size(); i++) { for(int j=0; j<6; j++) { string now; now += a[i]; now += b[i]; ps[j][i] = (i==0 ? 0 : ps[j][i-1]) + (now == patt[j]); } } } int get_distance(int x, int y) { int res[6]; for(int i=0; i<6; i++) res[i] = ps[i][y] - (x==0 ? 0 : ps[i][x-1]); if(res[0] + res[4] != res[1] + res[5]) return -1; if(res[1] + res[3] != res[0] + res[2]) return -1; if(res[2] + res[5] != res[3] + res[4]) return -1; int ans = min(res[0], res[1]) + min(res[2], res[3]) + min(res[4], res[5]); res[0] -= min(res[0], res[1]); res[1] -= min(res[0], res[1]); res[2] -= min(res[2], res[3]); res[3] -= min(res[2], res[3]); res[4] -= min(res[4], res[5]); res[5] -= min(res[4], res[5]); int sum = 0; for(int i=0; i<6; i++) sum += res[i]; ans += max(0, sum - 1); return ans; }

Compilation message (stderr)

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