Submission #1312270

#TimeUsernameProblemLanguageResultExecution timeMemory
1312270opeleklanosMutating DNA (IOI21_dna)C++20
21 / 100
18 ms2352 KiB
#include <iostream> #include <vector> #include "dna.h" using namespace std; string a; string b; #define C first #define A second.first #define T second.second void init(string a1, string b1){ a = a1; b = b1; } int get_distance(int x, int y){ if(x == y){ if(a[x] == b[x]) return 0; else return -1; } if(y - x == 1){ if(a[x] == b[x]){ if(a[y] == b[y]) return 0; else return -1; } if(a[x] == b[y]){ if(a[y] == b[x]) return 1; else return -1; } return -1; } if(y-x == 2){ pair<int, pair<int, int>> o; for(int i = x; i<=y; i++){ if(a[i] == 'C') o.C++; if(a[i] == 'A') o.A++; if(a[i] == 'T') o.T++; } for(int i = x; i<=y; i++){ if(b[i] == 'C') o.C--; if(b[i] == 'A') o.A--; if(b[i] == 'T') o.T--; } if(o.C != 0 || o.A != 0 || o.T != 0) return -1; int same = 0; for(int i = x; i<=y; i++) same += (a[i] == b[i]); if(same == 1) return 1; if(same == 0) return 2; if(same == 3) return 0; return -1; } }

Compilation message (stderr)

dna.cpp: In function 'int get_distance(int, int)':
dna.cpp:54:1: warning: control reaches end of non-void function [-Wreturn-type]
   54 | }
      | ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...