Submission #812588

#TimeUsernameProblemLanguageResultExecution timeMemory
812588abcvuitunggioMutating DNA (IOI21_dna)C++17
100 / 100
33 ms7376 KiB
#include "dna.h" #include <bits/stdc++.h> using namespace std; int s[100001][3][3],cnt[3][3],n,res,d[3]; void init(string a, string b){ n=a.length(); for (int i=0;i<n;i++){ if (a[i]=='T') a[i]='B'; if (b[i]=='T') b[i]='B'; for (int j=0;j<3;j++) for (int k=0;k<3;k++) s[i][j][k]=s[i-1][j][k]; s[i][a[i]-'A'][b[i]-'A']++; for (int j=0;j<3;j++) s[i][j][j]=0; } } int get_distance(int x, int y){ for (int i=0;i<3;i++) for (int j=0;j<3;j++) cnt[i][j]=s[y][i][j]-(x?s[x-1][i][j]:0); res=0; for (int i=0;i<3;i++) for (int j=i+1;j<3;j++){ int val=min(cnt[i][j],cnt[j][i]); cnt[i][j]-=val; cnt[j][i]-=val; res+=val; } int mx=0; d[0]=d[1]=d[2]=0; for (int i=0;i<3;i++) for (int j=0;j<3;j++){ d[i]+=cnt[i][j]; d[j]-=cnt[i][j]; mx=max(mx,cnt[i][j]); } if (d[0]|d[1]|d[2]) return -1; return mx*2+res; }

Compilation message (stderr)

dna.cpp: In function 'int get_distance(int, int)':
dna.cpp:40:5: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   40 |     if (d[0]|d[1]|d[2])
      |     ^~
dna.cpp:42:2: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   42 |  return mx*2+res;
      |  ^~~~~~
#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...