제출 #938725

#제출 시각아이디문제언어결과실행 시간메모리
938725Hugo1729DNA 돌연변이 (IOI21_dna)C++17
컴파일 에러
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; }

컴파일 시 표준 에러 (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);
      |      ^~~~~