Example #1
0
def main(argv):
    #llistat = [341,343,346,348,351,354,356,360,364,367,372,375,377,380,383,388,403,406,407,414,418,420,425,429,434,438,442]; #Div1contests
    #llistat = [379, 436, 325, 316, 241] #Div1&2contests
    #llistat = [549]; #LookseryCup
    llistat = [
        447, 448, 450, 451, 454, 456, 459, 460, 462, 463, 465, 466, 467
    ]
    #Div2contests.
    f = open('Div2sft.txt', 'w')
    api = CodeforcesAPI()
    for id in llistat:
        llista = list(api.contest_standings(id)['rows'])
        participa = str(len(llista))
        for p in llista:
            tio = p.party.members[0].handle
            print(str(id) + ' ' + str(p.rank))
            concursos = api.user_rating(tio)
            cont = 0
            for c in concursos:
                cont = cont + 1
                if c.contest_id == id:
                    f.write(
                        str(c.rank) + ' ' + str(c.old_rating) + ' ' +
                        str(c.new_rating) + ' ' + participa + ' ' + str(cont) +
                        ' ' + str(id) + '\n')
Example #2
0
def main(argv):
    assert len(argv) == 2

    api = CodeforcesAPI()

    print('Loading your submissions')
    handle = argv[1]
    submissions = filter_accepted(api.user_status(handle))
    solved_problems = filter_c(submission.problem for submission in submissions)
    solved_problems = set(solved_problems)
    six.print_(('Loaded {} solved C problems'.format(len(solved_problems))))

    print('Loading contests...')
    contests = group_by_contest_id(filter_div2(api.contest_list()))

    six.print_(('Loaded {} Div.2 contests'.format(len(contests))))

    print('Loading problemset...')
    problemset = api.problemset_problems()

    problems = group_by_contest_id(filter_c(problemset['problems']))

    stats = problemset['problemStatistics']
    stats = filter_c(stats)
    stats = filter(lambda s: s.contest_id in contests, stats)
    stats = filter(lambda s: problems[s.contest_id][0] not in solved_problems, stats)
    stats = sorted(stats, key=lambda s: s.solved_count, reverse=True)


    print()
    six.print_(('{:30}{:15}{}'.format('Name', 'Solved count', 'Url')))

    for stat in stats[:10]:
        problem = problems[stat.contest_id][0]
        six.print_(('{:30}{:<15}{}'.format(problem.name, stat.solved_count, make_url(problem))))
Example #3
0
def main(argv):
    assert len(argv) == 2

    api = CodeforcesAPI()

    print('Loading your submissions')
    handle = argv[1]
    submissions = filter_accepted(api.user_status(handle))
    solved_problems = {submission.problem for submission in submissions}
    print('Loaded {} solved problems'.format(len(solved_problems)))

    print('Loading contests...')
    contests = group_by_contest_id(filter_div2(api.contest_list()))

    print('Loaded {} Div.2 contests'.format(len(contests)))

    print('Loading problemset...')
    problemset = api.problemset_problems()

    stats = problemset['problemStatistics']
    stats = filter_c(stats)
    stats = filter(lambda s: s.contest_id in contests, stats)
    stats = sorted(stats, key=lambda s: s.solved_count, reverse=True)

    problems = group_by_contest_id(filter_c(problemset['problems']))

    print()
    print('{:30}{:10}{:15}{}'.format('Name', 'Is solved', 'Solved count', 'Url'))

    for stat in stats[:10]:
        problem = problems[stat.contest_id][0]
        print('{:30}{!s:10}{:<15}{}'.format(problem.name,
                                            problem in solved_problems,
                                            stat.solved_count,
                                            make_url(problem)))
Example #4
0
def retrieve_contestant_submissions(contestant, contest, problem_indices_by_contest_id):
    time.sleep(1)
    api = CodeforcesAPI()
    return list(filter(lambda s: (make_aware(datetime.fromtimestamp(s.creation_time),
                                             get_default_timezone()) >= contest.start_time and
                                  s.verdict != VerdictType.testing and
                                  s.problem.index in problem_indices_by_contest_id.get(s.problem.contest_id, [])),
                       api.user_status(contestant.cf_handle)))
