제출 #708538

#제출 시각아이디문제언어결과실행 시간메모리
708538ngano_upat_naDNA 돌연변이 (IOI21_dna)C++17
0 / 100
35 ms7200 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) { int ans = 0; y++; if ((A0[y] - A0[x] != A1[y] - A1[x]) || (T0[y] - T0[x] != T1[y] - T1[x]) || (C0[y] - C0[x] != C1[y] - 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 += 2; ac -= d; ta -= d; ct -= d; int e = min(ca,min(at,tc)); ans += 2; ca -= e; at -= e; tc -= e; int f = min(at,min(tc,ca)); ans += 2; at -= f; tc -= f; ca -= f; int g = min(ta,min(ct,ac)); ans += 2; return ans; }

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

dna.cpp: In function 'int get_distance(int, int)':
dna.cpp:92:9: warning: unused variable 'g' [-Wunused-variable]
   92 |     int g = min(ta,min(ct,ac));
      |         ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...