Looksery Cup Editorial

Source: Internet
Author: User

Here is the puzzle, do not do well. The next goal is rating up to 1800, not a dozen times CF

A. Face Detection

Author:monyura

One should iterate through each 2x2 square and check if it's possible to rearrange letters in such it they they form the Word "face". It could be do i.e. by sorting all letters from the square in alphabetic order and comparing the result with the word "a" CEF "(sorted letters of word" face ").

B. Looksery Party

Author:igor_kudryashov

In any cases there was such set of people that if they come on party and send messages to their contacts then each employee Receives the number of messages that's different from what Igor pointed. Let's show how to build such set. There is 2 cases.

There is no zeros among Igor ' s numbers. So if nobody comes on party then each employee receives 0 messages and, therefore, the desired set is empty.

There is at least one zero. Suppose Igor thinks that I-th employee would receive 0 messages. Then we should add i-th employee in the desired set. He'll send messages to his contacts and would receive 1 message from himself. If we add other employees in the desired set then the number of messages that i-th employee would receive would not decrease So we can remove him from considering. Igor pointed some numbers for people from the contact list of i-th employee and because they has already received one message We need to decrease these numbers by one. After then we can consider the same problem but with number of employees equals to n-1. If the remaining number of employees is equal to 0 then the desired set is built.

C. The Game of Parity

Author:olpetodessaonu

If n = k No moves May is done. The winner is determined with starting parity of citizens ' number. Otherwise let's see that's the player making the last move could guarantee his victory, if there is both odd and even cities When he makes the move. He just selects the city of which parity he should burn to obtain required parity. So, he enemy ' s target is to destroy all the cities of some one type. Sometimes the type does matter, sometimes doesn ' t. It depends on the player ' s name and the parity of K. So the problem's solution consists in checking if "non-last" Player ' s moves number (N-K)/2 are enough to destroy all th e odd or even cities. If Stannis makes the last move and K are odd, Daenerys should burn all the odd or all the even cities. If K is even, Daenerys should burn all the odd cities. If Daenerys makes the last move and K is even, Stannis have no chance to win. If k is odd, Stannis should burn all the even cities.

D. Haar Features

Author:monyura

This problem had a complicated statement but it's very similar to the real description of the features. Assume that we have a solution. It means we have a sequence of prefix-rectangles and coefficients to multiply. We can sort that sequence by the bottom-right corner of the rectangle and feature ' s value wouldn ' t is changed. Now we could apply our operations from the last one to the first. To calculate the minimum number of operations we'll iterate through each pixel starting from the bottom-right in The Column-major or raw-major order. For each pixel we'll maintain the coefficient with which it appears in the feature ' s value. Initially it is 0 for all. If the coefficient of the current cell are not equal to + 1 for W and-1 for B We increment the required amount of opera tions. Now we should make coefficient to has a proper value. Assume that it had to being X (-1 or + 1 depends on the color) but current coefficient of this pixel is C. Then we should anyway add this pixel 's value to the feature's value with the coefficient x-c. But the only-to-pixel ' s value now (after skipping all pixels, that has not smaller index of both row and Colum N) is-get sum on the prefix rectangle with the bottom-left corner in this pixel. Doing This addition we also add x-c to the coefficient of all pixels in prefix-rectangle. This solution could is implemented as I describe above in  o(n2m2) or o(nm).

Also I want to notice so in real Haar-like features one applies them don't to the whole image but to the part of the image . Anyway, the minimum amount of operations could is calculated in the same.

E. Sasha Circle

Authors:krasnokutskiy, 2222

Coming soon

F. Yura and Developers

Authors:rubanenko

Let ' s consider following solution:

LetF(L,RBeing the solution for[L,R] Subarray. It ' s easyF(1,N) is the answer for the given problem. How should one countF(L,R)? LetmBe a index of the maximum value over Subarray[L,R]. All theGoodSegments can divided into and non-intersecting sets:those that containmAnd those that don ' t. To count the latter we can callF(L,m-1) andF(m+ 1,R). We is left with counting the number of subarrays that containm, i.e. the number of pairs(I,J) such thatLI<m<JRandg(I,m-1) +g(m+ 1,J)%k= 0 (g(s,T) definesas+as+ 1 + ... +aT). LetsBe the sequence of the partial sums of the given array, i.e.sI=a1 +a2 + ... +aI. For everyJWe is interested in the number of suchIThatsJ-sI-am%k= 0, so if we iterate over every possible J , then we is interested in number Of i  that   s i = s J - a m ( modk )  and   l i < m . So we is left with simple query over the segment problem of form "How many numbers equal To x  and belong to a given Segment  ( l , R ) ". It can be do in  O ( q + k )  time and memory, where < Span class= "Tex-span" > q  is the number of generated queries. Model solution processes all the queries in offline mode, using frequency array.

One can notice in the worst case we can Generate  O ( n 2)  queries which doesn ' t fit into TL or ML. However, we can choose which is faster:iterate over all Possible  J  or < Span class= "Tex-span" > i . In both cases we get an easy congruence which ends up as a query described above. If we iterate only through the smaller segment, every time we "look at" the Element  w &NB Sp;it moves to a smaller segment which are at least the times smaller than the previous one. So, every element would end up in 1-element length segment where recursion would meet it ' s base in  O ( log ( n )) ' Looking at ' this element.

The overall complexity is O(n x log(n) + K).

G. Happy Line

authors:2222, Mrdindows

Let's reformulate the condition in terms of a certain height the towers, which'll be is on the stairs. Then an appropriate amount of money of a person in the queue are equal to the height of the tower with the height of the St EP at which the tower stands. And the process of moving in the queue would be equivalent to raising a tower on the top step, and the one in whose place I T came Up-down. As shown in the illustrations. Then, it becomes apparent, and that's the tower on the steps to be sorted, it's enough to sort the tower without The height of step it stays. Total complexity of sorting is O (Nlog (n)).

H. Degenerate Matrix

Author:igor_kudryashov

The rows of degenerate matrix is linear dependent so the matrix B can is written in the following-to:

Suppose

Let's assume that elements of the first row of Matrix  A  are coordinates of PO Int  a 0 on two-dimensional plane and the Elements of the second row is coordinates of Point  a 1. Assume that the rows of Matrix  B  are also coordinates of Points  b 0 and  b 1. Let's note that in this case the line that's passing through Points  b 0 and  b 1 is also passing Through Point  (0, 0).

Let ' s find the answer-the number d -by using binary search. Suppose we are considering some number D0. We need to check if there are such matrix B that

In geometric interpretation it means this pointb0 is inside the square which center was pointa0 and length of side is2 · D 0. In the same, the point b1 is inside the square which center was point a1 and L Ength of side is 2 · D0. So we need to check if there are a line which is passing through point (0, 0) and is crossing these squares. In order to does this we should consider every vertex of the first square, build the line it is passing through the chosen Vertex and the center of coordinate plane and check if it cross any side of the other square. Afterwards we should swap the squares and check again. Finally if there is a desired line we need to reduce the search area and to expand otherwise.

Looksery Cup Editorial

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.