Submission #697765

#TimeUsernameProblemLanguageResultExecution timeMemory
697765hiikunZMutating DNA (IOI21_dna)C++17
100 / 100
61 ms18092 KiB
#include<bits/stdc++.h> using namespace std; using ll = long long int; vector<vector<ll>> R(9,vector<ll>(200000,0)); void init(string a, string b){ ll N = (ll)a.size(); for(ll i = 0;i < N;i++){ ll p,q; if(a[i] == 'A') p = 0; if(a[i] == 'T') p = 1; if(a[i] == 'C') p = 2; if(b[i] == 'A') q = 0; if(b[i] == 'T') q = 1; if(b[i] == 'C') q = 2; for(ll j = 0;j < 9;j++) R[j][i + 1] = R[j][i]; R[p * 3 + q][i + 1]++; } } int get_distance(int x, int y){ y++; ll ans = 0; vector<int> A(9); for(ll j = 0;j < 9;j++) A[j] = R[j][y] - R[j][x]; for(ll i = 0;i < 3;i++){ A[i * 3 + i] = 0; for(ll j = i + 1;j < 3;j++){ ll k = min(A[i * 3 + j],A[j * 3 + i]); A[i * 3 + j] -= k; A[j * 3 + i] -= k; ans += k; } } vector<ll> C(3); for(ll i = 0;i < 3;i++){ for(ll j = 0;j < 3;j++){ C[i] += A[i * 3 + j]; C[j] -= A[i * 3 + j]; } } if(C[0] != 0 || C[1] != 0 || C[2] != 0) return -1; ll w = 0; for(int i = 0;i < 1;i++){ for(int j = 0;j < 3;j++){ for(int k = 0;k < 3;k++){ if(i != j && i != k && j != k && A[i * 3 + j] == A[j * 3 + k] && A[i * 3 + j] == A[k * 3 + i]){ w += A[i * 3 + j] * 2; } } } } return ans + w; }

Compilation message (stderr)

dna.cpp: In function 'void init(std::string, std::string)':
dna.cpp:16:16: warning: 'q' may be used uninitialized in this function [-Wmaybe-uninitialized]
   16 |        R[p * 3 + q][i + 1]++;
      |          ~~~~~~^~~
dna.cpp:16:12: warning: 'p' may be used uninitialized in this function [-Wmaybe-uninitialized]
   16 |        R[p * 3 + q][i + 1]++;
      |          ~~^~~
#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...