Looksery Cup 2015 Editorial
下面是题解,做的不好。下一步的目标是rating涨到 1800,没打过几次cf
A. Face Detection
Author: Monyura
One should iterate through each 2x2 square and check if it is possible to rearrange letters in such way they they form the word "face". It could be done i.e. by sorting all letters from the square in alphabetic order and comparing the result with the word "acef"(sorted letters of word "face").
B. Looksery Party
Author: Igor_Kudryashov
In any cases there is 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 is different from what Igor pointed. Let's show how to build such set. There are 2 cases.
There are 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 will receive 0 messages. Then we should add i-th employee in the desired set. He will send messages to his contacts and will receive 1 message from himself. If we add other employees in the desired set then the number of messages that i-th employee will receive will not decrease so we can remove him from considering. Igor pointed some numbers for people from contact list of i-th employee and because they have already received one message we need to decrease these numbers by one. After that 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 be done. The winner is determined with starting parity of citizens' number. Otherwise let's see that the player making the last move may guarantee his victory, if there are 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, his 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 is enough to destroy all the odd or even cities. If Stannis makes the last move and k is 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 has 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 is 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 be changed. Now we could apply our operations from the last one to the first. To calculate the minimum number of operations we will iterate through each pixel starting from the bottom-right in any of the column-major or raw-major order. For each pixel we will 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 is not equal to + 1 for W and - 1 for B we increment the required amount of operations. Now we should make coefficient to have a proper value. Assume that it has to be 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 way to add this pixel's value now(after skipping all pixels that have not smaller index of both row and column) is to 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 be implemented as I describe above in O(n2m2) or O(nm).
Also I want to notice that in real Haar-like features one applies them not to the whole image but to the part of the image. Anyway, the minimum amount of operations could be calculated in the same way.
E. Sasha Circle
Authors: Krasnokutskiy, 2222
Coming soon
F. Yura and Developers
Authors: Rubanenko
Let's consider following solution:
Let f(l, r) be the solution for [l, r] subarray. It's easy to see that f(1, n) is the answer for the given problem. How should one countf(l, r)? Let m be an index of the maximum value over subarray [l, r]. All the good segments can be divided into two non-intersecting sets: those that contain m and those that don't. To count the latter we can call f(l, m - 1) and f(m + 1, r). We are left with counting the number of subarrays that contain m, i.e. the number of pairs (i, j) such that l ≤ i < m < j ≤ r and g(i, m - 1) + g(m + 1, j)%k = 0(g(s, t) defines as + as + 1 + ... + at). Let s be the sequence of partial sums of the given array, i.e. si = a1 + a2 + ... + ai. For every j we are interested in the number of such i that sj - si - am%k = 0, so if we iterate over every possible j, then we are interested in number ofi that si = sj - am(modk) and l ≤ i < m. So we are left with simple query over the segment problem of form "how many numbers equal tox and belong to a given segment (l, r)". It can be done in O(q + k) time and memory, where q is the number of generated queries. Model solution processes all the queries in offline mode, using frequency array.
One can notice that in the worst case we can generate O(n2) queries which doesn't fit into TL or ML. However, we can choose which is faster: iterate over all possible j or i. In both cases we get an easy congruence which ends up as a query described above. If we iterate only over the smaller segment, every time we "look at" the element w it moves to a smaller segment which is at least two times smaller than the previous one. So, every element will end up in 1-element length segment where recursion will meet it's base in O(log(n))"looking at" this element.
The overall complexity is O(n × log(n) + k).
G. Happy Line
Let's reformulate the condition in terms of a certain height the towers, which will be on the stairs. Then an appropriate amount of money of a person in the queue is equal to the height of the tower with the height of the step at which the tower stands. And the process of moving in the queue will be equivalent to raising a tower on the top step, and the one in whose place it came up — down. As shown in the illustrations. Then, it becomes apparent that to make all of the tower on the steps to be sorted, it is 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 are linear dependent so the matrix B can be written in the following way:

Suppose

Let's assume that elements of the first row of matrix A are coordinates of point a0 on two-dimensional plane and the elements of the second row are coordinates of point a1. Assume that the rows of matrix B are also coordinates of points b0 and b1. Let's note that in this case the line that is passing through points b0 and b1 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 is such matrix B that

