제출 #550571

#제출 시각아이디문제언어결과실행 시간메모리
550571WoahManDNA 돌연변이 (IOI21_dna)C++17
100 / 100
43 ms9736 KiB
#include "dna.h" #include<bits/stdc++.h> using namespace std; int pref[100005][15]; void init(std::string a, std::string b) { memset(pref,0,sizeof pref); for(int i=1;i<=a.length();i++) { pref[i][0]=(a[i-1]=='A') + pref[i-1][0]; pref[i][1]=(b[i-1]=='A') + pref[i-1][1]; pref[i][2]=(a[i-1]=='T') + pref[i-1][2]; pref[i][3]=(b[i-1]=='T') + pref[i-1][3]; pref[i][4]=(a[i-1]=='C') + pref[i-1][4]; pref[i][5]=(b[i-1]=='C') + pref[i-1][5]; pref[i][6]=(a[i-1]=='A' && b[i-1]=='T') + pref[i-1][6]; pref[i][7]=(a[i-1]=='T' && b[i-1]=='A') + pref[i-1][7]; pref[i][8]=(a[i-1]=='T' && b[i-1]=='C') + pref[i-1][8]; pref[i][9]=(a[i-1]=='C' && b[i-1]=='T') + pref[i-1][9]; pref[i][10]=(a[i-1]=='C' && b[i-1]=='A') + pref[i-1][10]; pref[i][11]=(a[i-1]=='A' && b[i-1]=='C') + pref[i-1][11]; } } int sum(int l,int r,int id) { return pref[r][id]-pref[l-1][id]; } int get_distance(int x, int y) { x++;y++; if(sum(x,y,0)!=sum(x,y,1) || sum(x,y,2)!=sum(x,y,3) || sum(x,y,4)!=sum(x,y,5)) return -1; int ans=0,rem=0; for(int i=6;i<=10;i+=2) { int a=sum(x,y,i),b=sum(x,y,i+1); ans+=min(a,b); rem+=max(a,b)-min(a,b); } ans+=rem*2/3; return ans; }

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

dna.cpp: In function 'void init(std::string, std::string)':
dna.cpp:9:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    9 |  for(int i=1;i<=a.length();i++)
      |              ~^~~~~~~~~~~~
#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...