이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include"bits/stdc++.h"
#include "dna.h"
using namespace std;
const int sz = 1e5 + 5;
int pa[sz], pt[sz];
int n;
string s, t;
void init(string a, string b) {
	n = a.size();
	s = ' ' + a, t = ' ' + b;
	for (int i = 1; i <= n; i ++) {
		pa[i] = pa[i - 1], pt[i] = pt[i - 1];
		if ('A' == s[i] && 'T' == t[i]) {
			pa[i] ++;
		} else if ('T' == s[i] && 'A' == t[i]) {
			pt[i] ++;
		}
	}
}
int get_distance(int x, int y) {
	x ++, y ++;
	if (y - x <= 2) {
		vector<vector<int>> v;
		for (int i = x; i < y; i ++) {
			for (int j = i + 1; j <= y; j ++) {
				v.push_back({i, j});
			}
		}
		map<char, int> cna, cnt;
		for (int i = x; i <= y; i ++) {
			cna[s[x]] ++, cnt[t[x]] ++;
		}
		if (cna['A'] != cnt['A'] || cna['C'] != cnt['C'] || cna['T'] != cnt['T']) {
			return -1;
		}
		int mn = INT_MAX;
		do {
			string scp = s;
			int c = 0;
			for (auto& i : v) {
				c ++;
				swap(scp[i[0]], scp[i[1]]);
				if (scp.substr(x, (y - x + 1)) == t.substr(x, (y - x + 1))) {
					break;
				}
			}
			mn = min(mn, c);
		} while (next_permutation(begin(v), end(v)));
		return mn;
	} else {
		int pac = pa[y] - pa[x - 1];
		int ptc = pt[y] - pt[x - 1];
		if (pac != ptc) {
			return -1;
		} else {
			return pac;
		}
	}
}
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... |