Submission #522949

#TimeUsernameProblemLanguageResultExecution timeMemory
522949TurkhuuMutating DNA (IOI21_dna)C++17
Compilation error
0 ms0 KiB
#include "dna.h" #include<bits/stdc++.h> using namespace std; vector<int> ax, at, ta, ct, aa, ba, ac, bc, at, bt; void init(std::string a, std::string b) { int n = (int)a.size(); ax.resize(n + 1); at.resize(n + 1); ta.resize(n + 1); ct.resize(n + 1); aa.resize(n + 1); ac.resize(n + 1); at.resize(n + 1); ba.resize(n + 1); bc.resize(n + 1); bt.resize(n + 1); for(int i = 0; i < n; i++){ ax[i + 1] = ax[i]; at[i + 1] = at[i]; ta[i + 1] = ta[i]; ct[i + 1] = ct[i]; A[i + 1] = A[i]; C[i + 1] = C[i]; T[i + 1] = T[i]; if(a[i] == 'A'){ aa[i + 1] += 1; } if(a[i] == 'C'){ ac[i + 1] += 1; } if(a[i] == 'T'){ at[i + 1] += 1; } if(b[i] == 'A'){ ba[i + 1] += 1; } if(b[i] == 'C'){ bc[i + 1] += 1; } if(b[i] == 'T'){ bt[i + 1] += 1; } if(a[i] == 'A' && b[i] != 'A'){ ax[i + 1] += 1; } if(a[i] == 'A' && b[i] == 'T'){ at[i + 1] += 1; } if(a[i] == 'T' && b[i] == 'A'){ ta[i + 1] += 1; } if(a[i] == 'C' && b[i] == 'T'){ ct[i + 1] += 1; } if(a[i] == 'T' && b[i] == 'C'){ ct[i + 1] += 1; } } } int get_distance(int x, int y) { x += 1; y += 1; int AX = ax[y] - ax[x - 1]; int AT = at[y] - at[x - 1]; int TA = ta[y] - ta[x - 1]; int CT = ct[y] - ct[x - 1]; int AA = aa[y] - aa[x - 1]; int AC = ac[y] - ac[x - 1]; int AT = at[y] - at[x - 1]; int BA = ba[y] - ba[x - 1]; int BC = bc[y] - bc[x - 1]; int BT = bt[y] - bt[x - 1]; if(AA != BA || AC != BC || AT != BT){ return -1; } else{ return AX + (CT + abs(AT - TA)) / 2; } }

Compilation message (stderr)

dna.cpp:6:45: error: redefinition of 'std::vector<int> at'
    6 | vector<int> ax, at, ta, ct, aa, ba, ac, bc, at, bt;
      |                                             ^~
dna.cpp:6:17: note: 'std::vector<int> at' previously declared here
    6 | vector<int> ax, at, ta, ct, aa, ba, ac, bc, at, bt;
      |                 ^~
dna.cpp: In function 'void init(std::string, std::string)':
dna.cpp:25:4: error: 'A' was not declared in this scope
   25 |    A[i + 1] = A[i];
      |    ^
dna.cpp:26:4: error: 'C' was not declared in this scope
   26 |    C[i + 1] = C[i];
      |    ^
dna.cpp:27:4: error: 'T' was not declared in this scope
   27 |    T[i + 1] = T[i];
      |    ^
dna.cpp: In function 'int get_distance(int, int)':
dna.cpp:73:6: error: redeclaration of 'int AT'
   73 |  int AT = at[y] - at[x - 1];
      |      ^~
dna.cpp:68:6: note: 'int AT' previously declared here
   68 |  int AT = at[y] - at[x - 1];
      |      ^~