제출 #981503

#제출 시각아이디문제언어결과실행 시간메모리
981503faqinyeagerDNA 돌연변이 (IOI21_dna)C++17
컴파일 에러
0 ms0 KiB
#include "dna.h"
#include <bits/stdc++.h>

int n, a_cnt, b_cnt;
int asum[100050][3], bsm[100050][3];

void init(std::string a, std::string b){
	n = (int)a.size();
	for(int i = 0; i < n; i++){
		asum[i][a[i] - 'A'] ++;
		bsum[i][b[i] - 'A'] ++;
	}
	for(int i = 1; i < n; i++){
		for(int j = 0; j < 3; j++){
			asum[i][j] += asum[i - 1][j];
			bsum[i][j] += bsum[i - 1][j]; 
		}
	}
}

int get_distance(int x, int y){
	for(int j = 0; j < 3; j++){
		if(asum[y][j] - asum[x - 1][j] != bsum[y][j] - bsum[x - 1][j]){
			return -1;
		} 
	}
	int cnt = 0;
	for(int i = x; i < y; i++){
		if(a[i] != b[i]){
			cnt++;
		}
	}
	return (cnt + 1) / 2;
}

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

dna.cpp: In function 'void init(std::string, std::string)':
dna.cpp:11:3: error: 'bsum' was not declared in this scope; did you mean 'bsm'?
   11 |   bsum[i][b[i] - 'A'] ++;
      |   ^~~~
      |   bsm
dna.cpp:16:4: error: 'bsum' was not declared in this scope; did you mean 'bsm'?
   16 |    bsum[i][j] += bsum[i - 1][j];
      |    ^~~~
      |    bsm
dna.cpp: In function 'int get_distance(int, int)':
dna.cpp:23:37: error: 'bsum' was not declared in this scope; did you mean 'bsm'?
   23 |   if(asum[y][j] - asum[x - 1][j] != bsum[y][j] - bsum[x - 1][j]){
      |                                     ^~~~
      |                                     bsm
dna.cpp:29:6: error: 'a' was not declared in this scope
   29 |   if(a[i] != b[i]){
      |      ^
dna.cpp:29:14: error: 'b' was not declared in this scope
   29 |   if(a[i] != b[i]){
      |              ^