How ACM algorithm out of a problem?

This paper background

Algorithm abilities, but the race for the provincial and regional networks tournament game a few questions, summed up some of their own experience, I hope to share with you. This article does not deal with specific questions algorithm, are some theoretical ideas and suggestions.

Source title

If you can come up with a new title in the absence of the title source of their own situation, must also difficult to see the article. Problem source is the first step out of the question, I believe the topic to the point of need, and you're reading this blog must have a familiar topic brush site, and this site can be used as the source of your problem, because of the familiarity. I recommend two questions the source site:

English title Source website Codeforce

Chinese title source site 51nod

Get the problem source must ensure only able to write all solution, the subject may have three solutions to O (n ^ 2), O (nlog (n)), O (n), if any, of these three solution you will have to get, at least after reading other people's answers that they can complete a thorough understanding.

There is a question as part of a few, but as the topic and not only concern these parts:

  1. Topic name. According to the topic required, in either English or Chinese.
  2. Complexity requirements. Time and space complexity requirements, general time complexity is more important.
  3. Title Description. May also be referred title or caption intended surface, generally there will be described the case of a story; story may not, graphics or abstract mathematical procedure described problem.
  4. Input and output formats. Generally accounted input lines, output lines accounting, which describes the input data and the like.
  5. Input and output samples.
  6. Task presenting Notes. General explanation of the sample, or suggesting the topic of a special format. Notes portion may be omitted.
Note: You may read half went out of the question, so I intend to write precautions in advance here. That is: You must ensure a good topic topic name, title description, input, output, etc. in Baidu, Google and other popular browsers are not search by topic and source of the problem or similar problems.

Adapted meaning of problems

Meaning of the questions about adaptation, which is the subject description section, provide the following four strategies:

  1. Specific concrete . (Description of the object transfer) may be the subject of a specific person or something, some kind of operation, you can use this particular event or a particular person, transferred to a number of recent events, or your students more familiar things. For example: description of the object to your association or group as a teacher or a topic, so better more interesting topics.
  2. Specific abstraction . If you transfer too much trouble to describe the object, you may be entitled to some abstract abstract mathematical model, graphic arrangement, collision, mazes, etc., directly mathematical model to describe.
  3. Abstract abstraction . Also using the method described object of the transfer, you can be a mathematical model, the mathematical model to another scene.
  4. Abstract concrete . It is described in detail based on the original abstract. If the original is a water problem, you can adapt this question into English reading comprehension questions, do not forget to read the English part of the algorithm is the ACM contest, read the title of the topic is to do pre-conditions.

Input and output adaptation

  1. Increase precondition title input source , you can change the input source to another set of questions and enter the relevant input, to increase the difficulty of the subject. For example, the problem is sorted source input numbers, you can enter it into disorder.
  2. Preconditions reduction title input source , directly after the input data out of the processed original title, which is input as a new problem.
  3. For both cases also output , reduce the difficulty increases respectively, is omitted.
  4. Input and output format can also be adapted from an angle , after certain modifications may be made conditional output mode [A] (Input -> Output -> Input -> Output, recurring) pattern becomes [two] (Input -> Output, all data must be input or output time, or increase the storage means to increase the processing step). Of course, this operation is reversible.

The complexity of adaptation

  1. Modify the complexity of the requirements , the card out of the complexity of the O (nlogn) above solution, increase the difficulty of the subject. For example, the original requirements 2000ms, you can change it to 500ms or 1000ms, specific values depending on the particular circumstances, typically an integer multiple of 500ms.
  2. Modify the input and output requirements , increase or decrease the magnitude of the input and output of data, so the title more complex or simple.
  3. Modify the data size requirements , such as the original data 10 ^ 9, just as int. If you modify the data size is 10 ^ 18, it can only be saved with long long type, you may get stuck out some solution; if you modify the data size is 10 ^ 5, may be more than some practices, such as using hash table, and then the prefix and suffix processing, and the like.
  4. Modify the data type requirements . The original input int, you will change it to double or float, may add some difficulty, on the contrary reduce the difficulty.

The above is modified for the title, we must ensure that the search engines can not search to change a good topic.

How to generate sample

Generates input data

Generally, we need a sample of about 20 groups, saved in a file

  1. First, there must be some of the boundaries input, you need to add their own, such as border situations, special circumstances.
  2. When you add a relatively small amount of data input boundary, there may be some large amount of data can not be input manually add boundary, you can write a code, add borders limit the amount of data input.
  3. The remaining can write a code that allows python randomly generated sample different orders. For example, you amount of data size is 10 ^ 6, you can generate a plurality of data volumes 100, 1000 data amount, data amount 10 000, 100 000 the amount of data, the amount of input data 1,000,000.

Generate output data

20 sets of input samples generated in your standard program, the output in a file, save it as a sample output. Here we must ensure the correctness of your standard process, as well as the legitimacy of input and output (in line with the topic description).

You will need to generate a good input and output in groups to come up with a topic description, of course, you can come up with specific data, so that participants AC; you can come up with only routine data, so that those who do question has been WA. Good examples named specification generated, as shown below:

This image reproduced from my CSDN blog:

+ OJ write standard process server actually running

After doing this several of the above, a topic that basically finished, then you need these data and samples run on your server OJ ensure that time and space are in line with requirements. In the test, you need the solution you envision some complexity can all run on the server again to ensure solution viability topic.

to sum up

My senior year to the provincial tournament out of a problem, is not difficult, but a lot of data processing jammed team.

I think it will let some advanced operations, data processing more familiar, or more familiar with optimization of time complexity of the problem, there is discrimination in question is a good question.

Those who only need jammed violent solution team.

I share the experience ended, for the time being only remember so much, the back may also be updated.

I hope you can read this blog out yourself out of a subject and satisfy everyone.

Guess you like

Origin www.cnblogs.com/zhangjiuding/p/11334926.html