제출 #818132

#제출 시각아이디문제언어결과실행 시간메모리
818132alvingogoDNA 돌연변이 (IOI21_dna)C++17
컴파일 에러
0 ms0 KiB
#include "dna.h"
#include <bits/stdc++.h>
#define fs first
#define sc second
#define p_q priority_queue
using namespace std;

int n;
vector<int> pre[3][3],pre2[3],pre3[3];
void init(string a, string b) {
	map<char,int> m;
	m['A']=0;
	m['C']=1;
	m['T']=2;
	n=a.length();
	for(int i=0;i<3;i++){
		for(int j=0;j<3;j++){
			pre[i][j].resize(n);
		}
		pre2[i].resize(n);
		pre3[i].resize(n);
	}
	for(int i=0;i<n;i++){
		pre[m[a[i]]][m[b[i]]][i]++;
		pre2[m[a[i]]][i]++;
		pre3[m[b[i]]][i]++;
	}
	for(int i=1;i<n;i++){
		for(int j=0;j<3;j++){
			for(int k=0;k<3;k++){
				pre[j][k][i]+=pre[j][k][i-1];
			}
			pre2[j][i]+=pre2[j][i-1];
			pre3[j][i]+=pre3[j][i-1];
		}
	}
}

int get_distance(int x, int y) {
	int z[3][3]={0},s[3]={0};
	for(int i=0;i<3;i++){
		for(int j=0;j<3;j++){
			z[i][j]=pre[i][j][y];
			if(x){
				z[i][j]-=pre[i][j][x-1];
			}
		}
		s[i]+=pre2[y];
		s[i]-=pre3[y];
		if(x){
			s[i]-=pre2[x-1];
			s[i]+=pre3[x-1];
		}
	}
	if(s[0] || s[1] || s[2]){
		return -1;
	}
	int ans=0;
	ans+=min(z[0][1],z[1][0]);
	ans+=min(z[0][2],z[2][0]);
	ans+=min(z[1][2],z[2][1]);
	int a=z[1][0]+z[0][1]-2*min(z[0][1],z[1][0]);
	int b=z[1][2]+z[2][1]-2*min(z[2][1],z[1][2]);
	int c=z[2][0]+z[0][2]-2*min(z[0][2],z[2][0]);
	if(a!=b || b!=c){
		return -1;
	}
	return ans+2*a;
}

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

dna.cpp: In function 'int get_distance(int, int)':
dna.cpp:48:7: error: no match for 'operator+=' (operand types are 'int' and 'std::vector<int>')
   48 |   s[i]+=pre2[y];
      |   ~~~~^~~~~~~~~
dna.cpp:49:7: error: no match for 'operator-=' (operand types are 'int' and 'std::vector<int>')
   49 |   s[i]-=pre3[y];
      |   ~~~~^~~~~~~~~
dna.cpp:51:8: error: no match for 'operator-=' (operand types are 'int' and 'std::vector<int>')
   51 |    s[i]-=pre2[x-1];
      |    ~~~~^~~~~~~~~~~
dna.cpp:52:8: error: no match for 'operator+=' (operand types are 'int' and 'std::vector<int>')
   52 |    s[i]+=pre3[x-1];
      |    ~~~~^~~~~~~~~~~