Submission #438870

#TimeUsernameProblemLanguageResultExecution timeMemory
438870amallaMutating DNA (IOI21_dna)C++17
35 / 100
111 ms31208 KiB
#include<bits/stdc++.h> using namespace std; typedef vector<int> VI; const int maxN = 100'000; vector<VI> A(maxN+4, VI(3)), B(maxN+4, VI(3)), AW(maxN+4, VI(2)), TW(maxN+4, VI(2)), CW(maxN+4, VI(2)); void init(string a, string b) { for (int i = 1; i<=a.size(); ++i) { A[i] = A[i-1], B[i] = B[i-1], AW[i] = AW[i-1], TW[i] = TW[i-1], CW[i] = CW[i-1]; if (a[i-1]=='A') { ++A[i][0]; if (b[i-1]=='T') ++TW[i][0]; else if (b[i-1]=='C') ++CW[i][0]; } else if (a[i-1]=='T') { ++A[i][1]; if (b[i-1]=='A') ++AW[i][0]; else if (b[i-1]=='C') ++CW[i][1]; } else { ++A[i][2]; if (b[i-1]=='A') ++AW[i][1]; else if (b[i-1]=='T') +TW[i][1]; } if (b[i-1]=='A') ++B[i][0]; else if (b[i-1]=='T') ++B[i][1]; else ++B[i][2]; } } int get_distance(int x, int y) { if ( (A[y+1][0] - A[x][0] == B[y+1][0] - B[x][0]) && (A[y+1][1] - A[x][1] == B[y+1][1] - B[x][1]) && (A[y+1][2] - A[x][2] == B[y+1][2] - B[x][2]) ) { return min(AW[y+1][0] - AW[x][0], TW[y+1][0]-TW[x][0]) + min(AW[y+1][1] - AW[x][1], CW[y+1][0]-CW[x][0]) + min(CW[y+1][1] - CW[x][1], TW[y+1][1]-TW[x][1]) + abs((CW[y+1][1] - CW[x][1]) - (TW[y+1][1]-TW[x][1]))*2; } return -1; }

Compilation message (stderr)

dna.cpp: In function 'void init(std::string, std::string)':
dna.cpp:10:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   10 |     for (int i = 1; i<=a.size(); ++i) {
      |                     ~^~~~~~~~~~
dna.cpp:25:35: warning: value computed is not used [-Wunused-value]
   25 |             else if (b[i-1]=='T') +TW[i][1];
#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...