Submission #734503

#TimeUsernameProblemLanguageResultExecution timeMemory
734503Roman70Mutating DNA (IOI21_dna)C++17
Compilation error
0 ms0 KiB
#include "bits/stdc++.h" using namespace std; string c,d; const int sz = 1e5; int prefix[26][sz]; int prefix1[26][sz]; int prefix2[sz]; void init(std::string a, std::string b) { c = a; d = b; memset(prefix,0,sizeof(prefix)); memset(prefix1,0,sizeof(prefix1)); memset(prefix2,0,sizeof(prefix2)); prefix[0][c[0] - 'A']++; prefix1[0][d[0] - 'A']++; // 65 67 84 if(c[0] != d[0]) prefix2[0]++; for(int i = 1;i<c.size();i++){ prefix[i][c[i] - 'A']++; prefix[i][0]+= prefix[i-1][0]; prefix[i][2]+= prefix[i-1][2]; prefix[i][19]+= prefix[i-1][19]; if(c[i] != d[i]) prefix2[i]++; prefix2[i] += prefix2[i-1]; } for(int i = 1;i<d.size();i++){ prefix1[i][d[i] - 'A']++; prefix1[i][0]+= prefix1[i-1][0]; prefix1[i][2]+= prefix1[i-1][2]; prefix1[i][19]+= prefix1[i-1][19]; } } int get_distance(int x, int y) { int ans; int cmp[2][26]; cmp[0][0] = prefix[y][0] - (x == 0 ? 0 : prefix[x-1][0]); cmp[0][2]= prefix[y][2] - (x == 0 ? 0 : prefix[x-1][2]); cmp[0][19]= prefix[y][19] - (x == 0 ? 0 : prefix[x-1][19]); cmp[1][0]= prefix1[y][0] - (x == 0 ? 0 : prefix1[x-1][0]); cmp[1][2]= prefix1[y][2] - (x == 0 ? 0 : prefix1[x-1][2]); cmp[1][19]= prefix1[y][19] - (x == 0 ? 0 : prefix1[x-1][19]); if(cmp[0][0] == cmp[1][0] && cmp[0][2] == cmp[1][2] && cmp[0][19] == cmp[1][19]) return (prefix2[y] - (x == 0 ? 0 : prefix2[x-1])) / 2 + ((prefix2[y] - (x == 0 ? 0 : prefix2[x-1])) % 2); return -1; } int main(){ init("ATACAT", "ACTATA"); cout<<get_distance(3,5); return 0; }

Compilation message (stderr)

dna.cpp: In function 'void init(std::string, std::string)':
dna.cpp:38:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |     for(int i = 1;i<c.size();i++){
      |                   ~^~~~~~~~~
dna.cpp:54:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   54 |     for(int i = 1;i<d.size();i++){
      |                   ~^~~~~~~~~
dna.cpp: In function 'int get_distance(int, int)':
dna.cpp:74:9: warning: unused variable 'ans' [-Wunused-variable]
   74 |     int ans;
      |         ^~~
/usr/bin/ld: /tmp/ccWdo1zt.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccoHkuqs.o:dna.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status