제출 #727042

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

#define N '\n';
#define VI <vector <int>>
#define VVI <vector <vector <int>>>  
string s, s2;

int getDistance(int x, int y){
    map<char, int> el;
    map<char, int> el2;
    for(int i = x-1; i < y; i++){
        el[s[i]]++;
        el[s2[i]]++;
    }
    
    auto x2 = el.begin();
    auto y2 = el2.begin();
    bool possible = 1;
    for(int i = x - 1; i < y; i++){
        if(x2->second != y2->second){
            possible = 0;
        }
    }
    if(!possible){
        return -1;
    }
    
    int swaps = 0;
    int alright = 0;
    while(alright == y-x){
        for(int i = x-1, alright = 0; i < y; i++, alright++){
            if(s[i] != s2[i]){
                alright--;
                bool ok = 0;
                int pos = -1;
                for(int j = i + 1; j < y; j++){
                    if(s2[j] == s[i] && s2[i] == s[j]){
                        s2[i] = s[i];
                        s2[j] = s[j];
                        swaps++;
                        ok = 1;
                        break;
                    }
                    else if(s2[j] == s[i] && pos == -1){
                        pos = j;
                    }
                }
                if(!ok){
                    if(pos != -1){
                        char a = s2[i];
                        s2[pos] = s[i]; 
                        s2[pos] = a;
                        swaps++;
                    }
                }
            }
        }
    }
    
    return swaps;
}


void init(string a, string b){
    s = a;
    s2 = b;
}

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

/usr/bin/ld: /tmp/cc30PlbP.o: in function `main':
grader.cpp:(.text.startup+0x39d): undefined reference to `get_distance(int, int)'
collect2: error: ld returned 1 exit status