제출 #745606

#제출 시각아이디문제언어결과실행 시간메모리
745606LIFDNA 돌연변이 (IOI21_dna)C++17
21 / 100
48 ms9408 KiB
#include "dna.h" #include<bits/stdc++.h> #include<string> using namespace std; int su[200005][3][3]; int A[200005]; int C[200005]; int T[200005]; int AA[200005]; int CC[200005]; int TT[200005]; void init(std::string a, std::string b) { for(int i=0;i<a.length();i++) { char aa = a[i]; char bb = b[i]; int xx = 0; if(aa == 'A') { xx = 1; A[i+1] = A[i] + 1; } else A[i+1] = A[i]; if(aa == 'C') { xx = 2; C[i+1] = C[i] + 1; } else C[i+1] = C[i]; if(aa == 'T') { xx = 3; T[i+1] = T[i] + 1; } else T[i+1] = T[i]; int yy = 0; if(bb == 'A') { yy = 1; AA[i+1] = AA[i] + 1; } else AA[i+1] = AA[i]; if(bb == 'C') { yy = 2; CC[i+1] = CC[i] + 1; } else CC[i+1] = CC[i]; if(bb == 'T') { yy = 3; TT[i+1] = TT[i] + 1; } else TT[i+1] = TT[i]; for(int j=1;j<=3;j++) { for(int k=1;k<=3;k++) { if(j == xx && k == yy) { su[i+1][j][k] = su[i][j][k] + 1; } else su[i+1][j][k] = su[i][j][k]; } } } } int get_distance(int x, int y) { x += 1; y += 1; if(A[y] - A[x-1] != AA[y] - AA[x-1])return -1; if(C[y] - C[x-1] != CC[y] - CC[x-1])return -1; if(T[y] - T[x-1] != TT[y] - TT[x-1])return -1; int ans = (y-x+1); ans -= (su[y][1][1] - su[x-1][1][1]); ans -= (su[y][2][2] - su[x-1][2][2]); ans -= (su[y][3][3] - su[x-1][3][3]); int p1 = su[y][1][2] - su[x-1][1][2]; int p2 = su[y][2][1] - su[x-1][2][1]; ans -= min(p1,p2); p1 = su[y][1][3] - su[x-1][1][3]; p2 = su[y][3][1] - su[x-1][3][1]; ans -= min(p1,p2); p1 = su[y][2][3] - su[x-1][2][3]; p2 = su[y][3][2] - su[x-1][3][2]; ans -= min(p1,p2); return max(ans - (ans/3),0); }

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

dna.cpp: In function 'void init(std::string, std::string)':
dna.cpp:13:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   13 |  for(int i=0;i<a.length();i++)
      |              ~^~~~~~~~~~~
dna.cpp: In function 'int get_distance(int, int)':
dna.cpp:85:20: warning: array subscript 3 is above array bounds of 'int [3]' [-Warray-bounds]
   85 |  ans -= (su[y][3][3] - su[x-1][3][3]);
      |          ~~~~~~~~~~^
dna.cpp:85:36: warning: array subscript 3 is above array bounds of 'int [3]' [-Warray-bounds]
   85 |  ans -= (su[y][3][3] - su[x-1][3][3]);
      |                        ~~~~~~~~~~~~^
dna.cpp:91:17: warning: array subscript 3 is above array bounds of 'int [3]' [-Warray-bounds]
   91 |  p1 = su[y][1][3] - su[x-1][1][3];
      |       ~~~~~~~~~~^
dna.cpp:91:33: warning: array subscript 3 is above array bounds of 'int [3]' [-Warray-bounds]
   91 |  p1 = su[y][1][3] - su[x-1][1][3];
      |                     ~~~~~~~~~~~~^
dna.cpp:92:14: warning: array subscript 3 is above array bounds of 'int [3][3]' [-Warray-bounds]
   92 |  p2 = su[y][3][1] - su[x-1][3][1];
      |       ~~~~~~~^
dna.cpp:92:30: warning: array subscript 3 is above array bounds of 'int [3][3]' [-Warray-bounds]
   92 |  p2 = su[y][3][1] - su[x-1][3][1];
      |                     ~~~~~~~~~^
dna.cpp:95:17: warning: array subscript 3 is above array bounds of 'int [3]' [-Warray-bounds]
   95 |  p1 = su[y][2][3] - su[x-1][2][3];
      |       ~~~~~~~~~~^
dna.cpp:95:33: warning: array subscript 3 is above array bounds of 'int [3]' [-Warray-bounds]
   95 |  p1 = su[y][2][3] - su[x-1][2][3];
      |                     ~~~~~~~~~~~~^
dna.cpp:96:14: warning: array subscript 3 is above array bounds of 'int [3][3]' [-Warray-bounds]
   96 |  p2 = su[y][3][2] - su[x-1][3][2];
      |       ~~~~~~~^
dna.cpp:96:30: warning: array subscript 3 is above array bounds of 'int [3][3]' [-Warray-bounds]
   96 |  p2 = su[y][3][2] - su[x-1][3][2];
      |                     ~~~~~~~~~^
#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...