Submission #1009514

#TimeUsernameProblemLanguageResultExecution timeMemory
1009514induwara16Mutating DNA (IOI21_dna)C++17
0 / 100
1582 ms2880 KiB
#include "dna.h"
#include <bits/stdc++.h>

using namespace std;

typedef string str;
typedef vector<int> vi;

str a, b;

void init(std::string a1, std::string b2)
{
	a = a1;
	b = b2;
}

int get_distance(int x, int y)
{
	str a1 = a.substr(x, y);
	str b1 = b.substr(x, y);
	int n = a1.length(), c = 0;

	int as = count(a1.begin(), a1.end(), 'A');
	int cs = count(a1.begin(), a1.end(), 'C');
	int ts = n - as - cs;

	int as1 = count(b1.begin(), b1.end(), 'A');
	int cs1 = count(b1.begin(), b1.end(), 'C');
	int ts1 = n - as1 - cs1;

	if ((as != as1) || (cs != cs1) || (ts != ts1))
		return -1;
	else
		return 0;
	// if ((as == n) || (cs == n) || (ts == n))
	// 	return 0;

	// if ((as == 0) || (cs == 0) || (ts == 0))
	// 	return 1;

	// bool same = false;
	// for (int i = 0; i < n; i++)
	// {
	// 	if (a1[i] == b1[i])
	// 	{
	// 		same = true;
	// 		break;
	// 	}
	// }

	// return same ? 1 : 2;
}

Compilation message (stderr)

dna.cpp: In function 'int get_distance(int, int)':
dna.cpp:21:23: warning: unused variable 'c' [-Wunused-variable]
   21 |  int n = a1.length(), c = 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...