Example #5
0
def main():
    api = CodeforcesAPI()

    handles = ['soon', 'DmitriyH', 'Fefer_Ivan']

    users = api.user_info(handles)

    for u in users:
        print('{}, rank: {}'.format(u.handle, u.rank))
Example #6
0
def main():
    api = CodeforcesAPI()

    handles = ['soon', 'DmitriyH', 'Fefer_Ivan']

    users = api.user_info(handles)

    for u in users:
        print('{}, rank: {}'.format(u.handle, u.rank))
Example #7
0
def main(cid, handle):
    api = CodeforcesAPI()
    contest_id = int(cid)
    submissions = api.contest_status(contest_id, handle=handle)
    print('{:^20}{} {:^20} {:^20}'.format('Submission ID', 'User Name',
                                          "Verdict", "Problem Index"))
    for s in submissions:
        print('{:^20}{} {:^20} {:^20}'.format(
            s.id, ', '.join(member.handle for member in s.author.members),
            s.verdict, s.problem.index))
Example #8
0
def Contests():
    api = CodeforcesAPI()
    url = 'http://codeforces.com/contest/{}'
    answer = ""
    url_registration = 'http://codeforces.com/contestRegistration/{}'
    x = api.contest_list(False)
    answer = []
    for c in x:
        if (c.start_time > int(time.time())):
            answer.append({'name':c.name, 'date': time.ctime(c.start_time)})
    return answer
Example #9
0
def main(argv):
    api = CodeforcesAPI()

    contest_id = int(argv[1])

    hacks = api.contest_hacks(contest_id)

    for h in hacks:
        print("[{:^30}] hacked [{:^30}], verdict: {}".format(', '.join(member.handle for member in h.hacker.members),
                                                             ', '.join(member.handle for member in h.defender.members),
                                                             h.verdict.value))
Example #10
0
def main(argv):
    api = CodeforcesAPI()

    count_submissions = int(argv[1])

    submissions = api.problemset_recent_status(count_submissions)

    print('{:^20}{}'.format('Submission ID', 'Party members'))

    for s in submissions:
        print('{:^20}{}'.format(s.id, ', '.join(member.handle for member in s.author.members)))
Example #11
0
def main(argv):
    api = CodeforcesAPI()

    contest_id = int(argv[1])

    submissions = api.contest_status(contest_id)

    print('{:^20}{}'.format('Submission ID', 'Party members'))

    for s in submissions:
        print('{:^20}{}'.format(s.id, ', '.join(member.handle for member in s.author.members)))
Example #12
0
def main(argv):
    api = CodeforcesAPI()

    count_submissions = int(argv[1])

    submissions = api.problemset_recent_status(count_submissions)

    print('{:^20}{}'.format('Submission ID', 'Party members'))

    for s in submissions:
        print('{:^20}{}'.format(
            s.id, ', '.join(member.handle for member in s.author.members)))
Example #13
0
def main(argv):
    api = CodeforcesAPI()

    handle = argv[1]

    rating_changes = list(api.user_rating(handle))

    print('Rating history for {}:'.format(handle))
    for rating in rating_changes:
        print(rating.old_rating, end=' -> ')

    print(rating_changes[-1].new_rating)
Example #14
0
def main(argv):
    api = CodeforcesAPI()

    handle = argv[1]

    rating_changes = list(api.user_rating(handle))

    print('Rating history for {}:'.format(handle))
    for rating in rating_changes:
        print(rating.old_rating, end)

    print(rating_changes[-1].new_rating)
Example #15
0
def main(argv):
    api = CodeforcesAPI()

    contest_id = int(argv[1])

    hacks = api.contest_hacks(contest_id)

    for h in hacks:
        print("[{:^30}] hacked [{:^30}], verdict: {}".format(
            ', '.join(member.handle for member in h.hacker.members),
            ', '.join(member.handle for member in h.defender.members),
            h.verdict.value))
