Submission #1069929

#TimeUsernameProblemLanguageResultExecution timeMemory
1069929erdemfurkanMutating DNA (IOI21_dna)C++17
0 / 100
23 ms6652 KiB
#include "bits/stdc++.h" using namespace std; string A; string B; int prea[3][100007]; int preb[3][100007]; int prec[100007]; void init(string a, string b) { A = a; B = b; for(int i = 0; i < A.length(); i++) { prea[0][i+1] = prea[0][i] + (A[i] == 'A'); } for(int i = 0; i < A.length(); i++) { prea[1][i+1] = prea[1][i] + (A[i] == 'T'); } for(int i = 0; i < A.length(); i++) { prea[2][i+1] = prea[2][i] + (A[i] == 'C'); } for(int i = 0; i < B.length(); i++) { preb[0][i+1] = preb[0][i] + (B[i] == 'A'); } for(int i = 0; i < B.length(); i++) { preb[1][i+1] = preb[1][i] + (B[i] == 'T'); } for(int i = 0; i < B.length(); i++) { preb[2][i+1] = preb[2][i] + (B[i] == 'C'); } for(int i = 0; i < A.length(); i++) { prec[i+1] = prec[i] + (A[i] == B[i]); } } int get_distance(int x, int y) { x++; y++; int i = prea[0][y] - prea[0][x-1]; int j = prea[1][y] - prea[1][x-1]; int k = prea[2][y] - prea[2][x-1]; int ii = preb[0][y] - preb[0][x-1]; int jj = preb[1][y] - preb[1][x-1]; int kk = preb[2][y] - preb[2][x-1]; if(ii != i || jj != j || kk != k) { return -1; } int l = y-x+1; return (l - (prec[y] - prec[x-1] + 1))/2; }

Compilation message (stderr)

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