GDOI2018 Travel Notes

About Me

lhy, the first-year konjac contestant and the GDOI2018 soy sauce contestant.

Day 0

I arrived at the school early at 12:00 noon and organized my blog in the computer room. Get on the bus at more than one o'clock and head to Zhongshan No. 1 Middle School (sit in front of the yhf boss).

GDOI had suspended classes for two weeks before training, got to know some big guys, learned some metaphysical algorithms, and immediately went to GDOI after being abused by various big guys. I was ready to write eight questions and not get into soi. , because I feel really  weak .

Well, in fact, I'm still a bit lucky in my heart, maybe I can score 200 points or something this time, hehe.

After a bumpy ride, we finally arrived at the hotel. This time, lhl quickly allocated the room, which was very fast. Me and fmj are split together. The hotel room is big and very nice. …

At around 5:00 pm, our group went to Zhongshan No. 1 Middle School for dinner. After some careful comparison, I still feel that the food in Guangzhou No. 2 Middle School is better, um...

After eating, go to the exam room with the big guys to step on the spot. ywq and I found it without much effort, but the team led by yhf searched for about 20 minutes because of "some problems with the traversal order of the search" (in fact, they could find it by turning left after going up to the second floor, but they didn't searched the whole building) .

Watching TV at the hotel late at night (too much sleep the night before) .

Before I knew it, the day passed.

Day 1

At around 6:20 in the morning, I went downstairs to have breakfast after a simple grooming.

The breakfast in this hotel is really good, there are fried bacon, fried sausages, etc., or a buffet. After eating and playing this "extremely greasy" breakfast with lah, czy, fmj and others, we set off for No. 1 Middle School.

The start time of the exam was postponed from 8:00 to 8:30, but it didn't affect me much. Soon, the invigilator said the unzip password: tiandihe_naiganyujunjue!66. Sorry for my bad language. Immediately afterwards, I opened the test question...

T1: Farm

The main idea of ​​the title: Given a number of numbers, find out how many consecutive segments these numbers can be divided into evenly at most. The number of numbers <= 1000000, 1 <= each number <= 10, and the sum of all numbers <= 1000000.

Sign in question? It seems to enumerate the answers. First prefix and sum it up once, then O(n) segmentation to see if it can be divided into several equal segments, enumerate from large to small, and output as soon as the conditions are met. At first glance, it seems to be an O(n^2) algorithm, but if you think about it carefully, you can actually judge whether the sum of all numbers mod the current number of segments enumerated is zero before segmentation, and if it is not zero, it is certain If you can't score, skip it, or start scoring. This reduces the time complexity to O(sqrt(n)*n), plus some metaphysical optimizations, but still TLE. Then I thought about whether binary search can be used in segmentation, but I got my brain pumped and I miscalculated the time complexity, thinking that it would be slower than pure violence, but it is actually O(nlogn). So I didn't add the dichotomy and just used some weird optimizations. Got this problem in about an hour.

T2: Combination lock

The main idea of ​​the title: Given n numbers not greater than m, each operation can add or subtract one to the numbers in a continuous interval at the same time. If a number is less than 0 after one operation, make it equal to m-1; otherwise , if a number equals m after one operation, let it equal 0. The minimum number of operations required to make all numbers equal to 0. I can't remember the data range clearly, both n and m seem to be at the 10^5 level or 10^6 level.

Seeing this question, first of all conditioned reflex, I thought of the interval dp, pushed it for a while, and pushed it up. After thinking about it for a while, I didn't think of a good way, so I decided to skip watching T3.

T3: Taotao picks apples

The gist of the title: There is a rooted tree, and each node has a weight. Every unit time, the weight of the root node will be cleared, and then the weight of all nodes will be transferred to its parent node. For example this tree:

(The number on the node represents the weight of this node)

After one unit of time, it will look like this: 

There are several instructions that follow, which can be divided into two categories:

1. At the t-th unit time, add w to the weight of a node.

2. Ask what is the sum of the weights of a node and all its child nodes at the t-th unit time.

For each query, output a value representing the answer.

The number of nodes and instructions seem to be at the 10^6 level (the data range can't be remembered).

In this question, 50% of the data points have special properties, for example, 10% of the data tree is degenerated into a chain, and some points are only query instructions, etc., and 10% of small data. At the time, I was thinking about "programming for data" and doing it for each special case, so I started it right away. I finished the 10% brute force first, processed each instruction in O(n), passed the example easily, and then turned to the case where the number is a chain. For the case where the tree is a chain, my idea is to use a queue to simulate it. After playing, I found that it is not much faster than violence, huh, huh. To be on the safe side, I deleted this special case. It took me about two hours. In fact, I thought of a little idea of ​​only asking for the data of the command, but since time was really short, I didn't think about it any more, and just got the violence score.

Looking back at T2, I still didn't think of a good solution, so I directly hit the explosion search of n=4, and the special situation when m=2. Obviously, the answer when m=2 is how many consecutive 1s in the n numbers. Because the data range does not seem to clearly indicate that there is a case of m=2, I am not sure whether it can be divided into more points. After more than 30 minutes of writing (I haven't written a search for a long time, I have written this question several times), and rushed to T4.

T4: Graph Thesis for Primary School Students

The gist of the title: There is a directed graph with n points, and every two points are connected by exactly one edge. Now that m simple paths are known, find the expected number of strongly connected components in the graph, and then it is very strange to choose one mod. I completely forgot about the data range, it seems to be relatively large...

"XX Students XX Questions" series & unacceptable expectation questions. At first I thought about m=0, but it didn't help. Just output the number and leave.

 

Expected score: 80+20+10+0=110

 

At noon, I went to No. 1 Middle School for lunch, and chatted and laughed with lah on the way back to the hotel. Watched TV at the hotel.

 

Afternoon commentary:

T1: The prefix sum + enumerates the divisor of the sum of all numbers. If the double, double, triple, etc. of this divisor all appear in the prefix sum, then obviously this solution is feasible. Time complexity ≈ O(n).

T2: Differential + greedy messing around, seems to understand but not understand. It is worth mentioning that the questioner gave 10 points of m=2 data, um, not bad...

T3: Strange data structure, don't understand.

T4: It's still an expectation question that I don't understand.

After 40 minutes of speaking, the transcript was sent out immediately (the printer was good this time).

With anticipation, I saw the report card, and my heart suddenly became cold. Actual score: 50+15+10+0=75.

T1 doesn't know why WA got 5 points and only got 50 points. It may be that there is a loophole in a metaphysics optimization I wrote. I only got a 5 out of 20 on T2 for violence, probably because I wrote dfs directly, not bfs or memoized search. At that time, I naively thought that such a small data dfs would definitely be able to pass the water (actually, I wrote about the memorandum, but it failed, which made me mistakenly think that this question could not be used for memorization, so I directly wrote the blast search, huh), As a result, I lost 15 points in vain, but fortunately, 10 points of m=2 data were made up. T3 is expected. T4 really broke zero.

lah also exploded, he T1WA scored 8 points and only scored 20 points for a total of 50 points. The lah, who has always been a big guy, actually exploded, which I didn't expect.

fmj90 points, big guy.

czy85 points, big guy.

A few 100+ in the second and third grades, big guy.

Lah and I went to the retest gloomily, and czy also went with us because of a metaphysical error in the last two points of T1. At this time, I still had the last bit of luck in my heart, maybe the evaluation machine suddenly crashed or something.

After an hour or two of waiting on a sweltering afternoon, it was finally our turn. After retesting, I found that his T1 IF was blown up, and he didn't say anything. I still got the same score after the retest. A certain optimization in T1 may have been wrongly written, and the 20-point data of T2 can’t be reached by explosive search (lah, I’ve used memoization to search for water, big guy). After czy retested, it was found that the array was too small...

Anyway, it's a pity. But I'm not in a bad mood. After all, I'm still in the first year of junior high school, and I haven't even participated in the NOIp improvement group. This time I just came to see the world. Come on, Day 2!

Back to the hotel in the evening, still went to bed very late.

Day 2

 I got up at six o'clock in the morning and went to the dining hall downstairs to eat an "extremely greasy" breakfast. The difference is that the buffet has been changed to a perimeter meal, but the same dishes are still eaten. Yesterday, I calculated the score. Today, I need at least 160 points to be able to enter day 3. I feel a little overwhelmed.

After eating breakfast, I walked to No. 1 Middle School and entered the computer room. This time the start of the game was only delayed by 10 minutes, happy.

Soon, the decompression password was announced: easy?GDKOI2019_jian!. It seems that yesterday's topic was not lightly sprayed by the big guys.

T1: Chatting and laughing

The gist of the title: Given an undirected graph, each point has a value Wi. For two points, determine whether each number in 1 and 1..Wj is relatively prime, determine whether each number in 2 and 1..Wj is relatively prime, and determine whether each number in 3 and 1..Wj is relatively prime Coprime... Finally, determine whether each number in Wi and 1..Wj is coprime. If they are coprime, the edge weights of the edges between them are added to the sum of this logarithm. Now the edge weight of each edge can be reduced by a value K, and the minimum value of K can be obtained from node 1 to node n under the condition that the total distance traveled does not exceed T, and the output is in the case where K is the smallest the length of the shortest path from node 1 to node n. Wi<=10^9, n,m<=10^5 or 10^6 (can't remember exactly).

Isn't this question the bare shortest path + two-point answer after finding the edge weight? At that time, the thinking was too rigid, and I didn't expect to use gcd to judge mutual prime, so I just decided to decompose the prime factor to look forward to it! I want to slap myself. result

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325050623&siteId=291194637