Submission #567937

#TimeUsernameProblemLanguageResultExecution timeMemory
567937sdfsdfsddfMutating DNA (IOI21_dna)C++17
0 / 100
32 ms4244 KiB
#include <bits/stdc++.h> #include "dna.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:14:22: 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 < s.length();i++){
      |                    ~~^~~~~~~~~~~~
dna.cpp:35:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   35 |     for(int i = 0; i < s.length();i++){
      |                    ~~^~~~~~~~~~~~
dna.cpp:54:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   54 |     for(int i = 0; i < s.length();i++){
      |                    ~~^~~~~~~~~~~~
dna.cpp:39:22: warning: array subscript 2 is above array bounds of 'int [2]' [-Warray-bounds]
   39 |         literki2[i][2] = t;
      |         ~~~~~~~~~~~~~^
dna.cpp:50:28: warning: array subscript 2 is above array bounds of 'int [2]' [-Warray-bounds]
   50 |             literki2[i][2] += 1;
      |             ~~~~~~~~~~~~~~~^~~~
dna.cpp:18:22: warning: array subscript 2 is above array bounds of 'int [2]' [-Warray-bounds]
   18 |         literki1[i][2] = t;
      |         ~~~~~~~~~~~~~^
dna.cpp:29:28: warning: array subscript 2 is above array bounds of 'int [2]' [-Warray-bounds]
   29 |             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...