Submission #1009551

#TimeUsernameProblemLanguageResultExecution timeMemory
1009551somefjordMutating DNA (IOI21_dna)C++17
Compilation error
0 ms0 KiB
#include "dna.h"
#include <bits/stdc++.h>

using namespace std;

string as, bs;
vector<int> mc1, mc2;

void init(string a, string b) {
  as = a;
  bs = b;

  int n = a.length();
  mc1.resize(n + 2, 0);
  mc2.resize(n + 2, 0);

  for (int i = 1; i <= n; ++i) {
    mc1[i] = mc1[i - 1] + (as[i - 1] == 'A' && as[i - 1] != bs[i - 1]);
    mc2[i] = mc2[i - 1] + (bs[i - 1] == 'T' && as[i - 1] != bs[i - 1]);
    // printf("i : %d, %d %d %d\n", i, acount1[i], acount2[i],
    // mc[i]);
  }
}

int get_distance(int x, int y) {
  int c1 = mc1[y] - mc1[x];
  int c2 = mc2[y] - mc2[x];
  if (c1 != c2)
    return -1;

  return c1;

Compilation message (stderr)

dna.cpp: In function 'int get_distance(int, int)':
dna.cpp:31:12: error: expected '}' at end of input
   31 |   return c1;
      |            ^
dna.cpp:25:32: note: to match this '{'
   25 | int get_distance(int x, int y) {
      |                                ^