Submission #443408

#TimeUsernameProblemLanguageResultExecution timeMemory
443408Aryan_RainaMutating DNA (IOI21_dna)C++17
100 / 100
54 ms9404 KiB
#include "dna.h" #include <bits/stdc++.h> using namespace std; #define ar array #define all(a) a.begin(), a.end() int id(char x) { if (x == 'A') return 0; else if (x == 'C') return 1; else if (x == 'T') return 2; return -1; } const int MXN = 100009; int cnt[MXN][3][3], tota[MXN][3], totb[MXN][3]; void init(string a, string b) { for (int i = 0; i < a.size(); i++) { for (int j = 0; j < 3; j++) for (int k = 0; k < 3; k++) cnt[i+1][j][k] = cnt[i][j][k]; cnt[i+1][id(a[i])][id(b[i])]++; for (int j = 0; j < 3; j++) { tota[i+1][j] = tota[i][j]; totb[i+1][j] = totb[i][j]; } tota[i+1][id(a[i])]++; totb[i+1][id(b[i])]++; } } int get_distance(int x, int y) { ++x, ++y; for (int i = 0; i < 3; i++) if (tota[y][i]-tota[x-1][i] != totb[y][i]-totb[x-1][i]) return -1; int A[3][3]; for (int i = 0; i < 3; i++) for (int j = 0; j < 3; j++) A[i][j] = cnt[y][i][j]-cnt[x-1][i][j]; int ans = 0; ans += min(A[0][1],A[1][0]); ans += min(A[1][2],A[2][1]); ans += min(A[2][0],A[0][2]); ans += 2 * (max(A[0][1],A[1][0])-min(A[0][1],A[1][0])); return ans; }

Compilation message (stderr)

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