예제 #1
0
         ['466', 'A'], ['313', 'A'], ['459', 'A'], ['230', 'A'], ['476', 'A'],
         ['490', 'A'], ['439', 'A'], ['510', 'A'], ['25', 'A'], ['432', 'A'],
         ['330', 'A'], ['441', 'A'], ['462', 'A'], ['385', 'A'], ['276', 'A'],
         ['456', 'A'], ['151', 'A'], ['378', 'A'], ['496', 'A'], ['255', 'A'],
         ['483', 'A'], ['404', 'A'], ['233', 'A'], ['499', 'A'], ['165', 'A'],
         ['262', 'A'], ['501', 'A'], ['189', 'A'], ['350', 'A'], ['152', 'A'],
         ['265', 'A'], ['353', 'A'], ['114', 'A'], ['300', 'A'], ['389', 'A'],
         ['488', 'A'], ['224', 'A'], ['445', 'A'], ['43', 'A'], ['75', 'A'],
         ['296', 'A'], ['373', 'A'], ['361', 'A'], ['355', 'A'], ['239', 'A'],
         ['437', 'A'], ['363', 'A'], ['408', 'A'], ['376', 'A'], ['359', 'A'],
         ['302', 'A'], ['358', 'A'], ['34', 'A'], ['143', 'A'], ['186', 'A'],
         ['108', 'A'], ['416', 'A'], ['194', 'A'], ['106', 'A'], ['257', 'A'],
         ['298', 'A'], ['279', 'A'], ['27', 'A'], ['370', 'A'], ['49', 'A'],
         ['284', 'A'], ['192', 'A'], ['56', 'A'], ['234', 'A'], ['31', 'A'],
         ['305', 'A'], ['197', 'A'], ['35', 'A'], ['88', 'A'], ['18', 'A'],
         ['374', 'A'], ['393', 'A'], ['390', 'A'], ['397', 'A'], ['200', 'A']]

parser = codeforces_api.CodeforcesApi()
probss = parser.problemset_problems()
probs = probss['result']['problems']

div_B = []
count = 1
for step in div_b:
    for prob in probs:
        if int(step[0]) == prob['contestId'] and step[1] == prob['index']:
            div_B.append([count, prob['name'], step[0], step[1]])
            count += 1
for x in div_B:
    print(x)
예제 #2
0
"""
Testing module work.
"""

import codeforces_api
import conf

MAIN = codeforces_api.CodeforcesApi(conf.API_KEY, conf.API_SECRET)

PARSER = codeforces_api.CodeforcesParser()

COMMENTS = MAIN.blog_entry_comments(74185)
VIEW = MAIN.blog_entry_view(74185)
HACKS = MAIN.contest_hacks(1311)
LIST = MAIN.contest_list()
RATING_CHANGES = MAIN.contest_rating_changes(1311)
STANDINGS = MAIN.contest_standings(1311, handles=["tourist", "VadVergasov"])
STATUS = MAIN.contest_status(1311)
PROBLEMS = MAIN.problemset_problems()
RECENT_STATUS = MAIN.problemset_recent_status(10)
RECENT_ACTIONS = MAIN.recent_actions()
USER_ENTRIES = MAIN.user_blog_entries("VadVergasov")
FRIENDS = MAIN.user_friends(True)
INFO = MAIN.user_info(["tourist", "VadVergasov"])
RATINGS = MAIN.user_rated_list(True)
USER_RATING = MAIN.user_rating("VadVergasov")
USER_STATUS = MAIN.user_status("VadVergasov")

SOLUTION = PARSER.get_solution(1322, 72628149)
예제 #3
0
from collections import defaultdict
import operator
import requests
import string
import bs4 as bs
import codeforces_api

from flask import Flask, render_template

app = Flask(__name__)
cf = codeforces_api.CodeforcesApi()


@app.route('/')
def index():
    username = '******'
    contests = list(x for x in cf.contest_list() if x.phase == 'FINISHED')
    contests.sort(key=lambda x: x.start_time_seconds, reverse=True)
    # contests = [1, 2, 3]
    url = 'https://codeforces.com/contest/'
    user_submissions = cf.user_status(username)
    # grab all the user submissions, loop through them and store them as a map
    u_d = dict()

    for sub in user_submissions:
        p_type = sub.author.participant_type
        key = str(sub.contest_id) + sub.problem.index
        if key not in u_d:
            if sub.verdict == 'OK' and p_type == 'CONTESTANT':
                u_d[key] = 'SC'
            elif sub.verdict == 'OK':
