제출 #438898

#제출 시각아이디문제언어결과실행 시간메모리
438898pere_gilDNA 돌연변이 (IOI21_dna)C++17
43 / 100
1564 ms3780 KiB
#include "bits/stdc++.h" #include "dna.h" using namespace std; string a,b; void init(std::string A, std::string B) { a=A; b=B; } void count(int &res, int &f, int &s){ res+=f; s-=f; f=0; } int get_distance(int x, int y) { int canta[26]={}; int cantb[26]={}; int n=a.size(); for(int i=x;i<=y;i++){ canta[a[i]-'A']++; cantb[b[i]-'A']++; } for(int i=0;i<26;i++) if(canta[i]!=cantb[i]) return -1; int ac,at,ct=ac=at=0; int ca,ta,tc=ca=ta=0; for(int i=x;i<=y;i++){ if(a[i]=='A' && b[i]=='C') ac++; if(a[i]=='A' && b[i]=='T') at++; if(a[i]=='C' && b[i]=='T') ct++; if(a[i]=='C' && b[i]=='A') ca++; if(a[i]=='T' && b[i]=='A') ta++; if(a[i]=='T' && b[i]=='C') tc++; } //printf("\nbefore\n"); //printf("ac = %d | ca = %d\n",ac,ca); //printf("at = %d | ta = %d\n",at,ta); //printf("tc = %d | ct = %d\n",tc,ct); int res=0; (ac<ca) ? count(res,ac,ca) : count(res,ca,ac); (at<ta) ? count(res,at,ta) : count(res,ta,at); (tc<ct) ? count(res,tc,ct) : count(res,ct,tc); //printf("\nafter\n"); //printf("ac = %d | ca = %d\n",ac,ca); //printf("at = %d | ta = %d\n",at,ta); //printf("tc = %d | ct = %d\n",tc,ct); //printf("res at the ''end'' --> %d\n",res); int aux=ac+ca+at+ta+ct+tc-1; if(aux>=0) res+=aux; return res; }

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

dna.cpp: In function 'int get_distance(int, int)':
dna.cpp:21:6: warning: unused variable 'n' [-Wunused-variable]
   21 |  int n=a.size();
      |      ^
#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...