Submission #689552

#TimeUsernameProblemLanguageResultExecution timeMemory
689552ToxtaqMutating DNA (IOI21_dna)C++17
21 / 100
33 ms4912 KiB
#include<bits/stdc++.h> #include "dna.h" using namespace std; struct ATC{ int A = 0, T = 0, C = 0; }; vector<ATC>cnt_A, cnt_B; vector<int>pref; void init(string A, string B){ pref.resize(A.length() + 1); cnt_A.resize(A.length() + 1); cnt_B.resize(A.length() + 1); for(int i = 1;i <= A.length();++i){ pref[i] = pref[i - 1]; if(A[i - 1] != B[i - 1])pref[i]++; } for(int i = 1;i <= A.length();++i){ cnt_A[i].A = cnt_A[i - 1].A; cnt_A[i].T = cnt_A[i - 1].T; cnt_A[i].C = cnt_A[i - 1].C; if(A[i - 1] == 'A')cnt_A[i].A++; if(A[i - 1] == 'T')cnt_A[i].T++; if(A[i - 1] == 'C')cnt_A[i].C++; } for(int i = 1;i <= A.length();++i){ cnt_B[i].A = cnt_B[i - 1].A; cnt_B[i].T = cnt_B[i - 1].T; cnt_B[i].C = cnt_B[i - 1].C; if(B[i - 1] == 'A')cnt_B[i].A++; if(B[i - 1] == 'T')cnt_B[i].T++; if(B[i - 1] == 'C')cnt_B[i].C++; } } int get_distance(int x, int y){ x++; y++; int q = pref[y] - pref[x - 1]; ATC num1, num2; num1.A = cnt_A[y].A - cnt_A[x - 1].A; num1.T = cnt_A[y].T - cnt_A[x - 1].T; num1.C = cnt_A[y].C - cnt_A[x - 1].C; num2.A = cnt_B[y].A - cnt_B[x - 1].A; num2.T = cnt_B[y].T - cnt_B[x - 1].T; num2.C = cnt_B[y].C - cnt_B[x - 1].C; // cout << num1.A << " " << num1.T << " " << num1.C << '\n'; // cout << num2.A << " " << num2.T << " " << num2.C; if(num1.A != num2.A)return -1; if(num1.T != num2.T)return -1; if(num1.C != num2.C)return -1; if(!q)return 0; return q - 1; } //int main(){ // init("CTA", "ATC"); // cout << get_distance(0, 2); //}

Compilation message (stderr)

dna.cpp: In function 'void init(std::string, std::string)':
dna.cpp:13:21: 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 = 1;i <= A.length();++i){
      |                   ~~^~~~~~~~~~~~~
dna.cpp:18:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   18 |     for(int i = 1;i <= A.length();++i){
      |                   ~~^~~~~~~~~~~~~
dna.cpp:26:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |     for(int i = 1;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...