제출 #522950

#제출 시각아이디문제언어결과실행 시간메모리
522950TurkhuuDNA 돌연변이 (IOI21_dna)C++17
컴파일 에러
0 ms0 KiB
#include "dna.h" #include<bits/stdc++.h> using namespace std; vector<int> ax, at, ta, ct, aa, ba, ac, bc, at, bt; void init(std::string a, std::string b) { int n = (int)a.size(); ax.resize(n + 1); at.resize(n + 1); ta.resize(n + 1); ct.resize(n + 1); aa.resize(n + 1); ac.resize(n + 1); at.resize(n + 1); ba.resize(n + 1); bc.resize(n + 1); bt.resize(n + 1); for(int i = 0; i < n; i++){ ax[i + 1] = ax[i]; at[i + 1] = at[i]; ta[i + 1] = ta[i]; ct[i + 1] = ct[i]; A[i + 1] = A[i]; C[i + 1] = C[i]; T[i + 1] = T[i]; if(a[i] == 'A'){ aa[i + 1] += 1; } if(a[i] == 'C'){ ac[i + 1] += 1; } if(a[i] == 'T'){ at[i + 1] += 1; } if(b[i] == 'A'){ ba[i + 1] += 1; } if(b[i] == 'C'){ bc[i + 1] += 1; } if(b[i] == 'T'){ bt[i + 1] += 1; } if(a[i] == 'A' && b[i] != 'A'){ ax[i + 1] += 1; } if(a[i] == 'A' && b[i] == 'T'){ at[i + 1] += 1; } if(a[i] == 'T' && b[i] == 'A'){ ta[i + 1] += 1; } if(a[i] == 'C' && b[i] == 'T'){ ct[i + 1] += 1; } if(a[i] == 'T' && b[i] == 'C'){ ct[i + 1] += 1; } } } int get_distance(int x, int y) { x += 1; y += 1; int AX = ax[y] - ax[x - 1]; int AT = at[y] - at[x - 1]; int TA = ta[y] - ta[x - 1]; int CT = ct[y] - ct[x - 1]; int AAA = aa[y] - aa[x - 1]; int AAC = ac[y] - ac[x - 1]; int AAT = at[y] - at[x - 1]; int BBA = ba[y] - ba[x - 1]; int BBC = bc[y] - bc[x - 1]; int BBT = bt[y] - bt[x - 1]; if(AAA != BBA || AAC != BBC || AAT != BBT){ return -1; } else{ return AX + (CT + abs(AT - TA)) / 2; } }

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

dna.cpp:6:45: error: redefinition of 'std::vector<int> at'
    6 | vector<int> ax, at, ta, ct, aa, ba, ac, bc, at, bt;
      |                                             ^~
dna.cpp:6:17: note: 'std::vector<int> at' previously declared here
    6 | vector<int> ax, at, ta, ct, aa, ba, ac, bc, at, bt;
      |                 ^~
dna.cpp: In function 'void init(std::string, std::string)':
dna.cpp:25:4: error: 'A' was not declared in this scope
   25 |    A[i + 1] = A[i];
      |    ^
dna.cpp:26:4: error: 'C' was not declared in this scope
   26 |    C[i + 1] = C[i];
      |    ^
dna.cpp:27:4: error: 'T' was not declared in this scope
   27 |    T[i + 1] = T[i];
      |    ^