Example #16
0
def main():
    api = CodeforcesAPI()

    users = get_users(api)
    diff = get_difficult()
    for week in range(1):
        print_for_users(api, users, diff, week, load_ratings_from_file('rating' + str(week + 1) + '.txt'))
Example #17
0
def main():
    api = CodeforcesAPI()

    ranklist = api.contest_standings(613, count=10000)
    ranklist_rows = list(ranklist['rows'])

    users = {u.handle: u for u in api.user_info(list(get_all_user_handles(ranklist_rows)))}

    print("Users from Ural FU:")
    for row in filter_by_organization(ranklist_rows, users, "Ural FU"):
        print('    {party}, points: {points}'.format(party=row.party, points=row.points))

    print()

    print("Users from Mexico:")
    for row in filter_by_country(ranklist_rows, users, "Mexico"):
        print('    {party}, points: {points}'.format(party=row.party, points=row.points))
Example #18
0
def main(argv):
    #llistat = [341,343,346,348,351,354,356,360,364,367,372,375,377,380,383,388,403,406,407,414,418,420,425,429,434,438,442]; #Div1contests
    #llistat = [379, 436, 325, 316, 241] #Div1&2contests
    #llistat = [549]; #LookseryCup
    llistat = [447,448,450,451,454,456,459,460,462,463,465,466,467]; #Div2contests.
    f = open('Div2sft.txt', 'w')
    api = CodeforcesAPI()
    for id in llistat:
        llista = list(api.contest_standings(id)['rows'])
        participa = str(len(llista))
        for p in llista:
            tio = p.party.members[0].handle
            print(str(id)+' '+str(p.rank))
            concursos = api.user_rating(tio)
            cont = 0
            for c in concursos:
                cont = cont+1
                if c.contest_id==id:
                    f.write(str(c.rank)+' '+str(c.old_rating)+' '+str(c.new_rating)+' '+participa+' '+str(cont)+' '+str(id)+'\n')
Example #19
0
def main():
    api = CodeforcesAPI()

    users = get_users(api)
    diff = get_difficult()
    for week in range(8):
        if week == 4:
            continue
        print_for_users(
            api, users, diff, week,
            load_ratings_from_file('rating' + str(week + 1) + '.txt'),
            'tmp.' + str(week + 1) + '.html')
Example #20
0
def get_submissions(contest_id):
    api = CodeforcesAPI()

    return filter_only_contestants(api.contest_status(contest_id))
Example #21
0
from telegram.ext import Updater
from codeforces import CodeforcesAPI
import logging
from telegram.ext import CommandHandler
from utils import unsolved_group
from utils import random_problem
from utils import easiest
import random

updater = Updater(token='262573736:AAEfHFSGp-5YGJFIiDt8_TmSZMR0XCHjtTg')
dispatcher = updater.dispatcher
logging.basicConfig(format='%(asctime)s - %(name)s - %(levelname)s - %(message)s', level=logging.INFO)

api = CodeforcesAPI()


# DEFINITIONS OF FUNCTIONS

# Entrega un mensaje de error
def error(bot, update):
    bot.sendMessage(chat_id=update.message.chat_id, text="wat is dis")


# Funcion stat
def start(bot, update):
    bot.sendMessage(chat_id=update.message.chat_id, text="wat is dis")


# Funcio hello
def hello(bot, update):
    bot.sendMessage(update.message.chat_id,
Example #22
0
def load_problems(contest_id):
    api = CodeforcesAPI()

    return api.contest_standings(contest_id, count=1)['problems']
Example #23
0
def load_hacks(contest_id):
    api = CodeforcesAPI()

    return api.contest_hacks(contest_id)
Example #24
0
def main():
    api = CodeforcesAPI()

    users = get_users(api)
    save_ratings_to_file(users, 'rating1.txt')
Example #25
0
def get_submissions(contest_id):
    api = CodeforcesAPI()

    return filter_only_contestants(api.contest_status(contest_id))