[PYTHON] Atcoder until green

Self-introduction

Hi, this is HIROSHI0635. I'm in my second year working in finance (Orz ... I don't program at all at work). When I was in college, I was a liberal arts student, and I had never touched the program "Pu", but I managed to get green in 10 months after I started competing professionals, so I wanted to try the "~ color" article. I wrote. It's a self-sufficient article, but it may be a little useful for a Python coder who is new to Atcoder. スクリーンショット 2020-02-23 15.22.15.png

1. Until you start Atcoder

The motivation for starting was when I was wondering if I should really quit because of the cramped relationships at work, then I thought that it would be nice to have a job where I could compete with my technical skills, so I started programming with the idea that I can still do it. I arrived. However, I didn't know the programming "p" and I didn't have anything I wanted to make, so when I was wondering what to do, my senior at university recommended Atcoder. I was pretty good at studying for entrance exams (although center mathematics is at a level of about 80 points for both IA and IIB), so I thought that solving problems and raising or lowering the rate was a study method that suits me. ..

2. Frustration

I didn't know anything about the first language, so I chose C ++, which is the most major language in Atcoder, as recommended. However, the grammar was complicated, and there were many rules such as so-called "magic", so I couldn't solve the problem easily. In addition, I was transferred to another department and my relationships improved, and I was less motivated than before. Since then, I have been doing nothing for about half a year.

3. Until the resurrection

When I happened to meet an engineer customer at work and was frustrated with competitive programming in C ++, he said, "Then, why don't you try it again in Python? There are few magics and I think it's easy to do. I didn't have enough energy to go cycling as a hobby every week, so I was free, so I restarted again. This time, I went through a Python course at Paiza so that I wouldn't be frustrated by grammar, and then I started to solve the problem. However, if you write a huge program, you may need to do classes and instances, but with Atcoder it is enough to do functions, so I think it is better to solve the problem. If you're frustrated with C ++, think you've been fooled and try again with Python.

4. Up to brown

スクリーンショット 2020-02-23 18.19.40.png

It seemed to be a pain to build the environment, and it was foolish to be frustrated, so I wrote the code in paiza's online environment until just before it turned green https://paiza.io/ja Until it turned brown, I just filled in the B problem. It took a long time at first, but once I got used to it, the solution seemed to float in almost no time, and then I just implemented it. I filled up about 50 questions in one month and just wrote them. Next, I heard a rumor that "Ant book is good", and I bought it now, so AtCoder version! Ant book (beginner) has begun to be filled. I could understand the whole search and greed, but I was completely clogged with DFS and BFS, so I gave up and started to fill in the C problem, and while doing so, it turned brown.

5. Up to green

スクリーンショット 2020-02-23 19.33.42.png

I thought it would be easy to go from brown to green, but I struggled unexpectedly (actually, in the final contest to go brown, I thought it was a matter of time, with a performance of over 1000). Because, from around 2019/10, the level of the surroundings has clearly risen, and the performance has fallen by about 150 from before. In addition, sometimes I took time for a simple problem and sometimes gave a performance of about 400, which caused the rate to stall. So, I thought about "attack power" to solve difficult problems, "defensive power" to solve simple problems quickly, and it is difficult to increase attack power, so first raise defensive power. I tried. Also, as a recent problem tendency, the C problem has become easier, and the brown Difficulty (Difficulty 400-800 problem in Atcoder Problem) is skipped, and the green / light blue Difficulty problem often appears suddenly. (From ABC140 to ABC156, brown Difficulty has 5 questions, green Difficulty has 11 questions, and light blue Difficulty has 13 questions). There are many sets that do not have the brown problem, and if you are not at a level where you can solve the green problem, speeding up the gray problem is the fastest way to green. The only way to improve your defense is to devote yourself a lot, but here are some things I've done elsewhere.

Introducing a local environment

I've been indebted to Paiza's online environment for a long time, but I've never decided to build a local environment. At the same time, we introduced the Atcoder unit test https://qiita.com/YujiSoftware/items/00ce688ce5dde627ec36, which greatly improved the operation check of problems A and B. After all, the local environment has merits such as predictive input, templates, and finding bugs, so I think it is better to move to the local environment as soon as possible (I haven't mastered it at all yet). By the way, I use Pycharm.

See sample 1 quickly without loading the problem

Up to the C problem, even if you do not understand the problem sentence, it is often faster to scan the problem sentence and look at the sample to get an overall picture of the problem. After D, if you don't read the constraints carefully, you will often get caught, so you should read them carefully.

Utilization of virtual contest

As the intervals between contests increase, speed and motivation decrease, so I regularly held virtual contests with my colleagues to improve speed and maintain motivation.

Even if I failed, I managed to keep participating in the contest and was able to turn green.

6. Other useful tips for Python warriors

Collection.Counter, most_common () method

This library is really versatile. How to use this article. https://note.nkmk.me/python-collections-counter/ About once every five times, if you know this, you will have a problem that you can kill instantly.

The magic that makes the input a little faster

import sys  input = sys.stdin.readline

Just add these two lines at the very beginning and the speed will increase by about 10%. I'm not sure why. This article is easy to understand about small speed improvements. https://www.kumilog.net/entry/python-speed-comp

7. At the end

This time, the main trend was to start playing half-competition pros, but once I get to light blue, I'd like to write a cohesive article that will help me solve the problem a little more.

Recommended Posts

Atcoder until green
[Python] I'm a green coder ~ [AtCoder]
atCoder 173 Python
AtCoder ABC176
Challenge AtCoder
Until it turns light blue with AtCoder
AtCoder 174 BCD
AtCoder Green tried to solve with Go
AtCoder ABC177
[Fenwick_Tree] AtCoder Library-Reading with Green Coder-Implementation in Python-