Submission #607251

#TimeUsernameProblemLanguageResultExecution timeMemory
607251wiktorlewMutating DNA (IOI21_dna)C++17
56 / 100
36 ms6048 KiB
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 5; int ile[N][3][2], line[N][3]; int tsf(char c){ if(c=='A') return 0; if(c=='C') return 1; if(c=='T') return 2; } void init(string a, string b){ for(int i=0;i<a.length();i++){ ile[i+1][tsf(a[i])][0]++; ile[i+1][tsf(b[i])][1]++; if((a[i]=='A'&&b[i]=='C')||(a[i]=='C'&&b[i]=='A')) line[i+1][0]++; if((a[i]=='A'&&b[i]=='T')||(a[i]=='T'&&b[i]=='A')) line[i+1][1]++; if((a[i]=='C'&&b[i]=='T')||(a[i]=='T'&&b[i]=='C')) line[i+1][2]++; for(int j=0;j<=2;j++){ ile[i+1][j][0]+=ile[i][j][0]; ile[i+1][j][1]+=ile[i][j][1]; line[i+1][j]+=line[i][j]; } } } int get_distance(int x, int y){ x++; y++; if(ile[y][0][0]-ile[x-1][0][0]!=ile[y][0][1]-ile[x-1][0][1]){ return -1; } if(ile[y][1][0]-ile[x-1][1][0]!=ile[y][1][1]-ile[x-1][1][1]){ return -1; } if(ile[y][2][0]-ile[x-1][2][0]!=ile[y][2][1]-ile[x-1][2][1]){ return -1; } int wynik=0, err=0; for(int i=0;i<=2;i++){ int pom = line[y][i]-line[x-1][i]; wynik+=pom/2; if(pom%2) err++; } assert(err%3==0); wynik+=(err/3)*2; return wynik; }

Compilation message (stderr)

dna.cpp: In function 'void init(std::string, std::string)':
dna.cpp:11:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   11 |  for(int i=0;i<a.length();i++){
      |              ~^~~~~~~~~~~
dna.cpp: In function 'int tsf(char)':
dna.cpp:9:1: warning: control reaches end of non-void function [-Wreturn-type]
    9 | }
      | ^
#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...