제출 #437250

#제출 시각아이디문제언어결과실행 시간메모리
437250irmuunDNA 돌연변이 (IOI21_dna)C++17
컴파일 에러
0 ms0 KiB
#include<bits/stdc++.h>
#include "dna.h"
using namespace std;
string A,B;
int p[100001][3][3],i,c,d,e,f,g,j,k,h[3][3],ch[100001][3],ch1[100001][3],dif[2][3],ans;
void init(string a,string b){
  for(i=0;i<3;i++){
    ch[0][i]=0;
    ch1[0][i]=0;
    for(j=0;j<3;j++){
      p[0][i][j]=0;
    }
  }
  for(i=0;i<a.size();i++){
    if(a[i]=='A'){
      d=0;
    }
    else if(a[i]=='C'){
      d=1;
    }
    else{
      d=2;
    }
    if(b[i]=='A'){
      e=0;
    }
    else if(b[i]=='C'){
      e=1;
    }
    else{
      e=2;
    }
    for(j=0;j<3;j++){
      if(j==d){
      	ch[i+1][j]=ch[i][j]+1;
      }
      else{
        ch[i+1][j]=ch[i][j];
      }
      if(j==e){
      	ch1[i+1][j]=ch1[i][j]+1;
      }
      else{
        ch1[i+1][j]=ch1[i][j];
      }
      for(k=0;k<3;k++){
        if(j==d&&k==e){
          p[i+1][j][k]=p[i][j][k]+1;
        }
        else{
          p[i+1][j][k]=p[i][j][k];
        }
      }
    }
  }
}
int get_distanse(int x,int y){
  ans=0;
  for(i=0;i<3;i++){
    dif[0][0]=ch[y+1][0]-ch[x][0];
    dif[0][1]=ch[y+1][1]-ch[x][1];
    dif[0][2]=ch[y+1][2]-ch[x][2];
    dif[1][0]=ch1[y+1][0]-ch1[x][0];
    dif[1][1]=ch1[y+1][1]-ch1[x][1];
    dif[1][2]=ch1[y+1][2]-ch1[x][2];
    for(j=0;j<3;j++){
      h[i][j]=p[y+1][i][j]-p[x][i][j];
    }
  }
  if(dif[0][0]!=dif[1][0]||dif[0][1]!=dif[1][1]||dif[0][2]!=dif[1][2]){
    return -1;
  }
  f=min(h[0][1],min(h[1][2],h[2][0]));
  g=min(h[1][0],min(h[2][1],h[0][2]));
  ans+=(f+g)*2;
  h[0][1]-=f;
  h[1][2]-=f;
  h[2][0]-=f;
  h[1][0]-=g;
  h[2][1]-=g;
  h[0][2]-=g;
  return ans+h[0][1]+h[1][2]+h[2][0];
}

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

dna.cpp: In function 'void init(std::string, std::string)':
dna.cpp:14:12: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   14 |   for(i=0;i<a.size();i++){
      |           ~^~~~~~~~~
/usr/bin/ld: /tmp/ccoapk4T.o: in function `main':
grader.cpp:(.text.startup+0x39d): undefined reference to `get_distance(int, int)'
collect2: error: ld returned 1 exit status