제출 #1118028

#제출 시각아이디문제언어결과실행 시간메모리
1118028nickolasarapidisDNA 돌연변이 (IOI21_dna)C++17
컴파일 에러
0 ms0 KiB
#include "dna.h"
#include <bits/stdc++.h>
using namespace std;

int N;

vector<tuple<int, int, int>> cntA(100001, make_tuple(0, 0, 0));
vector<tuple<int, int, int>> cntB(100001, make_tuple(0, 0, 0));

vector<int> A(100001);

// 0 = A, 1 = T, 2 = C

int get_distance(int x, int y){
    //cout << get<0>(cntA[y]) << " " << get<1>(cntA[y]) << " " << get<2>(cntA[y]) << "\n";
    //cout << get<0>(cntB[y]) << " " << get<1>(cntB[y]) << " " << get<2>(cntB[y]) << "\n";
    if(x == 0 and cntA[y] != cntB[y]) return -1;
    else if(cntA[y] != cntB[y] or cntA[x - 1] != cntB[x - 1]){
        return -1;
    }
    
    if(x == 0) return A[y] - 1;
    return A[y] - A[x - 1] - 1;
}

void init(string a, string b){
    N = a.size();
    
    for(int i = 0; i < N; i++){
        if(i != 0) cntA[i] = cntA[i - 1];
        if(a[i] == 'A') get<0>(cntA[i])++;
        else if(a[i] == 'T') get<1>(cntA[i])++;
        else get<2>(cntA[i])++;
    }
    
    for(int i = 0; i < N; i++){
        if(i != 0) cntB[i] = cntB[i - 1];
        if(b[i] == 'A') get<0>(cntB[i])++;
        else if(b[i] == 'T') get<1>(cntB[i])++;
        else get<2>(cntB[i])++;
    }
    
    if(a[0] != b[0]) A[0] = 1;
    else A[0] = 0;
    
    for(int i = 1; i < N; i++){
        A[i] = A[i - 1];
        if(a[i] != b[i]) A[i]++;
    }
}

int main(){
    init("ATACAT", "ACTATA");
    cout << get_distance(1, 3) << "\n";
    cout << get_distance(4, 5) << "\n";
    cout << get_distance(3, 5) << "\n";
}

컴파일 시 표준 에러 (stderr) 메시지

/usr/bin/ld: /tmp/cca9IKG3.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccryTFp2.o:dna.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status