Submission #527669

#TimeUsernameProblemLanguageResultExecution timeMemory
527669vivaan_guptaMutating DNA (IOI21_dna)C++17
35 / 100
38 ms10404 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]; int all[N][3][3], all2[N][3][3]; 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]; } } int tmp2 = mp[b[i]]; cnt2[i][tmp2] ++; if(i > 0){ for(int j = 0;j < 3;j++){ cnt2[i][j] += cnt2[i-1][j]; } } all[i][tmp][tmp2] ++; if(i > 0){ for(int j = 0;j< 3;j++){ for(int k =0;k<3;k++){ all[i][j][k] += all[i-1][j][k]; } } } } 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]; for(int a = 0;a < 3;a++){ for(int b = a + 1;b < 3;b++){ // a b // b a int tmp1 = all[y][a][b]; int tmp2 = all[y][b][a]; if(x > 0){ tmp1 -= all[x - 1][a][b]; tmp2 -= all[x - 1][b][a]; } sum -= min(tmp1, tmp2); } } return sum; }

Compilation message (stderr)

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