Submission #484391

#TimeUsernameProblemLanguageResultExecution timeMemory
484391Spade1Mutating DNA (IOI21_dna)C++17
0 / 100
37 ms5892 KiB
#include <bits/stdc++.h> #include "dna.h" #define ll long long #define pii pair<int, int> #define st first #define nd second #define pb push_back using namespace std; string debug[] = {"AC", "AT", "CA", "CT", "TA", "TC"}; int p[100010][6]; void init(string a, string b) { for (int i = 1; i <= a.size(); ++i) { if (a[i - 1] == 'A' && b[i - 1] == 'C') p[i][0]++; if (a[i - 1] == 'A' && b[i - 1] == 'T') p[i][1]++; if (a[i - 1] == 'C' && b[i - 1] == 'A') p[i][2]++; if (a[i - 1] == 'C' && b[i - 1] == 'T') p[i][3]++; if (a[i - 1] == 'T' && b[i - 1] == 'A') p[i][4]++; if (a[i - 1] == 'T' && b[i - 1] == 'C') p[i][5]++; for (int j = 0; j < 6; ++j) { p[i][j] += p[i - 1][j]; } } } int get_distance(int x, int y) { ++x, ++y; bool a = (p[y][0] - p[x - 1][0] + p[y][1] - p[x - 1][1] == p[y][2] - p[x - 1][2] + p[y][4] - p[x - 1][4]); bool c = (p[y][2] - p[x - 1][2] + p[y][3] - p[x - 1][3] == p[y][0] - p[x - 1][0] + p[y][5] - p[x - 1][5]); bool t = (p[y][4] - p[x - 1][4] + p[y][5] - p[x - 1][5] == p[y][1] - p[x - 1][1] + p[y][3] - p[x - 1][3]); if (!(a && c && t)) return -1; if (y - x == 1) return 1; int ans = -1; for (int i = 0; i < 6; ++i) { ans += p[y][i] - p[x - 1][i]; } ans -= min(p[y][0] - p[x - 1][0], p[y][2] - p[x - 1][2]); ans -= min(p[y][1] - p[x - 1][1], p[y][4] - p[x - 1][4]); ans -= min(p[y][3] - p[x - 1][3], p[y][5] - p[x - 1][5]); return ans; }

Compilation message (stderr)

dna.cpp: In function 'void init(std::string, std::string)':
dna.cpp:14:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   14 |     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...