Submission #437329

#TimeUsernameProblemLanguageResultExecution timeMemory
437329DunderMifflinMutating DNA (IOI21_dna)C++17
Compilation error
0 ms0 KiB
#include "dna.h" #include<map> using namespace std; const int N = 123456; int pref[3][3][N]; int asum[3][N]; int bsum[3][N]; map<char, int> f; void init(std::string a, std::string b) { f['A'] = 0; f['C'] = 1; f['T'] = 2; int n = (int) a.size(); a = " " + a; b = " " + b; for (int i = 1; i <= n; i++) { for (int k = 0; k < 3; k++) { for (int l = 0; l < 3; l++) { pref[k][l][i] = pref[k][l][i - 1] + (f[a[i]] == k && f[b[i]] == l); } asum[k][i] = asum[k][i - 1] + (f[a[i]] == k); bsum[k][i] = bsum[k][i - 1] + (f[b[i]] == k); } } } int get_distance(int x, int y) { x++; y++; for (int t = 0; t < 3; t++) { if (asum[t][y] - asum[t][x - 1] != bsum[t][y] - bsum[t][x - 1]) { return -1; } } int ans = 0, extra = 0; for (int k = 0; k < 3; k++) { for (int l = k + 1; l < 3; l++) { ans += min(pref[k][l][y] - pref[k][l][x - 1], pref[l][k][y] - pref[l][k][x - 1]); extra += max(pref[k][l][y] - pref[k][l][x - 1], pref[l][k][y] - pref[l][k][x - 1]) - min(pref[k][l][y] - pref[k][l][x - 1], pref[l][k][y] - pref[l][k][x - 1]) } } return ans + 2 * extra; }

Compilation message (stderr)

dna.cpp: In function 'int get_distance(int, int)':
dna.cpp:39:162: error: expected ';' before '}' token
   39 |    extra += max(pref[k][l][y] - pref[k][l][x - 1], pref[l][k][y] - pref[l][k][x - 1]) - min(pref[k][l][y] - pref[k][l][x - 1], pref[l][k][y] - pref[l][k][x - 1])
      |                                                                                                                                                                  ^
      |                                                                                                                                                                  ;
   40 |   }
      |   ~