제출 #708527

#제출 시각아이디문제언어결과실행 시간메모리
708527ngano_upat_naDNA 돌연변이 (IOI21_dna)C++17
컴파일 에러
0 ms0 KiB
#include "dna.h" #include "bits/stdc++.h" using namespace std; using ll = long long; const int N = 100001; vector<int> A0(N,0), A1(N,0); vector<int> T0(N,0), T1(N,0); vector<int> C0(N,0), C1(N,0); vector<int> AC(N,0), CA(N,0), AT(N,0), TA(N,0), TC(N,0), CT(N,0); string s, t; void init(string a, string b) { s = a; t = b; int sz = (int)a.size(); for (int i=0; i<sz; i++) { A0[i+1] = A0[i]; T0[i+1] = T0[i]; C0[i+1] = C0[i]; if (s[i] == 'A') A0[i+1]++; if (s[i] == 'T') T0[i+1]++; if (s[i] == 'C') C0[i+1]++; } for (int i=0; i<sz; i++) { A1[i+1] = A1[i]; T1[i+1] = T1[i]; C1[i+1] = C1[i]; if (t[i] == 'A') A1[i+1]++; if (t[i] == 'T') T1[i+1]++; if (t[i] == 'C') C1[i+1]++; } for (int i=0; i<sz; i++) { AC[i+1] = AC[i]; CA[i+1] = CA[i]; AT[i+1] = AT[i]; TA[i+1] = TA[i]; CT[i+1] = CT[i]; TC[i+1] = CT[i]; if (s[i] == 'A' && t[i] == 'C') AC[i+1]++; if (s[i] == 'C' && t[i] == 'A') CA[i+1]++; if (s[i] == 'A' && t[i] == 'T') AT[i+1]++; if (s[i] == 'T' && t[i] == 'A') TA[i+1]++; if (s[i] == 'C' && t[i] == 'T') CT[i+1]++; if (s[i] == 'T' && t[i] == 'C') TC[i+1]++; } } int get_distance(int x, int y) { y++; if ((A0[z] - A0[x] != A1[z] - A1[x]) || (T0[z] - T0[x] != T1[z] - T1[x]) || (C0[z] - C0[x] != C1[z] - C1[x])) return -1; int ac = AC[y] - AC[x], ca = CA[y] - CA[x]; int at = AT[y] - AT[x], ta = TA[y] - TA[x]; int ct = CT[y] - CT[x], tc = TC[y] - TC[x]; int a = min(ac,ca); int b = min(at,ta); int c = min(ct,tc); ans = ans + a + b + c; ac -= a; ca -= a; at -= b; ta -= b; ct -= c; tc -= c; int d = min(ac,min(ta,ct)); ans += d; ac -= d; ta -= d; ct -= d; int e = min(ca,min(at,tc)); ans += e; ca -= e; at -= e; tc -= e; int f = min(at,min(tc,ca)); ans += f; at -= f; tc -= f; ca -= f; int g = min(ta,min(ct,ac)); ans += g; return ans; }

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

dna.cpp: In function 'int get_distance(int, int)':
dna.cpp:56:13: error: 'z' was not declared in this scope
   56 |     if ((A0[z] - A0[x] != A1[z] - A1[x]) || (T0[z] - T0[x] != T1[z] - T1[x]) || (C0[z] - C0[x] != C1[z] - C1[x])) return -1;
      |             ^
dna.cpp:65:5: error: 'ans' was not declared in this scope; did you mean 'abs'?
   65 |     ans = ans + a + b + c;
      |     ^~~
      |     abs