evilution

Time limit: 1.25s Memory limit: 1024MB Input: Output:

The Good Guys plan to beat the Bad Guys by shooting them with ionizing radiation. To calibrate their weapons, the Good Guys need to know the composition of some interval of the Bad Guys’ DNA. The Bad Guys are not just bad – they’re evil – and so, they evolve every day by replacing each of the letters A, C, G, and T in their DNA with their corresponding strings of length at least 2: SA,SC,SGS_A, S_C, S_G and STS_T. There will be many fights over many days, and so the Good Guys need to make QQ different queries consisting of three numbers – Ki,LiK_i, L_i and RiR_i. For each query, you need to report four numbers, corresponding to the number of As, Cs, Gs, and Ts in the closed interval [Li;Ri][L_i; R_i] of the Bad Guys’ DNA on the KiK_i-th day.

Implementation details

You should implement the function solve:

std::vector<std::vector<long long>> solve(
       std::string S_0,
	   std::vector<std::string> S_ACGT,
	   std::vector<long long> K,
	   std::vector<long long> L,
	   std::vector<long long> R
)
  • S0S_0: the Bad Guys' DNA on the 00-th day;
  • SACGTS_{ACGT}: the 44 strings SA,SC,SG,STS_A, S_C, S_G, S_T;
  • KK: vector of QQ non-negative integers, the ii-th of which is KiK_i;
  • LL: vector of QQ non-negative integers, the ii-th of which is LiL_i;
  • RR: vector of QQ non-negative integers, the ii-th of which is RiR_i;

This function is called exactly once for each test case. It has to return a vector of QQ 4-element vectors - the number of As, Cs, Gs and Ts in the corresponding queries.

Constraints and clarifications

  • 2S1052 \leq S \leq 10^5, where S=max(S0,SA,SC,SG,ST)S = max(|S_0|, |S_A|, |S_C|, |S_G|, |S_T)
  • It is guaranteed that all letters in the strings are A, C, G, T.
  • 1Q1041 \leq Q \leq 10^4
  • 0Ki10180 \leq K_i \leq 10^{18} for all 0iQ10 \leq i \leq Q-1
  • 0LiRi10180 \leq L_i \leq R_i \leq 10^{18} for all 0iQ10 \leq i \leq Q-1
  • It is guaranteed that for all queries there exist letters with indices from LiL_i to RiR_i.
Subtask Points Required subtasks SS QQ KiK_i Other constraints
0 0 - - - - The sample test.
1 7 0 5\leq 5 100\leq 100 10\leq 10 -
2 6 0-1 6\leq 6 104\leq 10^4 10\leq 10 -
3 13 0-2 103\leq 10^3 104\leq 10^4 50\leq 50 -
4 10 0-3 105\leq 10^5 104\leq 10^4 50\leq 50 -
5 15 0-4 105\leq 10^5 104\leq 10^4 2103\leq 2 \cdot 10^3 -
6 7 - 105\leq 10^5 104\leq 10^4 1018\leq 10^{18} Li=Ri=0L_i = R_i = 0.
7 17 0-3 103\leq 10^3 104\leq 10^4 1018\leq 10^{18} -
8 25 0-7 105\leq 10^5 104\leq 10^4 1018\leq 10^{18} -

Example

stdin

TAG
TGT
CGT
CCT
CGC
10
1 3 3
2 2 5
0 0 2
0 2 2
0 0 2
1 8 8
0 1 1
1 0 5
0 0 1
1 2 7

stdout

0 0 0 1
0 2 0 2
1 0 1 1
0 0 1 0
1 0 1 1
0 0 0 1
1 0 0 0
0 2 2 2
1 0 0 1
0 3 1 2

Explanation

The Bad Guys’ DNA for the 00-th, 11-st, and 22-nd day is as follows:

  • TAG
  • CGCTGTCCT
  • CGTCCTCGTCGCCCTCGCCGTCGTCGC

Sample grader

Input format:

  • line 11 to 55: S0,SA,SC,SG,STS_0, S_A, S_C, S_G, S_T.
  • line 66: QQ – the number of queries.
  • line 77 to 7+(Q1)7 + (Q − 1): Ki,Li,RiK_i, L_i, R_i.

Output format:

  • line ii – the numbers returned by the ii-th call.

Log in or sign up to be able to send submissions!