Submission #844326

#TimeUsernameProblemLanguageResultExecution timeMemory
84432612345678Mutating DNA (IOI21_dna)C++17
0 / 100
24 ms4944 KiB
#include "dna.h" #include <bits/stdc++.h> using namespace std; const int nx=1e5+5; int A[nx][3], B[nx][3], mp[27]; string sa, sb; void init(std::string a, std::string b) { mp['A']=0; mp['T']=1; mp['C']=2; for (int i=1; i<=a.size(); i++) A[i][0]=A[i-1][0], A[i][1]=A[i-1][1], A[i][2]=A[i-1][2], A[i][mp[a[i-1]]]++; for (int i=1; i<=b.size(); i++) B[i][0]=B[i-1][0], B[i][1]=B[i-1][1], B[i][2]=B[i-1][2], B[i][mp[b[i-1]]]++; sa=a; sb=b; } int get_distance(int x, int y) { x++; y++; int cnt=0; bool can=1; for (int i=0; i<3; i++) if (A[y][i]-A[x-1][i]!=B[y][i]-B[x-1][i]) can=0; if (!can) return -1; for (int i=x; i<=y; i++) { if (sa[i-1]!=sb[i-1]) cnt++; } return cnt/2; }

Compilation message (stderr)

dna.cpp: In function 'void init(std::string, std::string)':
dna.cpp:12:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   12 |  for (int i=1; i<=a.size(); i++) A[i][0]=A[i-1][0], A[i][1]=A[i-1][1], A[i][2]=A[i-1][2], A[i][mp[a[i-1]]]++;
      |                ~^~~~~~~~~~
dna.cpp:12:105: warning: array subscript has type 'char' [-Wchar-subscripts]
   12 |  for (int i=1; i<=a.size(); i++) A[i][0]=A[i-1][0], A[i][1]=A[i-1][1], A[i][2]=A[i-1][2], A[i][mp[a[i-1]]]++;
      |                                                                                                         ^
dna.cpp:13:17: 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<=b.size(); i++) B[i][0]=B[i-1][0], B[i][1]=B[i-1][1], B[i][2]=B[i-1][2], B[i][mp[b[i-1]]]++;
      |                ~^~~~~~~~~~
dna.cpp:13:105: warning: array subscript has type 'char' [-Wchar-subscripts]
   13 |  for (int i=1; i<=b.size(); i++) B[i][0]=B[i-1][0], B[i][1]=B[i-1][1], B[i][2]=B[i-1][2], B[i][mp[b[i-1]]]++;
      |                                                                                                         ^
dna.cpp:11:8: warning: array subscript 65 is above array bounds of 'int [27]' [-Warray-bounds]
   11 |  mp['A']=0; mp['T']=1; mp['C']=2;
      |  ~~~~~~^
dna.cpp:11:19: warning: array subscript 84 is above array bounds of 'int [27]' [-Warray-bounds]
   11 |  mp['A']=0; mp['T']=1; mp['C']=2;
      |             ~~~~~~^
dna.cpp:11:30: warning: array subscript 67 is above array bounds of 'int [27]' [-Warray-bounds]
   11 |  mp['A']=0; mp['T']=1; mp['C']=2;
      |                        ~~~~~~^
#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...