[At Coder] What I did to reach the green rank in Python

qiita.png

He has just recently reached the green rank in AtCoder.

This time, I have summarized what I have done personally and what I am paying attention to.

To reach the green rank

I think the following is necessary to reach the green rank.

--Solve the C problem within 15 minutes (** 3 complete 15 minutes ) --D Solve the problem within the time limit ( 4 Complete 100 minutes **)

Ultimately, I think it's possible to go to the green rank even if you can't solve the D problem (although it may take some time).

For reference, the table below summarizes the results of the contests I recently participated in virtually.

Contest name result Rating *
ABC127 3 complete 921
ABC128 3 complete 1148
ABC129 3 complete 1005
ABC130 4 complete 1309
ABC131 3 complete 524
ABC132 4 complete 1257
ABC133 4 complete 1115
ABC134 4 complete 1113
ABC135 3 complete 1175
ABC136 4 complete 1131
ABC137 4 complete 1451
ABC138 4 complete 1007

Looking at the table above, there are ** 3 times when the rate is 1148 or 1175.

ABC131 is an example where the D problem was easy, but it stopped at 3 completion. .. ..

Therefore, I personally think as follows.

Solve the C problem in 15 minutes each time, and solve the D problem once every three times! </ font>

If it takes more than 15 minutes to solve the C problem, I will definitely solve the D problem! I feel like.

The following is a summary of what you should be careful about when solving problems A to D.

Problem A / Problem B

Most of the problems A and B can be solved if you know the basic grammar.

I don't think there was any particular problem of worrying about the amount of calculation, so let's simply solve it using a for statement or an if statement.

Also, let's be able to perform basic list processing.

test.py


l =[]
l.append(1)  #Add to list
a = l.pop()  #Take out the end of the list
l = [i for i in range(N)]  #Comprehension notation
max_l = max(l)  #Get the maximum value in the list
min_l = min(l)  #Get the minimum value of the list

And in the B problem, there is sometimes a problem such as "normal processing is performed when N> 1, but exception handling is performed when N = 0" (or rather, such a bug has occurred in the program I wrote. (Sometimes), so

test.py


import sys
if N == 0:
   #Special treatment
   sys.exit()
for i in range(N):
   #Normal processing

I sometimes write something like this.

C problem

C has some difficult problems, and the amount of calculation must be taken into consideration.

Point1: See the size of the input data (consider the amount of calculation)

Example 1: ABC133 C problem

In this problem, the input size is 2 * 10 ^ 9. This is a size that makes it TLE even in a single loop, so I have to think that a simple for statement cannot be used.

However, if you think about it positively, it is a hint because there is a way to surely reduce the amount of calculation.

Example 2: ARC061 C problem

In this problem, on the contrary, the input data is a character string of 10 characters or less. For problems with extremely small input data, ** full search ** is often used.

--If N <= 10, you can use bit full search and n! Street full search. --If 100 <N <200, you can use up to triple loop

I can expect something like that. It's just an expectation.

Point2: Write down useful libraries etc. in a memo

The C problem imports various Python libraries and modules.

Also, prepare frequently used functions in advance.

I will summarize the libraries, modules, and functions that I personally use for C problems.

--itertools (combination, permutation, full search of N! Streets) --math (least common multiple, greatest common divisor, etc.) --Enumeration of divisors (version obtained by O (√N)) --bit full search (valid only when N is small) --deque (list that can append and pop from the left and right edges) --heapq (priority queue) --collections (the one who counts the frequency of appearance) --bisect (binary search)

Please comment if there are others!

To put it the other way around, most problems can be solved without using difficult algorithms such as ** dynamic programming, Dijkstra's algorithm, DFS and BFS. ** **

D problem

Problem D is not stable because I can only solve it about 7 times if I have 10 contests, and sometimes I can solve it within 30 minutes and sometimes it is just 100 minutes.

Personally, I wondered if it would be stable if I could solve the problems listed in @ drken's this article without struggling. I will.

Therefore, the algorithm template written here is coded in advance, and it seems to be nice to add or modify the program depending on the problem.

E problem / F problem

If it's a green coder, you don't have to solve it. I have to study because I have to be able to solve the E problem to become light blue.

Finally

There are many personal opinions, but I hope it will be helpful.

Recommended Posts

[At Coder] What I did to reach the green rank in Python
What I did to save Python memory
[Python] What I did to do Unit Test
What I did when updating from Python 2.6 to 2.7
I want to display the progress in Python!
What I did when I got stuck in the time limit with lambda python
I tried to graph the packages installed in Python
I want to write in Python! (3) Utilize the mock
What I did to ssh to the VPS Ubuntu environment
I want to use the R dataset in python
What I learned in Python
What I did when I was angry to put it in with the enable-shared option
What I did to speed up the string search task
I tried to implement the mail sending function in Python
I tried to summarize what python strong people are doing in the competition professional neighborhood
Ventilation is important. What I did to keep track of the C02 concentration in the room
In the python command python points to python3.8
I wrote the queue in Python
I wrote the stack in Python
[At Coder] What I did to reach the green rank in Python
What I thought and learned to study for 100 days at a programming school
What I did to ssh to the VPS Ubuntu environment
What I was addicted to with json.dumps in Python base64 encoding
What I did when I wanted to make Python faster -Numba edition-
Solve the smallest value in Python (equivalent to paiza rank D)
What to do when the value type is ambiguous in Python?
I tried to implement PLSA in Python
I tried to implement permutation in Python
I tried to implement PLSA in Python 2
What is "mahjong" in the Python library? ??
I tried to implement ADALINE in Python
I wanted to solve ABC159 in Python
I tried to implement PPO in Python
What I did with a Python array
What skills do I need to program with the FBX SDK Python?
[Python] I tried to summarize the set type (set) in an easy-to-understand manner.
What I did to keep track of the humidity and temperature of the archive
I want to explain the abstract class (ABCmeta) of Python in detail.
The file name was bad in Python and I was addicted to import
I made a program to check the size of a file in Python
After all, what should I use to do type comparisons in Python?
What is the fastest way to create a reverse dictionary in python?
How to use the C library in Python
I want to do Dunnett's test in Python
[Python] I want to know the variables in the function when an error occurs!
I want to use Python in the environment of pyenv + pipenv on Windows 10
I stumbled on the character code when converting CSV to JSON in Python
I was able to recurse in Python: lambda
I want to create a window in Python
What is wheezy in the Docker Python image?
I tried simulating the "birthday paradox" in Python
I tried the least squares method in Python
To dynamically replace the next method in python
I wrote "Introduction to Effect Verification" in Python
Draw graphs in Julia ... Leave the graphs to Python
I want to merge nested dicts in Python
[Python x AWS x Serverless] What I left behind at the PyCon JP 2020 stage
The trick to write flatten concisely in python
I tried to implement TOPIC MODEL in Python
How to get the files in the [Python] folder
I searched for the skills needed to become a web engineer in Python
I implemented the inverse gamma function in python
[Question] What happens when I use% in python?