제출 #1067371

#제출 시각아이디문제언어결과실행 시간메모리
1067371AlgorithmWarriorDNA 돌연변이 (IOI21_dna)C++17
100 / 100
29 ms9824 KiB
#include "dna.h" #include <bits/stdc++.h> #define MAX 100005 using namespace std; int sp[MAX][3][3]; int sp1[MAX][3]; int sp2[MAX][3]; void init(string a, string b) { int to[100]; to['A']=0; to['C']=1; to['T']=2; int n=a.size(); int i,j,k; for(i=1;i<=n;++i) { ++sp[i][to[a[i-1]]][to[b[i-1]]]; ++sp1[i][to[a[i-1]]]; ++sp2[i][to[b[i-1]]]; for(j=0;j<3;++j) sp1[i][j]+=sp1[i-1][j]; for(j=0;j<3;++j) sp2[i][j]+=sp2[i-1][j]; for(j=0;j<3;++j) for(k=0;k<3;++k) sp[i][j][k]+=sp[i-1][j][k]; } } int get_distance(int x, int y) { ++x,++y; int i,j; for(i=0;i<3;++i) if(sp1[y][i]-sp1[x-1][i]!=sp2[y][i]-sp2[x-1][i]) return -1; int nr=abs(sp[y][0][1]-sp[x-1][0][1]-sp[y][1][0]+sp[x-1][1][0]); int cnt=2*nr; for(i=0;i<3;++i) for(j=i+1;j<3;++j) cnt+=min(sp[y][i][j]-sp[x-1][i][j],sp[y][j][i]-sp[x-1][j][i]); return cnt; }

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

dna.cpp: In function 'void init(std::string, std::string)':
dna.cpp:21:26: warning: array subscript has type 'char' [-Wchar-subscripts]
   21 |         ++sp[i][to[a[i-1]]][to[b[i-1]]];
      |                          ^
dna.cpp:21:38: warning: array subscript has type 'char' [-Wchar-subscripts]
   21 |         ++sp[i][to[a[i-1]]][to[b[i-1]]];
      |                                      ^
dna.cpp:22:27: warning: array subscript has type 'char' [-Wchar-subscripts]
   22 |         ++sp1[i][to[a[i-1]]];
      |                           ^
dna.cpp:23:27: warning: array subscript has type 'char' [-Wchar-subscripts]
   23 |         ++sp2[i][to[b[i-1]]];
      |                           ^
#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...