제출 #527594

#제출 시각아이디문제언어결과실행 시간메모리
527594vivaan_guptaDNA 돌연변이 (IOI21_dna)C++17
35 / 100
46 ms6788 KiB
#include "dna.h" #include<bits/stdc++.h> using namespace std; const int N = 1e5 + 5; map<char,int> mp; string A, B; int cnt[N][3]; int cnt2[N][3]; int bad[N]; void init(std::string a, std::string b) { A = a, B = b; mp['A'] = 0; mp['C'] = 1; mp['T'] = 1; for(int i = 0;i < a.size();i++){ int tmp = mp[a[i]]; int gg = (a[i] != b[i]); cnt[i][tmp] ++; bad[i] = gg; if(i > 0){ bad[i] += bad[i-1]; for(int j = 0;j < 3;j++){ cnt[i][j] += cnt[i-1][j]; } } tmp = mp[b[i]]; cnt2[i][tmp] ++; if(i > 0){ for(int j = 0;j < 3;j++){ cnt2[i][j] += cnt2[i-1][j]; } } } return; } int get_distance(int x, int y) { bool ok = 1; for(int i = 0;i < 3;i++){ int sum = cnt[y][i]; if(x > 0) sum -= cnt[x - 1][i]; int sum2 = cnt2[y][i]; if(x > 0) sum2 -= cnt2[x - 1][i]; ok &= (sum == sum2); } if(!ok) return -1; int sum = bad[y]; if(x > 0) sum -= bad[x-1]; return ((sum + 1) / 2); }

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

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