Submission #1205500

#TimeUsernameProblemLanguageResultExecution timeMemory
1205500tamzidMutating DNA (IOI21_dna)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #include "dna.h" using namespace std; string A,B; vector<int> a_T,a_A,b_T,b_A,diff; void init(std::string a, std::string b) { A = a; B = b; a_A.resize(A.size()+1,0); b_A.resize(A.size()+1,0); b_T.resize(A.size()+1,0); a_T.resize(A.size()+1,0); diff.resize(A.size()+1,0); for(int i=0;i<A.size();++i) { a_A[i+1]+=a_A[i]; a_T[i+1]+=a_T[i]; b_A[i+1]+=b_A[i]; b_T[i+1]+=b_T[i]; diff[i+1]+=diff[i]; if(A[i] == 'A') ++a_A[i+1]; else ++a_T[i+1]; if(B[i] == 'A') ++b_A[i+1]; else ++b_T[i+1]; if(A[i] != B[i]) { ++diff[i+1]; } } } bool check() { return count(A.begin(),A.end(),'C') + count(B.begin(),B.end(),'C') > 0; } int get_distance(int x, int y) { if(y - x <=2 && check()) { if(y - x == 0) { if(A[x] == B[x]) return 0; else return -1; } else if(y - x == 1) { if((A[x] == B[x] && A[x+1] == B[x+1])) return 0; if((A[x] == B[x+1] && A[x+1] == B[x])) return 1; return -1; } else { int at = a_T[y+1] - a_T[x]; int aa = a_A[y+1] - a_A[x]; int bt = b_T[y+1] - b_T[x]; int ba = b_A[y+1] - b_A[x]; int difff = diff[y+1] - diff[x]; if(difff & 1) return -1; if(at != bt || aa != ba) return -1; return difff / 2; } }

Compilation message (stderr)

dna.cpp: In function 'int get_distance(int, int)':
dna.cpp:74:2: error: expected '}' at end of input
   74 | }
      |  ^
dna.cpp:43:32: note: to match this '{'
   43 | int get_distance(int x, int y) {
      |                                ^
dna.cpp:74:2: warning: control reaches end of non-void function [-Wreturn-type]
   74 | }
      |  ^