Submission #437986

#TimeUsernameProblemLanguageResultExecution timeMemory
437986ToroTNMutating DNA (IOI21_dna)C++17
100 / 100
50 ms7056 KiB
#include<bits/stdc++.h> using namespace std; #include "dna.h" int qs[100005][10],arr[10]; char one[10],two[10],alpha[]={'A','T','C'}; void init(std::string a, std::string b) { for(int i=0;i<3;i++) { for(int j=0;j<3;j++) { one[3*i+j+1]=alpha[i]; two[3*i+j+1]=alpha[j]; } } /*for(int i=1;i<=9;i++) { printf("%c %c\n",one[i],two[i]); }*/ for(int i=0;i<a.size();i++) { for(int j=1;j<=9;j++) { if(one[j]==a[i]&&two[j]==b[i]) { qs[i+1][j]=qs[i][j]+1; }else { qs[i+1][j]=qs[i][j]; } } } /*for(int i=1;i<=9;i++) { printf("%d %c %c\n",i,one[i],two[i]); for(int j=1;j<=a.size();j++) { printf("%d ",qs[j][i]); } printf("\n"); }*/ } int get_distance(int x, int y) { for(int i=1;i<=9;i++) { arr[i]=qs[y+1][i]-qs[x][i]; } /*for(int i=1;i<=9;i++) { printf("%d ",arr[i]); } printf("\n");*/ if(arr[2]-arr[4]==arr[6]-arr[8]&&arr[2]-arr[4]==arr[7]-arr[3]) { if(arr[2]>arr[4]) { return arr[4]+arr[8]+arr[3]+(arr[2]-arr[4])*2; }else { return arr[2]+arr[6]+arr[7]+(arr[4]-arr[2])*2; } }else { return -1; } }

Compilation message (stderr)

dna.cpp: In function 'void init(std::string, std::string)':
dna.cpp:20:15: 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.size();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...