In geometric interpretation it means that point b0 are inside the square which center is point a0 and length of side is 2·d0. In the same way the point b1 are inside the square which center is point a1 and length of side is 2·d0. So we need to check if there is a line that is passing through point (0, 0) and is crossing these squares. In order to do this we should consider every vertex of the first square, build the line that 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 2015 Editorial的更多相关文章
- Looksery Cup 2015 A. Face Detection 水题
A. Face Detection Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/549/pro ...
- Looksery Cup 2015 B. Looksery Party 暴力
B. Looksery Party Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/549/pro ...
- Looksery Cup 2015 D. Haar Features 暴力
D. Haar Features Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/549/prob ...
- Looksery Cup 2015 H. Degenerate Matrix 数学
H. Degenerate Matrix Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/549/ ...
- Looksery Cup 2015 F - Yura and Developers 单调栈+启发式合并
F - Yura and Developers 第一次知道单调栈搞出来的区间也能启发式合并... 你把它想想成一个树的形式, 可以发现确实可以启发式合并. #include<bits/stdc+ ...
- codeforces Looksery Cup 2015 H Degenerate Matrix
The determinant of a matrix 2 × 2 is defined as follows: A matrix is called degenerate if its determ ...
- Looksery Cup 2015 C. The Game Of Parity —— 博弈
题目链接:http://codeforces.com/problemset/problem/549/C C. The Game Of Parity time limit per test 1 seco ...
- codeforces Looksery Cup 2015 D. Haar Features
The first algorithm for detecting a face on the image working in realtime was developed by Paul Viol ...
- codeforces Looksery Cup 2015 H Degenerate Matrix 二分 注意浮点数陷阱
#include <cstdio> #include <cstring> #include <algorithm> #include <string> ...
随机推荐
- 继承—Monkey
public class Monkey { public void Monkey(String s){ } public void speak(){ System.out.println(" ...
- 为什么在input中加了display:inline;再加宽,还有作用?
以前一直一位input是个行内元素,但是,行内元素的特性就是没有宽高的概念,元素多高,多宽,全凭内容撑起来的. 但是今天写了个demo,用chrome控制台显示:display:inline-bloc ...
- MySql语句中select可以嵌套么,字段的重命名可以用中文么
今天文档中看到的查询语句,SELECT后面又跟了一个SELECT嵌套,而且把字段重命名为中文,请问可以这样做么 MySql语句中select可以嵌套么,字段的重命名可以用中文么 >> my ...
- vue中makeMap方法的使用 (定义注册一些值 后期方便使用)
function makeMap ( str, expectsLowerCase ) { var map = Object.create(null); var list = str.split(',' ...
- java uploadify 上传组件使用方法
!!!声明 1-3 是jsp页面所写内容 文中需要的util 参见百度云 http://pan.baidu.com/s/1kV0gqBt 如已失效 请加QQ1940978083 1.首先引入 ...
- 装了ubuntu后笔记本电脑的无线网卡用不了,怎么设置?
百度经验的一篇文章 http://jingyan.baidu.com/article/ca2d939dd4f1b4eb6c31ce09.html 点击右上角的齿轮,选择“系统设置” 点击“软件和更 ...
- Linux学习总结(9)——Linux 新手必知必会的 10 条 Linux 基本命令
Linux 对我们的生活产生了巨大的冲击.至少你的安卓手机使用的就是 Linux 核心.尽管如此,在第一次开始使用 Linux 时你还是会感到难以下手.因为在 Linux 中,通常需要使用终端命令来取 ...
- windows下laravel5安装
第一步:安装composer 网上教程非常多,自行百度 第二步:使用composer create-project laravel/laravel learnlaravel5 5.0.22 ...
- JVM调优系列:(四)GC垃圾回收
跟踪收集算法: 复制(copying): 将堆内分成两个同样空间,从根(ThreadLocal的对象.静态对象)開始訪问每个关联的活跃对象,将空间A的活跃对象所有拷贝到空间B,然后一次性回收整个空间A ...
- json数据转化成实体 存到数据库.
直接看步骤吧 1.一般我们会调用别人给的webservice获取一个字符串数据.如果为String data="xxxxxxxxxx"; 这个data事实上就是样例Enterpr ...