Submission #966774

# Submission time Handle Problem Language Result Execution time Memory
966774 2024-04-20T10:27:34 Z SuPythony Mutating DNA (IOI21_dna) C++17
0 / 100
20 ms 9676 KB
#include "dna.h"
#include <bits/stdc++.h>
using namespace std;

vector<int> pf(1e5+1,0);
vector<vector<int>> pf2(3, vector<int>(1e5+1,0));
vector<vector<int>> pf3(3, vector<int>(1e5+1,0));

void init(string a, string b) {
    for (int i=1; i<=a.size(); i++) {
        if (a[i-1]!=b[i-1]) {
            pf[i]=pf[i-1]+1;
        } else {
            pf[i]=pf[i-1];
        }
    }
    for (int i=1; i<=a.size(); i++) {
        if (a[i-1]=='A') pf2[0][i]=pf2[0][i-1]+1;
        else pf2[0][i]=pf2[0][i-1];
        if (a[i-1]=='C') pf2[1][i]=pf2[1][i-1]+1;
        else pf2[1][i]=pf2[1][i-1];
        if (a[i-1]=='A') pf2[2][i]=pf2[2][i-1]+1;
        else pf2[2][i]=pf2[2][i-1];
    }
    for (int i=1; i<=a.size(); i++) {
        if (b[i-1]=='A') pf3[0][i]=pf3[0][i-1]+1;
        else pf3[0][i]=pf3[0][i-1];
        if (b[i-1]=='C') pf3[1][i]=pf3[1][i-1]+1;
        else pf3[1][i]=pf3[1][i-1];
        if (b[i-1]=='A') pf3[2][i]=pf3[2][i-1]+1;
        else pf3[2][i]=pf3[2][i-1];
    }
}

int get_distance(int x, int y) {
    x++; y++;
    if ((pf2[y][0]-pf2[x-1][0])!=(pf3[y][0]-pf3[x-1][0])||(pf2[y][1]-pf2[x-1][1])!=(pf3[y][1]-pf3[x-1][1])||(pf2[y][2]-pf2[x-1][2])!=(pf3[y][2]-pf3[x-1][2])) return -1;
    int c=pf[y]-pf[x-1];
    return c/2+c%2;
}

Compilation message

dna.cpp: In function 'void init(std::string, std::string)':
dna.cpp:10:20: 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:17:20: 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:25:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |     for (int i=1; i<=a.size(); i++) {
      |                   ~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Runtime error 20 ms 9676 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 3536 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 3536 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 3536 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 20 ms 9676 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -