Submission #1150757

#TimeUsernameProblemLanguageResultExecution timeMemory
1150757zhasynDNA 돌연변이 (IOI21_dna)C++20
0 / 100
32 ms3072 KiB
#include "dna.h"
#include <bits/stdc++.h>
#define pb push_back
#define pf push_front
using namespace std;
#define F first
#define S second
typedef long long ll;
#define pii pair <int, int>
#define pll pair <ll, ll>
typedef long double ld;
const ll N = 1e5 + 100, M = 4096 + 10, len = 21, inf = 1e18;
const ll mod = 1e9 + 7;

int fen[6][N];
void upd(int code, int i){
	for(; i < N; i = (i | (i + 1))){
		fen[code][i]++;
	}
}
int get(int code, int r){
	int res = 0;
	for(; r >= 0; r = (r & (r + 1)) - 1){
		res += fen[code][r];
	}
	return res;
}
int get(int l, int r, int code){
	if(l == 0) return get(code, r);
	else return get(code, r) - get(code, l - 1);
}
void init(string a, string b) {
	int n = (int)a.size();
	for(int i = 0; i < n; i++){
		int code;
		if(a[i] == b[i]) continue;
		if(a[i] == 'A'){
			if(b[i] == 'C') code = 2;
			else code = 0;
		}
		if(a[i] == 'T'){
			if(b[i] == 'A') code = 1;
			else code = 4;
		}
		if(a[i] == 'C'){
			if(b[i] == 'A') code = 3;
			else code = 5;
		}
		upd(code, i);
	}
}
int get_distance(int x, int y) {
	vector <pii> vec;
	int ans = 0;
	for(int i = 0; i <= 4; i += 2){
		int fr = get(x, y, i);
		int sc = get(x, y, i + 1);		
		ans += min(fr, sc);
		if(fr > sc) vec.pb({i, fr - sc});
		else vec.pb({i + 1, sc - fr});
	}
	if(vec[0].S == vec[1].S && vec[1].S == vec[2].S){
		if(vec[0].F == 0 && vec[1].F == 3 && vec[2].F == 4) 
			return ans + vec[0].S * 2;
			
		if(vec[0].F == 1 && vec[1].F == 2 && vec[2].F == 5) 
			return ans + vec[0].S * 2;
	}
	
	return -1;
}

// int main(){
  	// ios::sync_with_stdio(false);
  	// cin.tie(NULL);
  	// string ax, bx;
  	// cin >> ax >> bx;
  	// init(ax, bx);
  	// cout << get_distance(3, 5);
  // return 0;
// }

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