Submission #548713

#TimeUsernameProblemLanguageResultExecution timeMemory
548713esomerMutating DNA (IOI21_dna)C++17
Compilation error
0 ms0 KiB
#include "dna.h" #include<bits/stdc++.h> using namespace std; #define int long long vector<tuple<int, int, int>> prefix1; vector<tuple<int, int, int>> prefix2; vector<int> prefix; int n; void init(string a, string b) { n = a.size(); prefix.resize(n); prefix1.resize(n); prefix2.resize(n); for(int i = 0; i < n; i++){ if(i == 0){ prefix1[i] = {0, 0, 0}; prefix2[i] = {0, 0, 0}; if(a[i] == 'A'){ get<0> (prefix1[i])++; }else if(a[i] == 'T'){ get<1>(prefix1[i])++; }else get<2> (prefix1[i])++; if(b[i] == 'A'){ get<0> (prefix2[i])++; }else if(b[i] == 'T'){ get<1>(prefix2[i])++; }else get<2> (prefix2[i])++; }else{ prefix1[i] = prefix1[i - 1]; prefix2[i] = prefix2[i - 1]; if(a[i] == 'A'){ get<0> (prefix1[i])++; }else if(a[i] == 'T'){ get<1>(prefix1[i])++; }else get<2> (prefix1[i])++; if(b[i] == 'A'){ get<0> (prefix2[i])++; }else if(b[i] == 'T'){ get<1>(prefix2[i])++; }else get<2> (prefix2[i])++; } if(a[i] != b[i]){ if(i == 0) prefix[i] = 1; else prefix[i] = prefix[i-1] + 1; }else{ if(i == 0) prefix[i] = 0; else prefix[i] = prefix[i-1]; } } } int get_distance(int x, int y) { int da, db; if(x > 0) da = get<0> (prefix1[y]) - get<0> (prefix1[x-1]); else da = get<0> (prefix1[y]); if(x > 0) db = get<0> (prefix2[y]) - get<0> (prefix2[x-1]); else db = get<0> (prefix2[y]); if(da != db) return -1; if(x > 0) da = get<1> (prefix1[y]) - get<1> (prefix1[x-1]); else da = get<1> (prefix1[y]); if(x > 0) db = get<1> (prefix2[y]) - get<1> (prefix2[x-1]); else db = get<1> (prefix2[y]); if(da != db) return -1; if(x > 0) da = get<2> (prefix1[y]) - get<2> (prefix1[x-1]); else da = get<2> (prefix1[y]); if(x > 0) db = get<2> (prefix2[y]) - get<2> (prefix2[x-1]); else db = get<2> (prefix2[y]); if(da != db) return -1; int d; if(x > 0) d = prefix[y] - prefix[x-1]; else d = prefix[y]; if(d % 2 != 0) return d / 2 + 1; else return d / 2; }

Compilation message (stderr)

/usr/bin/ld: /tmp/ccR1kcX3.o: in function `main':
grader.cpp:(.text.startup+0x39d): undefined reference to `get_distance(int, int)'
collect2: error: ld returned 1 exit status