제출 #1142077

#제출 시각아이디문제언어결과실행 시간메모리
1142077jokerDNA 돌연변이 (IOI21_dna)C++17
0 / 100
1595 ms2116 KiB
#include "dna.h"
#include <unordered_set>
#include <unordered_map>
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <iomanip>
#include <numeric>

using namespace std;
string ast;
string bst;

void init(std::string a, std::string b) {
    ast = a;
    bst = b;
}

int get_distance(int x, int y) {
    string sl = ast.substr(x,y-x+1);
    string sr = bst.substr(x,y-x+1);

    string t1 = sl;
    string t2 = sr;
    sort(t1.begin(),t1.end());
    sort(t2.begin(),t2.end());
    if (t1 == t2) {
        int ans = 0;
        int i = 0;
        while (sl != sr) {
            if (sl[i] == sr[i]) {
                i++;
            } else {
                char sw;
                for (size_t j = i+1;j < y-x+1;j++){
                    if (sl[j] == sr[i] && sr[j] != sl[j] && sr[j] == sl[i]) {
                        sw = sl[j];
                        break;
                    }else if (sl[j] == sr[i] && sr[j] != sl[j]) {
                        sw = sl[j];
                    }
                }
                ans++;
            }
        }
        return ans;
    }
	return -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...