Submission #567936

#TimeUsernameProblemLanguageResultExecution timeMemory
567936sdfsdfsddfMutating DNA (IOI21_dna)C++17
0 / 100
33 ms5388 KiB
#include <bits/stdc++.h> using namespace std; const int max_n = 10e5+7; int literki1[max_n][2]{}; int literki2[max_n][2]{}; int do_zamiany[max_n]{}; void init(string s, string x){ int a = 0, c= 0, t =0; //a = 0 b = 1 c = 2 for(int i = 0; i < s.length();i++){ literki1[i][0] = a; literki1[i][1] = c; literki1[i][2] = t; if(s[i] == 'A'){ a++; literki1[i][0] += 1; } else if(s[i] == 'C'){ c++; literki1[i][1] += 1; } else{ t++; literki1[i][2] += 1; } } a = 0; c = 0; t = 0; for(int i = 0; i < s.length();i++){ literki2[i][0] = a; literki2[i][1] = c; literki2[i][2] = t; if(x[i] == 'A'){ a++; literki2[i][0] += 1; } else if(x[i] == 'C'){ c++; literki2[i][1] += 1; } else{ t++; literki2[i][2] += 1; } } int ile_zmienic = 0; for(int i = 0; i < s.length();i++){ if(s[i] != x[i]) ile_zmienic++; do_zamiany[i] = ile_zmienic; } } int get_distance(int x, int y){ int a1 = literki1[y][0]-literki1[x][0]; int c1 = literki1[y][1]-literki1[x][1]; int t1 = literki1[y][2]-literki1[x][2]; int a2 = literki1[y][0]-literki1[x][0]; int c2 = literki1[y][1]-literki1[x][1]; int t2 = literki1[y][2]-literki1[x][2]; if(a1 == a2 && c1 == c2 && t1 == t2){ int wyjscie = (do_zamiany[y]-do_zamiany[x]+1)/2; return wyjscie; } else{ return -1; } }

Compilation message (stderr)

dna.cpp: In function 'void init(std::string, std::string)':
dna.cpp:13:22: 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 = 0; i < s.length();i++){
      |                    ~~^~~~~~~~~~~~
dna.cpp:34:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |     for(int i = 0; i < s.length();i++){
      |                    ~~^~~~~~~~~~~~
dna.cpp:53:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   53 |     for(int i = 0; i < s.length();i++){
      |                    ~~^~~~~~~~~~~~
dna.cpp:38:22: warning: array subscript 2 is above array bounds of 'int [2]' [-Warray-bounds]
   38 |         literki2[i][2] = t;
      |         ~~~~~~~~~~~~~^
dna.cpp:49:28: warning: array subscript 2 is above array bounds of 'int [2]' [-Warray-bounds]
   49 |             literki2[i][2] += 1;
      |             ~~~~~~~~~~~~~~~^~~~
dna.cpp:17:22: warning: array subscript 2 is above array bounds of 'int [2]' [-Warray-bounds]
   17 |         literki1[i][2] = t;
      |         ~~~~~~~~~~~~~^
dna.cpp:28:28: warning: array subscript 2 is above array bounds of 'int [2]' [-Warray-bounds]
   28 |             literki1[i][2] += 1;
      |             ~~~~~~~~~~~~~~~^~~~
#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...