Submission #565977

#TimeUsernameProblemLanguageResultExecution timeMemory
565977FairyWinxMutating DNA (IOI21_dna)C++17
Compilation error
0 ms0 KiB
#include "dna.h" #include <vector> #include <array> #include <algorithm> #define all(a) a.begin(), a.end() using namespace std; vector<int> a, b; void init(std::string _a, std::string _b) { a.resize(_a.size()); b.resize(_b.size()); for (int i = 0; i < (int) _a.size(); ++i) { if (_a[i] == 'A') { a[i] = 0; } else if (_a[i] == 'T') { a[i] = 1; } else { a[i] = 2; } if (_b[i] == 'A') { b[i] = 0; } else if (_b[i] == 'T') { b[i] = 1; } else { b[i] = 2; } } } int get_distance(int x, int y) { array<int, 3> c1, c2; int sum = 0; fill(all(c1), 0); fill(all(c2), 0); map<pair<int, int>, int> tmp; for (int i = x; i <= y; ++i) { if (a[i] != b[i]) { int a1 = a[i], a2 = b[i]; sum += 2; if (tmp[{a2, a1}]) { --tmp[{a2, a1}]; --sum; } else { ++tmp[{a1, a2}]; } } } return sum; }

Compilation message (stderr)

dna.cpp: In function 'int get_distance(int, int)':
dna.cpp:38:2: error: 'map' was not declared in this scope
   38 |  map<pair<int, int>, int> tmp;
      |  ^~~
dna.cpp:5:1: note: 'std::map' is defined in header '<map>'; did you forget to '#include <map>'?
    4 | #include <algorithm>
  +++ |+#include <map>
    5 | 
dna.cpp:38:20: error: expected primary-expression before ',' token
   38 |  map<pair<int, int>, int> tmp;
      |                    ^
dna.cpp:38:22: error: expected primary-expression before 'int'
   38 |  map<pair<int, int>, int> tmp;
      |                      ^~~
dna.cpp:43:8: error: 'tmp' was not declared in this scope; did you mean 'tm'?
   43 |    if (tmp[{a2, a1}]) {
      |        ^~~
      |        tm