Submission #1053235

#TimeUsernameProblemLanguageResultExecution timeMemory
1053235ZicrusMutating DNA (IOI21_dna)C++17
35 / 100
28 ms5232 KiB
#include <bits/stdc++.h> #include "dna.h" using namespace std; typedef long long ll; string a, b; vector<ll> sum, sumA, sumB; void init(string a1, string b1) { a = a1; b = b1; sum = vector<ll>(a.size()+1); for (int i = 1; i <= a.size(); i++) { sum[i] = sum[i-1] + (a[i-1] != b[i-1]); } sumA = vector<ll>(a.size()+1); for (int i = 1; i <= a.size(); i++) { sumA[i] = sumA[i-1] + (a[i-1] == 'A'); } sumB = vector<ll>(a.size()+1); for (int i = 1; i <= a.size(); i++) { sumB[i] = sumB[i-1] + (b[i-1] == 'A'); } } int get_distance(int x, int y) { if (sumA[y+1] - sumA[x] != sumB[y+1] - sumB[x]) return -1; ll cnt = sum[y+1] - sum[x]; return cnt / 2; }

Compilation message (stderr)

dna.cpp: In function 'void init(std::string, std::string)':
dna.cpp:13:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   13 |     for (int i = 1; i <= a.size(); i++) {
      |                     ~~^~~~~~~~~~~
dna.cpp:17:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   17 |     for (int i = 1; i <= a.size(); i++) {
      |                     ~~^~~~~~~~~~~
dna.cpp:21:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   21 |     for (int i = 1; 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...