secomo's blog

By secomo, history, 3 years ago, In English

my code has worked on codeblocks and when I send it. it is getting wrong answer on test 1 and the test message form is: " Wrong outout formats (0 elements printed ) unexpected end of file "

any help would be great

Spoiler

Full text and comments »

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

By secomo, history, 3 years ago, In English

Hi..

Given an array a that containes 2n elements each element has han an occurrence of 2 in the array.

so {1,2,4,1,4,2} would be an example, Now we have Q queries each query is asking for the maximum element on the segment L...R,but if the element has 2 occurrences on the segment L...R it will not be counted.

so if a={1,2,4,1,4,2} and query={2,6} the answer will be 1 because 4 and 2 will not be counted.

I think I can solve this uning Mo algorithm but I want a segment tree aproach.

Any help would be great, Thank you for reading.

Full text and comments »

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

By secomo, history, 3 years ago, In English

There is a tree that consists of one node(the root) let it be (1).

There is some queries each query is either

  1. find if x is ancestor of y.

  2. make x a son of y(its guaranteed that y exist).

If the first query does not exist its easy to solve it using DFS but I am stuck at finding a solution for the whole problem.

How to solve this?

Full text and comments »

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

By secomo, history, 3 years ago, In English

Example : {1,2,2,3,3}

the answer here is 5 :

{1,2,2} {1,2,3} {1,3,3} {2,2,3} {2,3,3}

I want a formula to calculate this.

I searched through Internet but I did not find a clear answer.

I am not good at math so I want a simple explination If that is possible. Thank you.

Full text and comments »

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

By secomo, history, 3 years ago, In English

hey... so I am learning about segment tree and I am wondring if It can solve this proplem that I came up with : given an array and some queries each query is a segment from index L to index R and the answer to the query is a[l]*1 + a[l+1]*2 + a[l+2]*3 +.... a[r]*(r-l+1) Is it possible to solve this proplem using segment tree and how? I am happy to see your opinions about this. Thank you for reading.

Full text and comments »

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