Answers for "mixing proteins hackerrank solution"

0

mixing proteins hackerrank solution

#include <cstdio>
#include <iostream>
#include <fstream>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <string>
#include <ctime>
#include <cassert>
#include <utility>

using namespace std;

#define MAXN 1000050

int N, K;
string S;
int A[MAXN];
int B[MAXN];

int main() {

	cin.sync_with_stdio(false);
	
	cin >> N >> K >> S;
	
	for (int i = 0; i < N; i++) {
		A[i] = S[i] - 'A';
	}
	for (int j = 30; j >= 0; j--) {
		if (K & (1 << j)) {
  			for (int i = 0; i < N; i++) {
				int o = (i - (1 << j)) % N;
				if (o < 0) {
					o += N;
				}
 				B[o] = A[i] ^ A[o];
			}
			memcpy(A, B, sizeof(A));
		}
	}
	
  	for (int i = 0; i < N; i++) {
		S[i] = A[i] + 'A';
	}
	cout << S << endl;
	
	return 0;
}
Posted by: Guest on September-29-2021

Code answers related to "mixing proteins hackerrank solution"

Browse Popular Code Answers by Language