예제 #4
0
파일: views.py 프로젝트: subodhk01/a2oj
def home(request):
    try:
        handle = request.GET['handle']
        div = request.GET['div']
        rating = request.GET['rating']
        #print(div)
    except:
        return render(request, 'index.html')
    parser = codeforces_api.CodeforcesApi()
    try:
        submissions = parser.user_status(handle=handle)
    except:
        return render(request, 'index.html' , {'msg': 'Invalid Codeforces handle '})
    ladder = []
    division = []
    div = int(div)
    rating = int(rating)
    div_head = ""
    if div==1:
        division = div_a
        div_head = "DIV 2.A"
    elif div==2:
        division = div_b
        div_head = "DIV 2.B"
    elif div==3:
        division = div_c
        div_head = "DIV 2.C"
    elif div==4:
        division = div_d
        div_head = "DIV 2.D"
    elif div==5:
        division = div_e
        div_head = "DIV 2.E"
    elif div==6:
        division = div_1d
        div_head = "DIV 1.D"
    elif div==7:
        division = div_1e
        div_head = "DIV 1.E"
    elif rating==1:
        division = rating_1
        div_head = "Codeforces Rating < 1300"
    elif rating==2:
        division = rating_2
        div_head = "1300 <= Codeforces Rating <= 1399"
    elif rating==3:
        division = rating_3
        div_head = "1400 <= Codeforces Rating <= 1499"
    elif rating==4:
        division = rating_4
        div_head = "1500 <= Codeforces Rating <= 1599"
    elif rating==5:
        division = rating_5
        div_head = "1600 <= Codeforces Rating <= 1699"
    elif rating==6:
        division = rating_6
        div_head = "1700 <= Codeforces Rating <= 1799"
    elif rating==7:
        division = rating_7
        div_head = "1800 <= Codeforces Rating <= 1899"
    elif rating==8:
        division = rating_8
        div_head = "1900 <= Codeforces Rating <= 1999"
    elif rating==9:
        division = rating_9
        div_head = "2000 <= Codeforces Rating <= 2099"
    elif rating==10:
        division = rating_10
        div_head = "2100 <= Codeforces Rating <= 2199"
    elif rating==11:
        division = rating_11
        div_head = "Codeforces Rating >= 2200"
    else:
        return render(request, 'index.html' , {'msg': 'Invalid Division selected '})
    solved = 0
    for step in division:
        for sub in submissions['result']:
            try:
                if int(step[2])==sub['problem']['contestId'] and step[3]==sub['problem']['index'] and sub['verdict']=="OK":
                    ladder.append([ step[0],sub['problem']['name'], sub['problem']['contestId'], sub['problem']['index'], True ])
                    solved = solved + 1
                    break
            except:
                pass
        else:
            ladder.append([ step[0],step[1], step[2], step[3], False ])
    # for step in ladder:
    #     for x in step:
    #         print(x,)
    #     print("\n")
    try:
        logging.basicConfig(filename='handle.log',level=logging.INFO)
        logging.info(handle)
        #r = requests.get('http://kyukey-lock.herokuapp.com/a2oj/'+ handle)
    except:
        print("Error in logging")
    return render(request, 'ladder.html', {'ladder':ladder, 'division':div_head, 'handle': handle, 'solved':solved})
예제 #5
0
import requests
from bs4 import BeautifulSoup
import codeforces_api


def future_contests():

    url = "https://www.codechef.com/contests/?itm_medium=navmenu&itm_campaign=allcontests_head"

    payload = {}
    headers = {
        'Cookie':
        'SESS93b6022d778ee317bf48f7dbffe03173=d9752da233ebc9cef84d7b1de79d7407'
    }

    response = requests.request("GET", url, headers=headers, data=payload)

    print(response.text)
    soup = BeautifulSoup(response, 'lxml')
    contest = soup.find("li", )

    return contest


anonim_cf_api = codeforces_api.CodeforcesApi()
codeforces_contests = anonim_cf_api.contest_list()['result']
예제 #6
0
def home(request):
    try:
        handle = request.GET['handle']
        div = request.GET['div']
        #print(div)
    except:
        return render(request, 'index.html')
    parser = codeforces_api.CodeforcesApi()
    try:
        submissions = parser.user_status(handle=handle)
    except:
        return render(request, 'index.html' , {'msg': 'Invalid Codeforces handle '})
    ladder = []
    division = []
    div = int(div)
    div_head = ""
    if div==1:
        division = div_a
        div_head = "DIV 2.A"
    elif div==2:
        division = div_b
        div_head = "DIV 2.B"
    elif div==3:
        division = div_c
        div_head = "DIV 2.C"
    elif div==4:
        division = div_d
        div_head = "DIV 2.D"
    elif div==5:
        division = div_e
        div_head = "DIV 2.E"
    elif div==6:
        division = div_1d
        div_head = "DIV 1.D"
    elif div==7:
        division = div_1e
        div_head = "DIV 1.E"
    else:
        return render(request, 'index.html' , {'msg': 'Invalid Division selected '})
    for step in division:
        for sub in submissions['result']:
            try:
                if int(step[2])==sub['problem']['contestId'] and step[3]==sub['problem']['index'] and sub['verdict']=="OK":
                    ladder.append([ step[0],sub['problem']['name'], sub['problem']['contestId'], sub['problem']['index'], True ])
                    break
            except:
                pass
        else:
            ladder.append([ step[0],step[1], step[2], step[3], False ])
    # for step in ladder:
    #     for x in step:
    #         print(x,)
    #     print("\n")
    try:
        logging.basicConfig(filename='handle.log',level=logging.INFO)
        logging.info(handle)
        #r = requests.get('http://kyukey-lock.herokuapp.com/a2oj/'+ handle)
    except:
        print("Error in logging")
    return render(request, 'ladder.html', {'ladder':ladder, 'division':div_head, 'handle': handle})