Блог пользователя ikatanic

Автор ikatanic, 12 лет назад, По-английски

Join us on Saturday, March 7th, 2015 for the seventh round of COCI!

Click here to see when the coding begins in your timezone!

  • Проголосовать: нравится
  • +30
  • Проголосовать: не нравится

»
12 лет назад, скрыть # |
← Rev. 2  
Проголосовать: нравится +75 Проголосовать: не нравится

I guess you like prime numbers, don't you? :P

I mean the rounds that you announce.

Good luck to everyone!

»
12 лет назад, скрыть # |
← Rev. 2  
Проголосовать: нравится +11 Проголосовать: не нравится

Let's discuss the problems now. What is the idea behind the 5-th task? I used the O(N^2) in case N<=7000. Otherwise, I do this 2^20 times:

1) Take a random L: K<=L<=N

2) Take a random F: F+L-1<=N

3) T=F+L-1

4) Take the average for the interval [F,T] and compare it to the answer...

Update: WTF?! It got full score :D

»
12 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

How to solve C?

  • »
    »
    12 лет назад, скрыть # ^ |
    ← Rev. 2  
    Проголосовать: нравится +5 Проголосовать: не нравится

    My idea is to consider all permutations of the rows. I mean:

    row1

    row2

    row3

    and then

    row1

    row3

    row2

    and so on...

    Now, let's build a graph for each permutation. From element in row i and column j there is an edge to (i,j+1) with weight a[i][j+1] and to (i+1,j+1) with weight a[i+1][j+1]. Of course, if there are no such positions we will not put edges.

    For each permutation run Dijkstra from (1,1). The answer for the current permutation will be in (3,N). At the end, the answer is the minimum of the answers for each permutation.

    Code: http://ideone.com/CMXKqJ

  • »
    »
    12 лет назад, скрыть # ^ |
    ← Rev. 3  
    Проголосовать: нравится +5 Проголосовать: не нравится

    let see all permutation about this 3 array. first we are picking numbers from first,then from second and then from third: then if you are picking numbers from second array in (l,r) segment, for this ans=sum[1][l]+sum[2][r]-sum[2][l]+sum[3][n]-sum[3][r] (sum[i] its prefix sums in i array).

    if we will choose l from 1 to n-2, all will be const except sum2[r]-sum3[r],this means that we need such r,that sum[2][r]-sum[3][r] will as small as possible,you can write preprocessing for it,its all. sorry for my bad english )) here code.

»
12 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

I came up with different N*sqrt N solution for 5th task: If we have an subsequence with average a [L,R], we can add to end of it subsequence [R+1,X] where [R+1,X] has largest average from all subsequences that begin in R+1 and the average is larger than a.(it will increase average of original subsequence). We will do this until there isn´t any subsequence that we can add to end.
To make it faster we will add only subsequences that are larger than sqrt(N), and when there is no subsequence larger than sqrt(n), we will add subsequence smaller than sqrt(N) that will at most increase the average of subsequence.

We can calculate where ends the subsequence larger than sqrt(n) with largest average with similar DP method(from right to left).

Is this solution correct and would it pass?

I am really sorry for my bad english.

»
12 лет назад, скрыть # |
 
Проголосовать: нравится +10 Проголосовать: не нравится

Last November, There was a task which is almost the same with the 5th one of this COCI at the Turkish National Olympiad In Informatics. Unlikely with the COCI version of this task, Turkish one was required finding the average of the consequtive subsequence whose average is maximum off all the consequtive subsequences whose lengths are between given two integers A and B. The time complexity for this question was O(NlogT). ( T = number range )