Submission #1015916

#TimeUsernameProblemLanguageResultExecution timeMemory
1015916deeraMutating DNA (IOI21_dna)C++17
43 / 100
1565 ms3932 KiB
#include <bits/stdc++.h> using namespace std; #include "dna.h" string A, B; void init(string a, string b) { A = a; B = b; } string sorted(string x) { sort(x.begin(), x.end()); return x; } int get_distance(int x, int y) { string a = A.substr(x, (y-x+1)); string b = B.substr(x, (y-x+1)); if (a == b) { return 0; } if (sorted(a) != sorted(b)) { return -1; } string fa = "", fb = ""; for(int i=0;i<a.size();i++) { if (a[i] != b[i]) { fa += a.substr(i, 1); fb += b.substr(i, 1); } } a = fa; b = fb; int n = a.size(); if (a == b) { return 0; } if (n == 1) { return -1; } if (n == 2 || n == 3) { return n - 1; } return (n / 2) + (n % 2); }

Compilation message (stderr)

dna.cpp: In function 'int get_distance(int, int)':
dna.cpp:32:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |     for(int i=0;i<a.size();i++) {
      |                 ~^~~~~~~~~
#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...