Submission #549080

#TimeUsernameProblemLanguageResultExecution timeMemory
549080SlyGaleebMutating DNA (IOI21_dna)C++17
56 / 100
39 ms5672 KiB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define ld long double
#define vf v[i].first
#define vs v[i].second
const ll MOD = 1e9 + 7;

void print(vector<int> &v) {
	for (auto c:v)
		cout << c << " ";
	cout << "\n";
}

vector<int>pref = {0};
vector<int>prefA1 = {0};
vector<int>prefT1 = {0}; 
vector<int>prefC1 = {0}; 
vector<int>prefA2 = {0};
vector<int>prefT2 = {0};
vector<int>prefC2 = {0};

int n;
string c,d;

void init(string a, string b) {
	n = a.size();
	c = a;
	d = b;
	int a1=0,a2=0,b1=0,b2=0,c1=0,c2=0,ans=0;
	for (int i = 0; i < n; ++i) {
		if (a[i]!=b[i])
			++ans;
		pref.push_back(ans);
		if (a[i]=='A') 
			a1++;
		prefA1.push_back(a1);
		if (a[i]=='T') 
			b1++;
		prefT1.push_back(b1);
		if (b[i]=='A') 
			a2++;
		prefA2.push_back(a2);
		if (b[i]=='T') 
			b2++;
		prefT2.push_back(b2);
		if (a[i]=='C')
			c1++;
		prefC1.push_back(c1);
		if (b[i]=='C')
			c2++;
		prefC2.push_back(c2);
	}
}

int get_distance(int x, int y) {
	int ans = 0;
	if (prefA1[y+1]-prefA1[x]!=prefA2[y+1]-prefA2[x] || prefT1[y+1]-prefT1[x]!=prefT2[y+1]-prefT2[x] || prefC1[y+1]-prefC1[x]!=prefC2[y+1]-prefC2[x])
		return -1;
	return (pref[y+1]-pref[x]+1)/2;

}

/*int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	string a,b;
	cin >> a >> b;
	init(a,b);
	cout << get_distance(1,3);
	cout << "\n";
	print(pref);
	print(prefA1);
	print(prefA2);
	print(prefT1);
	print(prefT2);
}*/

Compilation message (stderr)

dna.cpp: In function 'int get_distance(int, int)':
dna.cpp:57:6: warning: unused variable 'ans' [-Wunused-variable]
   57 |  int ans = 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...