ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • 코드포스 난이도(*800 ~ 3500) 별 출제 유형
    아무거나적어~ 2021. 7. 29. 16:23

    codeforces crawling.zip
    2.18MB

     

    미리보기

    참고

    • 자료수집: https://codeforces.com/problemset?order=BY_RATING_DESC
    • 자료대상: 알고리즘 유형이 기제되어 있는 모든 문제
    • 자료수집시기: 21.07.29
    • 수집방법: python3 을 이용한 crawling
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    import requests
    from bs4 import BeautifulSoup
    from collections import defaultdict as dd
    import matplotlib.pyplot as plt
     
    db = dd(lambda: dd(int))
    cnt = dd(int)
     
    for page in range(171):
        print(page)
        url = f"https://codeforces.com/problemset/page/{page}?order=BY_RATING_DESC"
        response = requests.get(url)
        html = response.text
        soup = BeautifulSoup(html, "html.parser")
        table = soup.select("table.problems > tr")
     
        for problem_info in table[1:]:
            col = problem_info.select("td")
            difficulty = col[3].get_text().split()
            if difficulty:
                difficulty = int(difficulty[0])
            else: difficulty = 0
            if(len(col[1].select("a")[1:])):
                cnt[difficulty] += 1
                for e in col[1].select("a")[1:]:
                    db[difficulty][e.get_text()] += 1
     
    for diff in db.keys():
        d = {k: v for k, v in sorted(db[diff].items(), key=lambda item: item[1])}
        plt.rcParams.update({'font.size'5})
        plt.barh(range(len(d)), d.values(), align='center', color='orange')
        plt.yticks(range(len(d)), d.keys())
        plt.xlabel(f"*{diff}, total: {cnt[diff]}", fontsize=18)
        plt.ylabel(' ', fontsize=18)
     
        plt.savefig(f"{diff}.png", dpi=300)
       plt.cla()
    cs

     

    댓글

Designed by Tistory.