Codeforces Round #290 (Div. 2)

评测之前

[remind]总结:看到Div1的A题我就吓尿了、然后换小号做了Div2、最后1秒交了Div2的D题,然后Present Pass,我也是醉了,果然我太弱了、、然后没有了、、、[/remind]

好吧,那么让我们来分析题目>_<

[task]

A. Fox And Snake
Fox Ciel starts to learn programming. The first task is drawing a fox! However, that turns out to be too hard for a beginner, so she decides to draw a snake instead.
A snake is a pattern on a n by m table. Denote c-th cell of r-th row as (r, c). The tail of the snake is located at (1, 1), then it’s body extends to (1, m), then goes down 2 rows to (3, m), then goes left to (3, 1) and so on.
Your task is to draw this snake for Fox Ciel: the empty cells should be represented as dot characters (‘.‘) and the snake cells should be filled with number signs (‘#‘).
Consider sample tests in order to understand the snake pattern.
Input

The only line contains two integers: n and m (3 ≤ n, m ≤ 50).
n is an odd number.

Output

Output n lines. Each line should contain a string consisting of m characters. Do not output spaces.

Sample test(s)
input

output

input

output

input

output

input

output

[/task]
题目大意大概就是、、、卧槽、好吧、模拟、、看数据就能知道辣!

[remind]

B. Fox And Two Dots
Fox Ciel is playing a mobile puzzle game called “Two Dots”. The basic levels are played on a board of size n × m cells, like this:
Each cell contains a dot that has some color. We will use different uppercase Latin characters to express different colors.
The key of this game is to find a cycle that contain dots of same color. Consider 4 blue dots on the picture forming a circle as an example. Formally, we call a sequence of dots d1, d2, …, dk a cycle if and only if it meets the following condition:

  1. These k dots are different: if i ≠ j then di is different from dj.
  2. k is at least 4.
  3. All dots belong to the same color.
  4. For all 1 ≤ i ≤ k - 1: di and di + 1 are adjacent. Also, dk and d1 should also be adjacent. Cells x and y are called adjacent if they share an edge.

Determine if there exists a cycle on the field.

Input

The first line contains two integers n and m (2 ≤ n, m ≤ 50): the number of rows and columns of the board.
Then n lines follow, each line contains a string consisting of m characters, expressing colors of dots in each line. Each character is an uppercase Latin letter.

Output

Output “Yes” if there exists a cycle, and “No” otherwise.

Sample test(s)
input

output

input

output

input

output

input

output

input

output

Note

In first sample test all ‘A‘ form a cycle.
In second sample there is no such cycle.
The third sample is displayed on the picture above (‘Y‘ = Yellow, ‘B‘ = Blue, ‘R‘ = Red).

[/remind]
题目大意就是我们要查找是否有长度大于4的环

[remind]

C. Fox And Names
Fox Ciel is going to publish a paper on FOCS (Foxes Operated Computer Systems, pronounce: “Fox”). She heard a rumor: the authors list on the paper is always sorted in the lexicographical order.
After checking some examples, she found out that sometimes it wasn’t true. On some papers authors’ names weren’t sorted inlexicographical order in normal sense. But it was always true that after some modification of the order of letters in alphabet, the order of authors becomes lexicographical!
She wants to know, if there exists an order of letters in Latin alphabet such that the names on the paper she is submitting are following in the lexicographical order. If so, you should find out any such order.
Lexicographical order is defined in following way. When we compare s and t, first we find the leftmost position with differing characters:si ≠ ti. If there is no such position (i. e. s is a prefix of t or vice versa) the shortest string is less. Otherwise, we compare characters siand ti according to their order in alphabet.
Input

The first line contains an integer n (1 ≤ n ≤ 100): number of names.
Each of the following n lines contain one string namei (1 ≤ |namei| ≤ 100), the i-th name. Each name contains only lowercase Latin letters. All names are different.

Output

If there exists such order of letters that the given names are sorted lexicographically, output any such order as a permutation of characters ‘a’–’z’ (i. e. first output the first letter of the modified alphabet, then the second, and so on).
Otherwise output a single word “Impossible” (without quotes).

Sample test(s)
input

output

input

output

input

output

input

output

[/remind]
题目大意就是我们有一系列假装已经排好序的字符串!我们要更改abcdedfhigklmnopqrstuvwxyz的大小顺序,来使这些字符串成字典序。
我当时感觉就是小的到大的连边,然后做一遍SPFA,然后按照点的权值输出就好!不知道会不会fst、、、

[remind]

D. Fox And Jumping
Fox Ciel is playing a game. In this game there is an infinite long tape with cells indexed by integers (positive, negative and zero). At the beginning she is standing at the cell 0.
There are also n cards, each card has 2 attributes: length li and cost ci. If she pays ci dollars then she can apply i-th card. After applying i-th card she becomes able to make jumps of length li, i. e. from cell x to cell (x - li) or cell (x + li).
She wants to be able to jump to any cell on the tape (possibly, visiting some intermediate cells). For achieving this goal, she wants to buy some cards, paying as little money as possible.
If this is possible, calculate the minimal cost.
Input

The first line contains an integer n (1 ≤ n ≤ 300), number of cards.
The second line contains n numbers li (1 ≤ li ≤ 109), the jump lengths of cards.
The third line contains n numbers ci (1 ≤ ci ≤ 105), the costs of cards.

Output

If it is impossible to buy some cards and become able to jump to any cell, output -1. Otherwise output the minimal cost of buying such set of cards.

Sample test(s)
input

output

input

output

input

output

input

output

Note

In first sample test, buying one card is not enough: for example, if you buy a card with length 100, you can’t jump to any cell whose index is not a multiple of 100. The best way is to buy first and second card, that will make you be able to jump to any cell.
In the second sample test, even if you buy all cards, you can’t jump to any cell whose index is not a multiple of 10, so you should output -1.

[/remind]
题目大意:有n个数字,每个数字有花费,我们要花最少的钱,是选择的数字的总GCD为1.
Orz一开始被忽悠过去做E、、【他们说E简单、、】然后最后十几分钟赶快写了一个纯暴力DP的D、【最后一秒钟提交Present Pass我也是醉、、、】总之很惊险,可能会T掉、【因为太暴力了】祝好运!

[remind]E题没做(-。-;)、、[/remind]

评测之后

A题Accept
B题Accept
C题Accept
D题FST、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、世界再见、
好吧,昨天一躺下来就知道D哪里错了、、有一个更新的时候忘记判断了、、毕竟是15分钟码完然后最后1秒教的程序、、、、的确坑、、改了一下果然A掉了、QAQ、、SB错毁一生、