Submission #981506

#TimeUsernameProblemLanguageResultExecution timeMemory
981506faqinyeagerMutating DNA (IOI21_dna)C++17
Compilation error
0 ms0 KiB
#include "dna.h" #include <bits/stdc++.h> int n, a_cnt, b_cnt; int asum[100050][3], bsum[100050][3]; string aa, bb; void init(std::string a, std::string b){ aa = a, bb = b; n = (int)a.size(); for(int i = 0; i < n; i++){ asum[i][a[i] - 'A'] ++; bsum[i][b[i] - 'A'] ++; } for(int i = 1; i < n; i++){ for(int j = 0; j < 3; j++){ asum[i][j] += asum[i - 1][j]; bsum[i][j] += bsum[i - 1][j]; } } } int get_distance(int x, int y){ for(int j = 0; j < 3; j++){ if(asum[y][j] - asum[x - 1][j] != bsum[y][j] - bsum[x - 1][j]){ return -1; } } int cnt = 0; for(int i = x; i < y; i++){ if(aa[i] != bb[i]){ cnt++; } } return (cnt + 1) / 2; }

Compilation message (stderr)

dna.cpp:6:1: error: 'string' does not name a type; did you mean 'stdin'?
    6 | string aa, bb;
      | ^~~~~~
      | stdin
dna.cpp: In function 'void init(std::string, std::string)':
dna.cpp:9:2: error: 'aa' was not declared in this scope; did you mean 'a'?
    9 |  aa = a, bb = b;
      |  ^~
      |  a
dna.cpp:9:10: error: 'bb' was not declared in this scope; did you mean 'b'?
    9 |  aa = a, bb = b;
      |          ^~
      |          b
dna.cpp: In function 'int get_distance(int, int)':
dna.cpp:31:6: error: 'aa' was not declared in this scope
   31 |   if(aa[i] != bb[i]){
      |      ^~
dna.cpp:31:15: error: 'bb' was not declared in this scope
   31 |   if(aa[i] != bb[i]){
      |               ^~