Submission #820021

#TimeUsernameProblemLanguageResultExecution timeMemory
820021amunduzbaevMutating DNA (IOI21_dna)C++17
35 / 100
33 ms6604 KiB
#include "dna.h" #include "bits/stdc++.h" using namespace std; #define ar array typedef long long ll; //~ #define int ll const int N = 1e5 + 5; int is[N], pref[N]; ar<int, 3> c[2][N]; void init(string a, string b) { //~ cout<<"here"<<endl; int n = a.size(); for(int i=1;i<=n;i++){ pref[i] = pref[i - 1] + (a[i - 1] != b[i - 1]); c[0][i] = c[0][i - 1], c[1][i] = c[1][i - 1]; { int v; if(a[i - 1] == 'A') v = 0; if(a[i - 1] == 'C') v = 1; if(a[i - 1] == 'T') v = 2; c[0][i][v]++; } { int v; if(b[i - 1] == 'A') v = 0; if(b[i - 1] == 'C') v = 1; if(b[i - 1] == 'T') v = 2; c[1][i][v]++; } } } ar<int, 3> get(int t, int x, int y){ ar<int, 3> ans {}; ans[0] = c[t][y][0] - c[t][x][0]; ans[1] = c[t][y][1] - c[t][x][1]; ans[2] = c[t][y][2] - c[t][x][2]; //~ cout<<ans[0]<<" "<<ans[1]<<" "<<ans[2]<<"\n"; return ans; } int get_distance(int x, int y) { x++, y++; if(get(0, x - 1, y) == get(1, x - 1, y)){ return (pref[y] - pref[x - 1]) / 2; } else { return -1; } }

Compilation message (stderr)

dna.cpp: In function 'void init(std::string, std::string)':
dna.cpp:31:13: warning: 'v' may be used uninitialized in this function [-Wmaybe-uninitialized]
   31 |    c[1][i][v]++;
      |             ^
dna.cpp:24:13: warning: 'v' may be used uninitialized in this function [-Wmaybe-uninitialized]
   24 |    c[0][i][v]++;
      |             ^
#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...