제출 #1018314

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

using namespace std;
int ps[mxN][3][2], pr[mxN][6];

void init(std::string a, std::string b) {
    int n=a.size();
    a='i'+a, b='i'+b;
    for(int i=1; i<=n; ++i) {
        ps[i][0][0]=ps[i-1][0][0];
        ps[i][1][0]=ps[i-1][1][0];
        ps[i][2][0]=ps[i-1][2][0];
        ps[i][0][1]=ps[i-1][0][1];
        ps[i][1][1]=ps[i-1][1][1];
        ps[i][2][1]=ps[i-1][2][1];
        if(a[i]=='A') ++ps[i][0][0];
        else if(a[i]=='C') ++ps[i][1][0];
        else ++ps[i][2][0];
        if(b[i]=='A') ++ps[i][0][1];
        else if(b[i]=='C') ++ps[i][1][1];
        else ++ps[i][2][1];
        for(int j=0; j<6; ++j) pr[i][j]=pr[i-1][j];
        if(a[i]=='A'&&b[i]=='C') ++pr[i][0];
        if(a[i]=='C'&&b[i]=='A') ++pr[i][1];
        if(a[i]=='A'&&b[i]=='T') ++pr[i][2];
        if(a[i]=='T'&&b[i]=='A') ++pr[i][3];
        if(a[i]=='C'&&b[i]=='T') ++pr[i][4];
        if(a[i]=='T'&&b[i]=='C') ++pr[i][5];
    }
}

int get_distance(int x, int y) {
    ++x, ++y;
    for(int i=0; i<3; ++i) {
        if((ps[y][i][0]-ps[x-1][i][0])!=(ps[y][i][1]-ps[x-1][i][1])) {
            return -1;
        }
    }
    vector<int> v;
    for(int i=0; i<6; ++i) v.push_back(pr[y+1][i]-pr[x][0]);
    int p=min(v[0], v[1]), q=min(v[2], v[3]), r=min(v[4], v[5]);
    v[0]-=p, v[1]-=p;
    int ans=p+q+r;
    ans+=2*max(v[0], v[1]);
    return ans;
}

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

dna.cpp:5:8: error: 'mxN' was not declared in this scope
    5 | int ps[mxN][3][2], pr[mxN][6];
      |        ^~~
dna.cpp:5:23: error: 'mxN' was not declared in this scope
    5 | int ps[mxN][3][2], pr[mxN][6];
      |                       ^~~
dna.cpp: In function 'void init(std::string, std::string)':
dna.cpp:11:9: error: 'ps' was not declared in this scope
   11 |         ps[i][0][0]=ps[i-1][0][0];
      |         ^~
dna.cpp:23:32: error: 'pr' was not declared in this scope
   23 |         for(int j=0; j<6; ++j) pr[i][j]=pr[i-1][j];
      |                                ^~
dna.cpp:24:36: error: 'pr' was not declared in this scope
   24 |         if(a[i]=='A'&&b[i]=='C') ++pr[i][0];
      |                                    ^~
dna.cpp:25:36: error: 'pr' was not declared in this scope
   25 |         if(a[i]=='C'&&b[i]=='A') ++pr[i][1];
      |                                    ^~
dna.cpp:26:36: error: 'pr' was not declared in this scope
   26 |         if(a[i]=='A'&&b[i]=='T') ++pr[i][2];
      |                                    ^~
dna.cpp:27:36: error: 'pr' was not declared in this scope
   27 |         if(a[i]=='T'&&b[i]=='A') ++pr[i][3];
      |                                    ^~
dna.cpp:28:36: error: 'pr' was not declared in this scope
   28 |         if(a[i]=='C'&&b[i]=='T') ++pr[i][4];
      |                                    ^~
dna.cpp:29:36: error: 'pr' was not declared in this scope
   29 |         if(a[i]=='T'&&b[i]=='C') ++pr[i][5];
      |                                    ^~
dna.cpp: In function 'int get_distance(int, int)':
dna.cpp:36:13: error: 'ps' was not declared in this scope
   36 |         if((ps[y][i][0]-ps[x-1][i][0])!=(ps[y][i][1]-ps[x-1][i][1])) {
      |             ^~
dna.cpp:41:40: error: 'pr' was not declared in this scope
   41 |     for(int i=0; i<6; ++i) v.push_back(pr[y+1][i]-pr[x][0]);
      |                                        ^~