dorasainath955's blog

By dorasainath955, history, 2 days ago, In English

Problem

In the editorial it was mentioned that upper bound of this problem will be in the order of $$$1000.2^{50}$$$.
But I am unable to understand why is that the case
1)How would the test case for the $$$sum = 1000.2^{50}$$$ would look like?
This is my understanding of the problem:

$$$A = [a_1, a_2, ..., a_n]$$$
$$$ans = \sum{A}$$$

Apply operation 2 as operation-1 just reverses the array, which doesn't affect the array sum. Reversing and doing operation-2 will just change the sign of the sum.

$$$A = [a_2-a_1, ..., a_n-a_{n-1}]$$$
$$$\sum{A} = a_{n}-a_{1}$$$

if we were to reverse the original array and did operation-2

$$$A = [a_n, a_{n-1}..., a_1]$$$
$$$A = [a_{n-1}-a_{n}, ..., a_1-a_{2}]$$$
$$$\sum{A} = a_1-a_n$$$
$$$ans = max(sum, -sum, ans)$$$

Keep repeating until we have single element left in $$$A$$$ From my point of view it just doesn't feel intuitive that sum could be the order of $$$1000.2^{50}$$$

Full text and comments »

  • Vote: I like it
  • -14
  • Vote: I do not like it

By dorasainath955, history, 3 weeks ago, In English

Submission
Problem

Approach

make the row and column sums to be equal to zero in other words let $$$x=0$$$ then construct the matrix
  1. Create two vectors call them as "row_sums" and "col_sums".
    $$$RowSums[i]$$$ corresponds to sum of all elements in $$$row_{i}$$$
    Same goes for col_sums

given $$$A = n\times m$$$ matrix, where it's always the case that $$$A_{1, 1}=0$$$(one based index), here we have 2 options to go to from $$$A_{1,1}$$$

  • Go right
  • Go down

Right

Going right indirectly means that $$$A_{i, 1} $$$ where $$$i \in [2, n]$$$ for all $$$i$$$ are never went missing these values are unchanged, find column-1 sum then replace $$$A_{1,1}=0$$$ with $$$A_{1,1}=-\sum_{i=1}^{n}{A_{i, 1}}$$$ since $$$A_{1, 1}=0$$$ we can take summation without having to worry about subtracting $$$A_{1,1}$$$ from the column sum
Then update the col_sums and row_sums array. col_sums[1] += $$$A_{1,1}$$$ and row_sums[1] += $$$A_{1,1}$$$
Update the position of the current indexes based on the next character value that comes from string s. if next character is D then increase the row index by 1. if next character is R update column index by 1.

Down

Going Down indirectly means that $$$A_{1, j} $$$ where $$$j \in [2, m]$$$ for all $$$j$$$ are never went missing these values are unchanged, find row-1 sum then replace $$$A_{1,1}=0$$$ with $$$A_{1,1}=-\sum_{j=1}^{m}{A_{1, j}}$$$ since $$$A_{1, 1}=0$$$ we can take summation without having to worry about subtracting $$$A_{1,1}$$$ from the row sum
Then update the col_sums and row_sums array. col_sums[1] += $$$A_{1,1}$$$ and row_sums[1] += $$$A_{1,1}$$$
Update the position of the current indexes based on the next character value that comes from string s. if next character is D then increase the row index by 1. if next character is R update column index by 1.

Repeat the process for all missing values

In the code I've Linked i used pair<int, int>current_pos, current_pos.first to track current row positon and current_pos.second to track current column position.

Full text and comments »

  • Vote: I like it
  • 0
  • Vote: I do not like it

By dorasainath955, history, 5 weeks ago, In English

Imagine a number N which is made of digits d repeating n times
eg:

$$$N = dddddd.....d$$$
(n times)
if we keep taking modulo of $$$N$$$(increase the number of digits) with some number $$$p$$$ at one point the modulo keeps on repeating eg: $$$d = 3$$$ and $$$p = 7$$$
Row Number N N mod 7
1 3 3
2 33 5
3 333 4
4 3333 1
5 33333 6
6 333333 0
7 3333333 3
8 33333333 5
9 333333333 4
10 3333333333 1
11 33333333333 6

From row 7 it keeps repeating
The reason i am asking this question due to this Problem

Is there any proof to this or is it just that I have to remember this.


It my first time encountering this pattern

Full text and comments »

  • Vote: I like it
  • +8
  • Vote: I do not like it

By dorasainath955, history, 4 months ago, In English

Submission
C1. Adjust The Presentation (Easy Version)

Approach: Assume that answer is "YA" and try to contradict it, if contradicted print "TIDAK"


  1. create a unique vector that consists of elements of "b" in such a way that no two consecutive elements are repeating
    b = {1, 1, 2, 2, 3} unqiue = {1, 2, 3}
  2. create a map mp that stores whether a element element has already occured(useful to verify if the slide encountered, bi can be given by person with same as bi).
    eg: b = {1, 2, 2, 1}, a = {1, 2, 3}, since person-1 and person-2 can give slide-1, 2. Then again we encountered slide-1 at b[3](zero index) so person-1(he's visited it) can be rearranged into giving slide-1 at b[3], map stores this information
    • Iterate through all elements of unique if the index i goes out of bounds for array a then break the loop;
    • if you find a[i] != b[i] && mp[unique[i]]==false then we can't arrange the persons in array to get our element bi print "TIDAK"

Full text and comments »

  • Vote: I like it
  • +5
  • Vote: I do not like it

By dorasainath955, history, 4 months ago, In English

Submission this is the problem I'm trying to solve, my approach is to create a map that consists of each element and their frequency count, then for intial MEX i try to find elements less than MEX and such that x%(mp[i]-MEX)==0 and mp[i]>1. i try to convert that repeating element into MEX, if i couldn't I'll break out and print the MEX as answer, else I'll repeat the process until i reach size of array n. Where am i going wrong?

Full text and comments »

  • Vote: I like it
  • 0
  • Vote: I do not like it

By dorasainath955, history, 4 months ago, In English
  • Vote: I like it
  • 0
  • Vote: I do not like it

By dorasainath955, history, 10 months ago, In English
  • Vote: I like it
  • 0
  • Vote: I do not like it

By dorasainath955, history, 10 months ago, In English

problem link: Problem

Submission Link : Submission

Full text and comments »

  • Vote: I like it
  • 0
  • Vote: I do not like it