Submission #677101

#TimeUsernameProblemLanguageResultExecution timeMemory
677101hello_there_123Mutating DNA (IOI21_dna)C++17
100 / 100
37 ms7440 KiB
#include <bits/stdc++.h> using namespace std; string s, t; int n; int lol[4][4][200005]; int mat[4][4]; //lol[i][j] -> i wants to turn into j void init(std::string a, std::string b) { int n = a.length(); for(int i=0;i<n;i++){ int fir, sec; if(a[i] == 'A') fir = 0; if(a[i] == 'T') fir = 1; if(a[i] == 'C') fir = 2; if(b[i] == 'A') sec = 0; if(b[i] == 'T') sec = 1; if(b[i] == 'C') sec = 2; for(int j=0;j<3;j++){ for(int k=0;k<3;k++){ if(i!=0) lol[j][k][i] = lol[j][k][i-1]; } } if(a[i]==b[i]) continue; lol[fir][sec][i]++; } } int get_distance(int z, int y) { int ans = 0; for(int i=0;i<3;i++){ for(int j=0;j<3;j++){ if(z>0) mat[i][j] = lol[i][j][y] - lol[i][j][z-1]; else mat[i][j] = lol[i][j][y]; } } int x = min(mat[0][1],mat[1][0]); ans+=x; mat[0][1]-=x; mat[1][0]-=x; x = min(mat[0][2],mat[2][0]); ans+=x; mat[0][2]-=x; mat[2][0]-=x; x = min(mat[1][2],mat[2][1]); ans+=x; mat[1][2]-=x; mat[2][1]-=x; if(mat[0][1] + mat[0][2] == mat[1][0] + mat[2][0] && mat[1][0]+mat[1][2] == mat[0][1] + mat[2][1] && mat[2][0]+mat[2][1] == mat[0][2]+mat[1][2]){ ans+=2*(mat[0][1] + mat[0][2]); return ans; } else return -1; }

Compilation message (stderr)

dna.cpp: In function 'void init(std::string, std::string)':
dna.cpp:24:19: warning: 'sec' may be used uninitialized in this function [-Wmaybe-uninitialized]
   24 |   lol[fir][sec][i]++;
      |   ~~~~~~~~~~~~~~~~^~
dna.cpp:24:19: warning: 'fir' may be used uninitialized in this function [-Wmaybe-uninitialized]
#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...