제출 #831775

#제출 시각아이디문제언어결과실행 시간메모리
831775MrDebooMutating DNA (IOI21_dna)C++17
컴파일 에러
0 ms0 KiB
#include "dna.h"
#include "bits/stdc++.h"
using namespace std;
int n;
int g[3][3][100000];
string f="ACT";
void init(std::string a, std::string b) {
	n=a.size();
	for(int i=0;i<3;i++){
		for(int w=i;w<3;w++){
			for(int j=0;j<n;j++){
				if(a[j]==f[i]&&b[j]==f[w])g[i][w][j]++;
			}
			if(j)g[i][w][j]+=g[i][w][j-1];
		}
	}
}

int get_distance(int l, int r) {
	int G[3][3];
	for(int i=0;i<3;i++){
		for(int w=0;w<3;w++)G[i][w]=g[i][w][r]-(l==0?0:g[i][w][l-1]);
	}
	int ans=G[0][1]+G[1][2]+G[0][2],a=n-ans*2-G[0][0]-G[1][1]-G[2][2];
	return ans+(a/3)*2;
}

컴파일 시 표준 에러 (stderr) 메시지

dna.cpp: In function 'void init(std::string, std::string)':
dna.cpp:14:7: error: 'j' was not declared in this scope
   14 |    if(j)g[i][w][j]+=g[i][w][j-1];
      |       ^