Submission #437307

#TimeUsernameProblemLanguageResultExecution timeMemory
437307DunderMifflinMutating DNA (IOI21_dna)C++17
Compilation error
0 ms0 KiB
#include "dna.h" #include<map> 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; for (int k = 0; k < 3; k++) { for (int l = k + 1; l < 3; l++) { ans += pref[k][l][y] - pref[k][l][x - 1]; } } return ans; }

Compilation message (stderr)

dna.cpp:9:1: error: 'map' does not name a type
    9 | map<char, int> f;
      | ^~~
dna.cpp: In function 'void init(std::string, std::string)':
dna.cpp:12:2: error: 'f' was not declared in this scope
   12 |  f['A'] = 0; f['C'] = 1; f['T'] = 2;
      |  ^