Submission #440065

#TimeUsernameProblemLanguageResultExecution timeMemory
440065abekerMutating DNA (IOI21_dna)C++17
0 / 100
40 ms5636 KiB
#include <bits/stdc++.h> #include "dna.h" using namespace std; const int MAXN = 1e5 + 5; const char DNA[] = "ACT"; int cnt[MAXN][3][3]; int get_id(char c) { return strchr(DNA, c) - DNA; } void init(string a, string b) { for (int i = 0; i < a.size(); i++) { if (i) memcpy(cnt[i], cnt[i - 1], sizeof cnt[i]); cnt[i][get_id(a[i])][get_id(b[i])]++; } } int get_cnt(int x, int y, int i, int j) { return cnt[y][i][j] - (x ? cnt[x - 1][i][j] : 0); } int get_distance(int x, int y) { int res = 0; for (int i = 0; i < 3; i++) for (int j = 0; j < i; j++) { int p = get_cnt(x, y, i, j); int q = get_cnt(x, y, j, i); if (p < q) swap(p, q); res += (2 * p + q - 1) / 3 + 1; } return res; }

Compilation message (stderr)

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