제출 #670567

#제출 시각아이디문제언어결과실행 시간메모리
670567sleepntsheepMutating DNA (IOI21_dna)C++17
0 / 100
29 ms5012 KiB
#include <stdio.h>
#include <string.h>
#include <string>

using namespace std;

#define N 100005
#define ABS(x) ((x) < 0 ? (-(x)) : (x))

char a[N], b[N];
int unlike[N];
int counta[N][3];
int countb[N][3];

void init(string a_, string b_) {
    strcpy(a+1, a_.c_str());
    strcpy(b+1, b_.c_str());
    for (int i = 1; a[i]; i++) {
        unlike[i] = unlike[i-1] + !!(a[i] - b[i]);
        for (int j = 0; j < 3; j++) {
            counta[i][j] = counta[i-1][j] + (j["ATC"] == a[i]);
            countb[i][j] = countb[i-1][j] + (j["ATC"] == b[i]);
        }
    }
}

int get_distance(int x, int y) {
    x++;y++;
    for (int i = 0; i < 3; i++)
        if (counta[y][i] - counta[x-1][i] != countb[y][i] - countb[x-1][i])
            return -1;
    int wrong = unlike[y] - unlike[x-1];
    return (wrong - wrong % 3) / 2 + "\0\1\2"[wrong%3];
}

#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...