Submission #825301

#TimeUsernameProblemLanguageResultExecution timeMemory
825301arnold518Mutating DNA (IOI21_dna)C++17
35 / 100
27 ms7360 KiB
#include "dna.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; const int MAXN = 1e5; int N, P[MAXN+10][3][3]; int f(char x) { if(x=='A') return 0; if(x=='C') return 1; if(x=='T') return 2; } void init(string a, string b) { N=a.size(); for(int i=1; i<=N; i++) { for(int p=0; p<3; p++) for(int q=0; q<3; q++) P[i][p][q]=P[i-1][p][q]; P[i][f(a[i-1])][f(b[i-1])]++; } } int get_distance(int l, int r) { l++; r++; int A[3][3]={{0}}; for(int p=0; p<3; p++) for(int q=0; q<3; q++) A[p][q]=P[r][p][q]-P[l-1][p][q]; int ans=0, a, b, c; ans+=min(A[0][1], A[1][0]); a=abs(A[0][1]-A[1][0]); ans+=min(A[0][2], A[2][0]); b=abs(A[0][2]-A[2][0]); ans+=min(A[2][1], A[1][2]); c=abs(A[2][1]-A[1][2]); if(a!=b || b!=c || a!=c) return -1; ans+=a*2; return ans; }

Compilation message (stderr)

dna.cpp: In function 'int f(char)':
dna.cpp:18:1: warning: control reaches end of non-void function [-Wreturn-type]
   18 | }
      | ^
#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...