Submission #1060346

#TimeUTC-0UsernameProblemLanguageResultExecution timeMemory
10603462024-08-15 13:11:45tolbiMutating DNA (IOI21_dna)C++17
0 / 100
20 ms4624 KiB
#include "dna.h"
#include <bits/stdc++.h>
using namespace std;
vector<array<int,6>> pref;
void init(std::string a, std::string b) {
pref.clear();
pref.resize(a.length()+1,array<int,6>());
for (int i = 0; i < a.length(); i++){
if (a[i]=='A' && b[i]=='C') pref[i+1][0]=1;
if (a[i]=='A' && b[i]=='T') pref[i+1][1]=1;
if (a[i]=='T' && b[i]=='A') pref[i+1][2]=1;
if (a[i]=='T' && b[i]=='C') pref[i+1][3]=1;
if (a[i]=='C' && b[i]=='A') pref[i+1][4]=1;
if (a[i]=='C' && b[i]=='T') pref[i+1][5]=1;
for (int j = 0; j < 6; j++){
pref[i+1][j]+=pref[i][j];
}
}
}
int get_distance(int x, int y) {
int ac = pref[y+1][0]-pref[x][0];
int at = pref[y+1][1]-pref[x][1];
int ta = pref[y+1][2]-pref[x][2];
int tc = pref[y+1][3]-pref[x][3];
int ca = pref[y+1][4]-pref[x][4];
int ct = pref[y+1][5]-pref[x][5];
int ans = min(ac,ca)+min(tc,ct)+min(at,ta);
if (ac>ca){
ac-=ca;
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Compilation message (stderr)

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