Submission #938725

#TimeUsernameProblemLanguageResultExecution timeMemory
938725Hugo1729Mutating DNA (IOI21_dna)C++17
Compilation error
0 ms0 KiB
#include "dna.h" #include <bits/stdc++.h> using namespace std; string a,b; int n; int pref[100001][3][3]={0},pa[100001][3]={0},pb[100001][3]={0}; map<char,int> m; void init(string c, string d) { a=c;b=d; n=a.size(); m['A']=0; m['C']=1; m['T']=2; for(int i=0;i<n;i++){ for(int j=0;j<3;j++){ pa[i+1][j]=pa[i][j]; pb[i+1][j]=pb[i][j]; for(int k=0;k<3;k++){ pref[i+1][j][k]=pref[i+1][j][k]; } } pa[i+1][m[a[i]]]++; pb[i+1][m[b[i]]]++; pref[i+1][m[a[i]]][m[b[i]]]++; } } int get_distance(int x, int y) { int dista1=pa[y+1][0]-pa[x][0]; int distb1=pb[y+1][0]-pb[x][0]; int dista2=pa[y+1][1]-pa[x][1]; int distb2=pb[y+1][1]-pb[x][1]; if(dista1==distb1&&dista2==distb2){ int ans=0,l=y-x+1; for(int i=0;i<3;i++){ int sus1=pref[y+1][i][j]-pref[x][i][j]; int sus2=pref[y+1][j][i]-pref[x][j][i]; for(int j=0;j<=i;j++){ if(i==j)l-=sus1; else{ sussy=min(sus1,sus2); l-=2*sussy; ans+=sussy; } } } int among=l/3; ans+=among*2; return ans; } else return -1; }

Compilation message (stderr)

dna.cpp: In function 'int get_distance(int, int)':
dna.cpp:40:26: error: 'j' was not declared in this scope
   40 |    int sus1=pref[y+1][i][j]-pref[x][i][j];
      |                          ^
dna.cpp:45:6: error: 'sussy' was not declared in this scope
   45 |      sussy=min(sus1,sus2);
      |      ^~~~~