Submission #1057370

#TimeUsernameProblemLanguageResultExecution timeMemory
1057370TrentMutating DNA (IOI21_dna)C++17
0 / 100
17 ms3772 KiB
#include "dna.h" #include "bits/stdc++.h" using namespace std; #define forR(i, x) for(int i = 0; i < (x); ++i) #define REP(i, a, b) for(int i = (a); i < (b); ++i) typedef long long ll; typedef vector<int> vi; string a, b; void init(std::string a, std::string b) { ::a = a; ::b = b; } int id(char v) { return v == 'A' ? 0 : v == 'C' ? 1 : 2; } int get_distance(int x, int y) { int cnt[3][3]; forR(i, 3) forR(j, 3) cnt[i][j] = 0; REP(i, x, y+1) { cnt[id(a[i])][id(b[i])]++; } int ab=min(cnt[0][1], cnt[1][0]), ac=min(cnt[0][2], cnt[2][0]), bc=min(cnt[1][2], cnt[2][1]); cnt[0][1]-=ab, cnt[1][0]-=ab; cnt[0][2]-=ac, cnt[2][0]-=ac; cnt[1][2]-=bc, cnt[2][1]-=bc; int abt=max(cnt[0][1], cnt[1][0]), act=max(cnt[0][2], cnt[2][0]), bct=max(cnt[1][2], cnt[2][1]); if(abt == act && act == bct) { return ab + ac + bc + 2 * abt; } }

Compilation message (stderr)

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