Submission #1072021

#TimeUsernameProblemLanguageResultExecution timeMemory
1072021Ahmed57Mutating DNA (IOI21_dna)C++17
100 / 100
42 ms8524 KiB
#include "bits/stdc++.h" using namespace std; vector<int> A,B; int lo[100001][3][3]; void init(string a, string b){ for(auto i:a){ if(i=='A')A.push_back(0); else if(i=='T')A.push_back(1); else A.push_back(2); } for(auto i:b){ if(i=='A')B.push_back(0); else if(i=='T')B.push_back(1); else B.push_back(2); } for(int i = 0;i<A.size();i++){ lo[i][A[i]][B[i]]++; if(i){ for(int e = 0;e<3;e++)for(int g = 0;g<3;g++)lo[i][e][g]+=lo[i-1][e][g]; } } } int get_distance(int x, int y){ long long all =0; int lol[3][3]; for(int i = 0;i<3;i++){ for(int j = 0;j<3;j++){ lol[i][j] = lo[y][i][j]; if(x){ lol[i][j]-=lo[x-1][i][j]; } } } int aa[3] = {0}; int bb[3] = {0}; for(int i = 0;i<3;i++){ for(int j = 0;j<3;j++){ aa[i]+=lol[i][j]; bb[j]+=lol[i][j]; } } for(int i = 0;i<3;i++){ if(aa[i]!=bb[i])return -1; } for(int i = 0;i<3;i++){ lol[i][i] = 0; for(int j = i+1;j<3;j++){ int mi = min(lol[i][j],lol[j][i]); all+=mi; lol[i][j]-=mi; lol[j][i]-=mi; } } int su = 0; for(int i = 0;i<3;i++){ for(int j = 0;j<3;j++){ su+=lol[i][j]; } } all+=su/3*2; return all; }

Compilation message (stderr)

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