Skip to content

kerolloz/codeforces-problem-scraper-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CodeForces Problem Scraper API

A straightforward Flask-Python API designed to parse Codeforces problems into JSON format.

Endpoint

Make a GET request to the root /?id=1325/A and provide the required query parameter id. The id should be in the following format contest_id/problem_letter.

For example, parsing this problem yields the following JSON response:

{
  "inputSpecification": "<p>The first line contains a single integer $$$t$$$ $$$(1 \\le t \\le 100)$$$  — the number of testcases.</p><p>Each testcase consists of one line containing a single integer, $$$x$$$ $$$(2 \\le x \\le 10^9)$$$.</p>",
  "memoryLimit": {
    "unit": "megabytes",
    "value": 256
  },
  "note": "<p>In the first testcase of the sample, $$$GCD(1,1)+LCM(1,1)=1+1=2$$$.</p><p>In the second testcase of the sample, $$$GCD(6,4)+LCM(6,4)=2+12=14$$$.</p>",
  "outputSpecification": "<p>For each testcase, output a pair of positive integers $$$a$$$ and $$$b$$$ ($$$1 \\le a, b \\le 10^9)$$$ such that $$$GCD(a,b)+LCM(a,b)=x$$$. It's guaranteed that the solution always exists. If there are several such pairs $$$(a, b)$$$, you can output any of them.</p>",
  "samples": [
    {
      "input": "\n2\n2\n14\n",
      "output": "\n1 1\n6 4\n"
    }
  ],
  "statement": "<p>You are given a positive integer $$$x$$$. Find <span class=\"tex-font-style-bf\">any</span> such $$$2$$$ positive integers $$$a$$$ and $$$b$$$ such that $$$GCD(a,b)+LCM(a,b)=x$$$.</p><p>As a reminder, $$$GCD(a,b)$$$ is the greatest integer that divides both $$$a$$$ and $$$b$$$. Similarly, $$$LCM(a,b)$$$ is the smallest integer such that both $$$a$$$ and $$$b$$$ divide it.</p><p>It's guaranteed that the solution always exists. If there are several such pairs $$$(a, b)$$$, you can output any of them.</p>",
  "timeLimit": {
    "unit": "second",
    "value": 1
  },
  "title": "A. EhAb AnD gCd"
}

Usage

After cloning the repository, you have two options:

  • Option 1: Python3 Installed

    • Navigate to the /app directory.
    • Install packages in requirements.txt using pip3.
      pip3 install -r requirements.txt
    • Start the server.
      FLASK_APP=main.py flask run
  • Option 2: Docker Installed

    • Build the image.
      docker build -t cf-problem-scraper-api .
    • Create a container.
      docker run -d --name cf-api -p 80:80 cf-problem-scraper-api

JSON Schema

{
  "inputSpecification": String,
  "memoryLimit": {
    "unit": String,
    "value": Number
  },
  "note": String, // or null
  "outputSpecification": String,
  "samples": [
    {
      "input": String,
      "output": String
    }
  ],
  "statement": String,
  "timeLimit": {
    "unit": String,
    "value": Number
  },
  "title": String
}

Feel free to explore and integrate this API into your projects!

About

Simple Flask-Python API

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published