├── static ├── .nojekyll └── img │ ├── logo.png │ └── favicon.ico ├── docs ├── api │ ├── _category_.json │ ├── image │ │ └── ws-msg.png │ ├── openapi.md │ ├── endpoint.md │ ├── auth.md │ ├── format.mdx │ └── async-result.mdx ├── judge │ ├── _category_.json │ ├── api │ │ ├── _category_.json │ │ ├── async-result.mdx │ │ └── luogu-problem.mdx │ ├── index.md │ ├── pricing.md │ └── langs.md ├── project │ ├── _category_.json │ ├── hustoj.md │ ├── index.md │ ├── syzoj.md │ ├── hydro.md │ └── uoj.md └── index.md ├── babel.config.js ├── .idea ├── .gitignore ├── codeStyles │ ├── codeStyleConfig.xml │ └── Project.xml ├── vcs.xml ├── modules.xml ├── git_toolbox_prj.xml ├── lgapi-docs.iml ├── inspectionProfiles │ └── Project_Default.xml └── jsonSchemas.xml ├── sidebars.js ├── tsconfig.json ├── .gitignore ├── README.md ├── .github └── workflows │ ├── build.yml │ └── deploy.yml ├── package.json ├── .deploy.py ├── docusaurus.config.js ├── openapi ├── _api.yaml └── judge.yaml └── LICENSE /static/.nojekyll: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/api/_category_.json: -------------------------------------------------------------------------------- 1 | { 2 | "label": "API 调用", 3 | "position": 3 4 | } 5 | -------------------------------------------------------------------------------- /docs/judge/_category_.json: -------------------------------------------------------------------------------- 1 | { 2 | "label": "评测能力", 3 | "position": 4 4 | } 5 | -------------------------------------------------------------------------------- /docs/project/_category_.json: -------------------------------------------------------------------------------- 1 | { 2 | "label": "接入项目", 3 | "position": 114514 4 | } 5 | -------------------------------------------------------------------------------- /docs/judge/api/_category_.json: -------------------------------------------------------------------------------- 1 | { 2 | "label": "API 文档", 3 | "position": 114514 4 | } 5 | -------------------------------------------------------------------------------- /static/img/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/luogu-dev/lgapi-docs/HEAD/static/img/logo.png -------------------------------------------------------------------------------- /static/img/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/luogu-dev/lgapi-docs/HEAD/static/img/favicon.ico -------------------------------------------------------------------------------- /docs/api/image/ws-msg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/luogu-dev/lgapi-docs/HEAD/docs/api/image/ws-msg.png -------------------------------------------------------------------------------- /babel.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | presets: [require.resolve('@docusaurus/core/lib/babel/preset')], 3 | }; 4 | -------------------------------------------------------------------------------- /.idea/.gitignore: -------------------------------------------------------------------------------- 1 | # Default ignored files 2 | /shelf/ 3 | /workspace.xml 4 | # Editor-based HTTP Client requests 5 | /httpRequests/ 6 | -------------------------------------------------------------------------------- /.idea/codeStyles/codeStyleConfig.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /sidebars.js: -------------------------------------------------------------------------------- 1 | // @ts-check 2 | 3 | /** @type {import('@docusaurus/plugin-content-docs').SidebarsConfig} */ 4 | const sidebars = { 5 | sidebar: [{ type: 'autogenerated', dirName: '.' }] 6 | }; 7 | 8 | module.exports = sidebars; 9 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | // This file is not used in compilation. It is here just for a nice editor experience. 3 | "extends": "@tsconfig/docusaurus/tsconfig.json", 4 | "compilerOptions": { 5 | "baseUrl": "." 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Dependencies 2 | /node_modules 3 | 4 | # Production 5 | /build 6 | 7 | # Generated files 8 | .docusaurus 9 | .cache-loader 10 | 11 | # Misc 12 | .DS_Store 13 | .env.local 14 | .env.development.local 15 | .env.test.local 16 | .env.production.local 17 | 18 | npm-debug.log* 19 | yarn-debug.log* 20 | yarn-error.log* 21 | -------------------------------------------------------------------------------- /docs/project/hustoj.md: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar_position: 9999999999 3 | --- 4 | 5 | # HUSTOJ 6 | 7 | :::danger 注意 8 | 9 | HUSTOJ 是一个历史久远的评测系统,其设计方式和使用的技术均较为古老,从部署难易程度、功能和安全性来说均已**落后**于新生代的系统。我们非常**不建议**使用。 10 | 11 | 如果您还没有搭建评测系统,推荐使用同样免费开源的 [Hydro](./hydro.md) 作为您的评测系统。 如果您已经安装了 HUSTOJ,也可以无痛迁移至 [Hydro](./hydro.md)。 12 | 13 | ::: 14 | 15 | *尚无 HUSTOJ 支持。* 16 | -------------------------------------------------------------------------------- /docs/api/openapi.md: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar_position: 114514 3 | pagination_next: null 4 | --- 5 | 6 | # OpenAPI 7 | 8 | OpenAPI 规范(OpenApp Specification, OAS),是定义一个标准的、与具体编程语言无关的 API 的规范。OpenAPI 规范使得人类和计算机都能在“不接触任何程序源代码和文档、不监控网络通信”的情况下理解一个服务的作用。 9 | 10 | 洛谷开放平台提供了遵循 OpenAPI 规范的描述文件,可以随时在导航栏右上角打开 [OpenAPI 页面](/openapi)查阅。您也可以在页面上下载描述文件,并用趁手的工具(Postman、Swagger 等)来展示或调试 API。 11 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # 洛谷 API 文档 2 | 3 | 目前该项目有[开放平台文档](https://docs.lgapi.cn/open/)。 4 | 5 | 该网站使用 [Docusaurus 2](https://docusaurus.io/) 构建,文档内容采用 [CC BY-NC-ND 4.0 协议](http://creativecommons.org/licenses/by-nc-nd/4.0/)进行许可。 6 | 7 | [![知识共享许可协议](https://i.creativecommons.org/l/by-nc-nd/4.0/88x31.png)](http://creativecommons.org/licenses/by-nc-nd/4.0/) 8 | 9 | ### 开发、编辑 10 | 11 | ``` 12 | $ pnpm install 13 | $ pnpm run start 14 | ``` 15 | -------------------------------------------------------------------------------- /docs/judge/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | pagination_prev: null 3 | --- 4 | 5 | # 评测能力 6 | 7 | 评测能力是洛谷推出的评测即服务。OpenApp 可以通过这个能力使用洛谷的评测机资源执行程序,验证代码。 8 | 9 | 对于将洛谷作为 RemoteJudge 源,使用洛谷题库进行评测的 OpenApp,可以通过 [https://cdn.luogu.com.cn/problemset-open/latest.ndjson.gz](https://cdn.luogu.com.cn/problemset-open/latest.ndjson.gz) 下载洛谷题库的导出数据,以更新本地题库。 10 | 11 | :::note 12 | 13 | 洛谷题库数据为 NDJSON(Newline Delimited JSON,换行分割的 JSON)格式,每一行都是洛谷题库中的一道题目,可以在读入时以行为单位读入。 14 | 15 | ::: 16 | -------------------------------------------------------------------------------- /docs/api/endpoint.md: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar_position: 1 3 | pagination_prev: null 4 | --- 5 | 6 | # API 端点 7 | 8 | :::caution 注意 9 | 10 | 洛谷开放平台的所有端点都使用了 TLS 为应用层加密,保障 API 调用和内容的安全。 11 | 12 | 平台限制 TLS 版本为 1.2 及以上,请确保 OpenApp 开启了 TLS 1.2 及以上版本的安全支持。 13 | 14 | ::: 15 | 16 | HTTP 端点的 Base URL 为 `https://open-v1.lgapi.cn`。HTTP 端点用于 OpenApp 的主动请求,需要完成鉴权,详见[鉴权说明](auth.md)。 17 | 18 | WebSocket 端点为 `wss://open-ws.lgapi.cn/ws`。WebSocket 端点用于平台对 OpenApp 的消息推送,同样需要鉴权,详见 [异步结果推送](async-result.mdx) 中的 WebSocket 部分。 19 | -------------------------------------------------------------------------------- /.idea/git_toolbox_prj.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 14 | 15 | -------------------------------------------------------------------------------- /docs/api/auth.md: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar_position: 2 3 | sidebar_label: 鉴权说明 4 | --- 5 | 6 | # API 鉴权说明 7 | 8 | 洛谷开放平台的 API 鉴权使用 HTTP Basic authentication 完成,从开放平台申请到的 OpenApp Token 实际上是 Basic auth 的凭证组合,例如下面这个 token: 9 | ``` 10 | 01gt8s4bnbesna15e9f6wvk5pn:w1MmbjBCsDYjXpgS 11 | ``` 12 | 13 | 冒号前面的 `01gt8s4bnbesna15e9f6wvk5pn` 是用户、后面的 `w1MmbjBCsDYjXpgS` 则是密码,在某些请求库或工具中需要分开填写。 14 | 15 | 如果直接构造 HTTP Header 的话,则需要按照标准对其 base64 编码后使用,例如上面这个 token 就需要以这种形式发送: 16 | 17 | ``` 18 | Authorization: Basic MDFndDhzNGJuYmVzbmExNWU5ZjZ3dms1cG46dzFNbWJqQkNzRFlqWHBnUw== 19 | ``` 20 | -------------------------------------------------------------------------------- /docs/judge/api/async-result.mdx: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar_position: 114514 3 | hide_table_of_contents: true 4 | pagination_next: null 5 | --- 6 | 7 | import ApiSchema from '@theme/ApiSchema'; 8 | 9 | # 执行结果 10 | 11 | `GET /judge/result?id=` 12 | 13 | OpenApp 可以通过这个接口使用 Request ID 主动获得此前的评测结果。 14 | 15 | 在评测尚未完成且没有任何结果产生的时候,该接口会返回 HTTP 状态 `204 No Content`。在已有部分结果产生,或评测已经完成时,该接口会以 HTTP 状态 `200 OK` 返回内容。 16 | 17 | 评测能力的执行结果,无论是使用此 API 还是使用 HTTP callback 或 WebSocket 等消息通知渠道,其返回的对象结构都是一样的: 18 | 19 | 20 | -------------------------------------------------------------------------------- /.idea/lgapi-docs.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /docs/judge/api/luogu-problem.mdx: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar_position: 1 3 | sidebar_label: 洛谷题库评测 4 | hide_table_of_contents: true 5 | --- 6 | 7 | import ApiSchema from '@theme/ApiSchema'; 8 | 9 | # 洛谷题库评测 10 | 11 | `POST /judge/problem` 12 | 13 | 洛谷的题库数据是不公开的,若希望 OpenApp 可以使用洛谷的题目数据进行评测,通过这个接口将代码发回洛谷完成。洛谷的公开题库(除 RemoteJudge 外)均支持此接口。 14 | 15 | 这是异步请求,只会返回 Request ID。对于主动查询,请参阅[执行结果](async-result.mdx);对于被动推送,执行结果关联的 WebSocket 通知频道为 `judge.result`。结果需要及时查询,平台只会将结果保存 15 分钟。 16 | 17 | POST Body: 18 | 19 | 20 | 21 | Response Body: 22 | 23 | 24 | -------------------------------------------------------------------------------- /docs/project/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | pagination_prev: null 3 | pagination_next: null 4 | --- 5 | 6 | # 接入项目 7 | 8 | 为了降低 OpenApp 开发成本,可以选择一些已经实现了接入洛谷开放平台的项目协助开发。如此列表有遗漏,欢迎联系推荐。 9 | 10 | ## 评测系统集成 11 | 12 | :::tip 13 | 14 | 不是所有评测系统都在设计上支持远端评测,使用体验可能因系统而异。推荐使用原生支持多题库和远端评测的 [Hydro](hydro.md)。 15 | 16 | 如果您还没有搭建评测系统,推荐使用 Hydro 作为您的评测系统。Hydro 有完善的插件系统用以增删定制功能,以及原生的多题库和远程评测支持。更多功能可参照 [功能对比](https://docs.hydro.ac/docs/#%E5%8A%9F%E8%83%BD%E5%AF%B9%E6%AF%94)。 17 | 18 | 如果您已经安装了 HUSTOJ、SYZOJ、Vijos 等评测系统,同样也可以根据 [官方迁移指南](https://docs.hydro.ac/plugins/migrate/) 的介绍将您的评测系统无缝迁移至 Hydro,所有的题目、用户、提交记录、比赛等数据均会保留。若在迁移过程中遇到问题,可以联系开发人员免费协助。 19 | 20 | ::: 21 | 22 | ## 功能对比 23 | 24 | | 在线测评系统 | 一键导入 | 单题添加 | 25 | |:-----------------------:|:------:|:------:| 26 | | [Hydro(推荐)](hydro.md) | 支持 | 支持 | 27 | | [UniversalOJ](uoj.md) | 支持 | 支持 | 28 | | [SYZOJ](syzoj.md) | 支持 | 不支持 | 29 | | [HUSTOJ](hustoj.md) | 不支持 | 不支持 | 30 | 31 | ## SDK 等 32 | 33 | 暂无。 34 | -------------------------------------------------------------------------------- /.github/workflows/build.yml: -------------------------------------------------------------------------------- 1 | name: build 2 | 3 | on: 4 | - push 5 | - pull_request 6 | 7 | concurrency: 8 | group: ${{ github.workflow }}:${{ github.ref }} 9 | cancel-in-progress: true 10 | 11 | jobs: 12 | build: 13 | runs-on: ubuntu-latest 14 | steps: 15 | - name: checkout 16 | uses: actions/checkout@v4 17 | 18 | - uses: pnpm/action-setup@v4 19 | name: install pnpm 20 | with: 21 | run_install: false 22 | 23 | - name: install node.js 24 | uses: actions/setup-node@v4 25 | with: 26 | node-version: 20 27 | cache: 'pnpm' 28 | 29 | - name: install dependencies 30 | run: pnpm install 31 | 32 | - name: build 33 | run: pnpm run build 34 | 35 | - name: upload artifact 36 | uses: actions/upload-artifact@v4 37 | with: 38 | name: help-site 39 | path: build 40 | -------------------------------------------------------------------------------- /docs/project/syzoj.md: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar_label: SYZOJ 3 | sidebar_position: 3 4 | --- 5 | 6 | # 原生支持洛谷开放平台的 SYZOJ 新版本 7 | 8 | 在 [新版本(`573796f`)](https://github.com/syzoj/syzoj/commit/573796fa7670e28d428692f1d91e7ea50ee154e5) 中,SYZOJ 已经原生支持洛谷开放平台,无需额外的配置或插件。用户只需将系统更新至最新版本,即可轻松实现与洛谷开放平台的集成。这个更新将极大地简化接入流程,为您提供更全面的用户体验。 9 | 10 | 如果您是 SYZOJ 的用户,您可以在后台管理界面的“其他操作”中验证您的版本是否支持洛谷开放平台的接入。如果您的版本较旧,您可以使用以下方法来更新您的系统: 11 | 12 | - 对于 Docker 快速安装用户,您可以在服务器上运行 `docker pull menci/syzoj-web` 后重启服务以进行更新。 13 | - 对于手动安装用户,您可以在 `syzoj-web` 目录中运行 `git pull` 后重启服务以进行更新。 14 | 15 | 如果您使用了经过定制修改的 SYZOJ 版本,您可以选择自行升级到新版本,或者咨询洛谷开放平台,以获取协助进行相关接入的支持。 16 | 17 | 要使 SYZOJ 接入洛谷开放平台,您需要执行以下步骤: 18 | 19 | 1. 在“后台管理-配置文件”中配置 `luogu_openapi_token`,将您从开放平台申请到的 OpenApp Token 填入配置文件中并保存,如: 20 | 21 | ```json 22 | { 23 | "luogu_openapi_token": "01gt8s4bnbesna15e9f6wvk5pn:w1MmbjBCsDYjXpgS" 24 | } 25 | ``` 26 | 27 | 2. 在“后台管理-其他操作”中点击“导入洛谷 VJudge 题目”按钮,一键导入所有洛谷开放平台的题目。 28 | 29 | 3. 完成上述步骤后,您应该能够在题库中看到题目类型为“VJudge(洛谷)”的题目,并尝试提交以确认您的 SYZOJ 已可以通过开放平台进行远程评测。 30 | 31 | 如果您有部署或者二次开发方面的需求,可以联系开发者或洛谷开放平台寻求付费帮助。 32 | -------------------------------------------------------------------------------- /docs/judge/pricing.md: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar_position: 2 3 | --- 4 | 5 | # 收费标准 6 | 7 | :::caution 8 | 9 | 洛谷开放平台目前处于公测阶段,服务 SLA 和接口稳定性仅能提供尽力而为的支持。费用标准也并非正式商业化价格,如有问题可与我们通过商业邮箱联系。 10 | 11 | ::: 12 | 13 | 洛谷开放平台的评测能力服务(RemoteJudge)是付费服务。凡是需要使用这项服务的,都需要收费。 14 | 15 | 目前仅开放**标准版**一个套餐。以后可能开放更多的套餐。 16 | 17 | ## 计费点 18 | 19 | :::caution 20 | 21 | 洛谷开放平台目前处于公测阶段,暂未按照运行时间扣减计费点,我们将在启用该规则前通知用户。 22 | 23 | ::: 24 | 25 | 用户付费后,在一定时间内可以获得一定数量的计费点,用于使用评测服务。 26 | 27 | 具体而言,每次评测成功后,将至少扣除 1 个计费点;如果该评测的实际运行时间超过 10 秒,则每超过 10 秒(不到 10 秒的部分算作 10 秒),增扣 1 个计费点。每次评测扣除计费点的上限为 10 个计费点。评测失败时(指平台没有产生结果,不包括编译失败等情况)不扣除计费点。 28 | 29 | ## 标准版套餐 30 | 31 | - 按季度收费:每季度 1500 元。 32 | - 按年收费:每年 5100 元(85 折)。 33 | 34 | 本套餐将会每个季度提供 30000 个计费点。当季度有效,超出时间后则失效,不结转次季度。年付套餐则是产生 4 个按季度循环的套餐,不能提前使用下个季度的套餐额度。 35 | 36 | 如有其他数量需求,可联系我们定制。 37 | 38 | 所有服务均可开具增值税普通发票或增值税专用发票,也可以签订服务协议或合同,具体请通过商业合作邮箱或者微信客服咨询。 39 | 40 | ## 服务标准 41 | 42 | - 服务可用性:99%。本项数据是指在一个月内,计划外的故障导致无法使用评测服务的时长,不超过一个月的 1%。 43 | - 可以评测所有的洛谷题号为 P 或者 B 开头的题目(公共题目),约 15,000 题目。 44 | - 提供洛谷公共题目的题面。但不会直接提供测试数据。 45 | - 提供技术支持服务(QQ 群)协助接入。 46 | - 不提供试用服务。如果希望查看部署效果,可以前往 查看部署实例和尝试。 47 | -------------------------------------------------------------------------------- /docs/project/hydro.md: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar_position: 1 3 | --- 4 | 5 | # Hydro 插件 6 | 7 | HydroOJ 作为首批接入洛谷开放平台的在线评测系统,实现了完整的远程评测体验,您可以在 Hydro 中导入洛谷全部题目,定期更新,复制题目,编辑题面,发起评测和接收所有的子评测详细结果。 8 | 9 | 如果您还没有安装 Hydro,可以使用下方命令一键安装,详情阅读[官方指南](https://docs.hydro.ac/docs/install/)。 10 | 11 | ```sh 12 | LANG=zh . <(curl https://hydro.ac/setup.sh) 13 | ``` 14 | 15 | 使 Hydro 接入洛谷开放平台,您需要进行以下操作: 16 | 17 | 1. 使用 `hydrooj install https://hydro.ac/hydroac-client.zip` 安装最新的远端评测和题库导入工具。 18 | 2. 重启 Hydro 进程(`pm2 restart hydrooj`)。 19 | 3. 使用管理员账号登录,前往 控制面板 -> 脚本管理 页面,找到 `luogu-import-problem` 脚本,运行,参数可留空,也可参照下方更多信息。 20 | 4. 前往 控制面板->洛谷RemoteJudge管理,购买或填写账号信息。 21 | 5. 设置完成后再次重启 Hydro 进程。 22 | 6. 大功告成! 23 | 24 | 如果需要帮助部署/迁移或有二次开发的需求,您可联系 Hydro 开发者寻求帮助。 25 | 26 | ## 题库导入参数 27 | 28 | ```json 29 | {"path":"","domainId":"luogu","prefix":""} 30 | ``` 31 | 32 | JSON 格式; 33 | 34 | `path` 为本地的题目包路径,留空则自动下载。 35 | `domainId` 为导入的目标域,若希望导入默认域则填写 system 36 | `prefix` 为导入题目时添加的题号前缀,留空则保持原题号。 37 | 38 | 若日后需要更新题目列表则再次运行该导入功能即可。 39 | 40 | - Hydro 仓库地址:https://github.com/hydro-dev/hydro 41 | - Hydro 文档:https://hydro.js.org (镜像:https://docs.hydro.ac) 42 | - 洛谷 vjudge 插件仓库地址:https://github.com/hydro-dev/luogu 43 | -------------------------------------------------------------------------------- /.idea/inspectionProfiles/Project_Default.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 22 | -------------------------------------------------------------------------------- /docs/project/uoj.md: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar_label: UOJ 3 | sidebar_position: 2 4 | --- 5 | 6 | # 适用于 UniversalOJ 的 Remote Judge 模块 7 | 8 | 通过将本模块集成到您现有的 Universal Online Judge (UOJ) 安装中,您可以将洛谷开放平台的强大评测能力带入您本地的评测系统中,从而提高您的教学效率和质量。 9 | 10 | 作为首批接入洛谷开放平台的评测系统扩展模块,本模块提供了完整的代评测体验,具体包括以下功能: 11 | 12 | - 支持在线爬取来自洛谷的题面,并在自己的评测系统上展示; 13 | - 远程提交评测请求至洛谷平台,获取评测结果及其详细信息,并将其显示在您的评测系统上; 14 | - 对于需要导入较多题目的情况,我们还支持从本地文件批量导入洛谷题库(请在 [评测能力](../judge/index.md) 页面下载离线数据库)。 15 | 16 | 为了将现有的 UOJ 安装接入洛谷开放平台,您需要遵循以下步骤进行操作: 17 | 18 | 1. 将 [renbaoshuo/UOJ-Luogu-RemoteJudge](https://github.com/renbaoshuo/UOJ-Luogu-RemoteJudge) 仓库中的相关文件下载到本地([打包下载链接](https://github.com/renbaoshuo/UOJ-Luogu-RemoteJudge/archive/refs/heads/master.zip);打不开?[从镜像仓库下载](https://git.m.ac/baoshuo/UOJ-Luogu-RemoteJudge/archive/master.zip))。 19 | 2. 按照 [安装教程](https://github.com/renbaoshuo/UOJ-Luogu-RemoteJudge/blob/master/INSTALLATION.md) 中的步骤将洛谷开放平台集成进您的评测系统中(打不开?访问 [镜像页面](https://git.m.ac/baoshuo/UOJ-Luogu-RemoteJudge/src/branch/master/INSTALLATION.md))。 20 | 21 | 如果无法访问 GitHub,可以访问镜像仓库 [git.m.ac/baoshuo/UOJ-Luogu-RemoteJudge](https://git.m.ac/baoshuo/UOJ-Luogu-RemoteJudge)([打包下载链接](https://git.m.ac/baoshuo/UOJ-Luogu-RemoteJudge/archive/master.zip))。 22 | 23 | 如果您有部署或者二次开发方面的需求,可以联系开发人员寻求付费帮助。 24 | -------------------------------------------------------------------------------- /docs/api/format.mdx: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar_position: 3 3 | hide_table_of_contents: true 4 | --- 5 | 6 | import ApiSchema from '@theme/ApiSchema'; 7 | 8 | # 调用格式 9 | 10 | 针对 POST 类需要 HTTP body 的请求,平台以接受 JSON 为准。但在大部分情况,等价的 Form(包括 `form-data` 和 `x-www-form-urlencoded`)也是接受的,如下面两个请求: 11 | 12 | ``` 13 | POST /json-example 14 | Accept: application/json 15 | Content-Type: application/json 16 | User-Agent: my-new-app/1.0 17 | 18 | {"a":"b","1":2} 19 | ``` 20 | 21 | ``` 22 | POST /form-example 23 | Accept: application/json 24 | Content-Type: application/x-www-form-urlencoded 25 | User-Agent: my-new-app/1.0 26 | 27 | a=b&1=2 28 | ``` 29 | 30 | 本平台的请求返回如无特殊说明,均为 JSON 格式,但仍应该带上 `Accept: application/json` 请求头。 31 | 32 | 为了在调试和查错时更加方便快捷,我们强烈建议应用开发方使用自己的独特 `User-Agent` 标识,例如上面例子中的 `my-new-app/1.0`。 33 | 34 | 平台的返回值会在每个 API 的说明页面详细给出。但他们执行成功与否均会以 HTTP 状态表示,如: 35 | - `200 OK` 请求成功完成。 36 | - `204 No Content` 请求成功完成,且没有任何内容需要返回。 37 | - `400 Bad Request` 请求内容有误。 38 | - `401 Unauthorized` 需要鉴权。 39 | - `402 Payment Required` 余额不足,需要充值。 40 | - `403 Forbidden` 权限不足。 41 | - `404 Not Found` 资源未找到。 42 | - `405 Method Not Allowed` 资源未找到。 43 | 44 | 具体请以 API 的说明页面为准。 45 | 46 | ## 错误处理 47 | 48 | 有些时候请求不能成功完成,对于 40x 一类错误,均会返回下面格式的错误信息: 49 | 50 | 51 | 52 | 而当 `errorType` 为 `Lentille\SymfonyBundle\Exception\FormErrorException` 或 `errorData.lentilleFormError` 为 `1` 时,`errorData` 字段具有如下结构: 53 | 54 | 55 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@luogu-dev/lgapi-docs", 3 | "version": "0.0.0", 4 | "private": true, 5 | "scripts": { 6 | "docusaurus": "docusaurus", 7 | "start": "docusaurus start", 8 | "build": "docusaurus build", 9 | "swizzle": "docusaurus swizzle", 10 | "deploy": "docusaurus deploy", 11 | "clear": "docusaurus clear", 12 | "serve": "docusaurus serve", 13 | "write-translations": "docusaurus write-translations", 14 | "write-heading-ids": "docusaurus write-heading-ids", 15 | "typecheck": "tsc" 16 | }, 17 | "dependencies": { 18 | "@docusaurus/core": "2.3.1", 19 | "@docusaurus/preset-classic": "2.3.1", 20 | "@mdx-js/react": "^1.6.22", 21 | "clsx": "^1.2.1", 22 | "prism-react-renderer": "^1.3.5", 23 | "react": "^17.0.2", 24 | "react-dom": "^17.0.2", 25 | "redocusaurus": "^1.6.1" 26 | }, 27 | "devDependencies": { 28 | "@docusaurus/module-type-aliases": "2.3.1", 29 | "@tsconfig/docusaurus": "^1.0.5", 30 | "typescript": "^4.7.4" 31 | }, 32 | "browserslist": { 33 | "production": [ 34 | ">0.5%", 35 | "not dead", 36 | "not op_mini all" 37 | ], 38 | "development": [ 39 | "last 1 chrome version", 40 | "last 1 firefox version", 41 | "last 1 safari version" 42 | ] 43 | }, 44 | "engines": { 45 | "node": ">=20.17" 46 | }, 47 | "packageManager": "pnpm@9.13.2+sha512.88c9c3864450350e65a33587ab801acf946d7c814ed1134da4a924f6df5a2120fd36b46aab68f7cd1d413149112d53c7db3a4136624cfd00ff1846a0c6cef48a" 48 | } 49 | -------------------------------------------------------------------------------- /.idea/jsonSchemas.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /docs/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar_label: 平台介绍/Introduction 3 | sidebar_position: 1 4 | breadcrumbs: false 5 | hide_title: true 6 | unlisted: true 7 | hide_table_of_contents: true 8 | pagination_prev: null 9 | pagination_next: null 10 | --- 11 | 12 | # 欢迎来到洛谷开放平台 13 | 14 | 15 | 洛谷开放平台是由国内知名算法社区洛谷推出的技术赋能解决方案,旨在为教育机构、开发者及在线评测系统(OJ)提供一站式题库接入与评测服务。平台依托洛谷十年积累的优质资源,开放其海量公开题库及高并发评测能力,帮助用户快速构建稳定、专业的编程训练环境,显著降低开发运维成本。 16 | 17 | - 海量资源:无缝接入 10,000+ 道精选算法题目(不含RemoteJudge),覆盖主流竞赛考点与教学场景,支持题库实时同步更新。 18 | - 高速评测:依托高峰期日均处理 200,000+ 评测的分布式系统,提供高效的响应、精准判题服务,免除自建评测机运维压力。 19 | - 生态兼容:原生支持 HydroOJ、UOJ、SYZOJ 等主流开源 OJ 系统,提供标准化 API 接口与插件化接入方案,确保低代码快速部署。 20 | 21 | 商务合作邮箱:k@luogu.org 22 | 23 | **Luogu Open Platform** is a technical empowerment solution developed by Luogu, China's premier algorithm community, specifically designed for educational institutions, developers, and Online Judge (OJ) systems. Leveraging a decade of high-quality resources accumulated by Luogu, the platform opens access to its massive public question bank and high-concurrency evaluation capabilities, enabling users to quickly build stable, professional programming training environments while significantly reducing development and operational costs. 24 | 25 | - **Extensive Resources**: Seamless integration with 10,000+ curated algorithm problems (excluding RemoteJudge), covering key competition topics and educational scenarios, with real-time question bank synchronization. 26 | - **High-Speed Judging**: Powered by distributed systems processing over 200,000 submissions daily during peak periods, delivering efficient response times and precise judging services, eliminating the need for self-hosted judging machines. 27 | - **Ecosystem Compatibility**: Native support for major OJ frameworks including HydroOJ, UOJ, and SYZOJ, featuring standardized API interfaces and plugin-based integration solutions for low-code deployment. 28 | 29 | The document is currently in Chinese only. For English inquiries, please contact us at k@luogu.org. -------------------------------------------------------------------------------- /.deploy.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | import os 4 | import oss2 5 | import zipfile 6 | import argparse 7 | import tempfile 8 | import re 9 | 10 | 11 | def build_parser(): 12 | parser = argparse.ArgumentParser(description='Luogu deploy script') 13 | parser.add_argument('-p', '--prefix', help='Aliyun OSS Path Prefix') 14 | parser.add_argument('path', help='built path') 15 | return parser 16 | 17 | 18 | def main(): 19 | args = build_parser().parse_args() 20 | oss_auth = oss2.Auth(os.environ['ALIOSS_AK'], os.environ['ALIOSS_SK']) 21 | oss_bucket = oss2.Bucket(oss_auth, os.environ['ALIOSS_ENDPOINT'], os.environ['ALIOSS_BUCKET']) 22 | prefix = (args.prefix.replace('\\', '/').rstrip('/') + '/').lstrip('/') 23 | 24 | built_dir = os.path.join(os.getcwd(), args.path) 25 | built_files = set([os.path.join(base[len(built_dir):], file).replace('\\', '/').lstrip('/\\') 26 | for base, _, files in os.walk(built_dir) 27 | for file in files 28 | ]) 29 | 30 | oss_file_set = set([obj.key for obj in oss2.ObjectIterator(oss_bucket, prefix=prefix) if obj.key]) 31 | files_to_remove = oss_file_set - set([prefix + file for file in built_files]) 32 | 33 | print(f'Files to remove: {files_to_remove}') 34 | 35 | for file in built_files: 36 | oss_key = prefix + file 37 | if re.search(r'([0-9a-f]{16,}|\.[0-9a-f]{8}\.(js|css)$)', file) and oss_key in oss_file_set: 38 | print(f'Skipping file {file} (hashed)') 39 | continue 40 | 41 | full_path = os.path.join(built_dir, *file.split('/')) 42 | print(f'Putting file {file}') 43 | result = oss_bucket.put_object(oss_key, open(full_path, 'rb').read()) 44 | if result.status != 200: 45 | raise RuntimeError(result) 46 | 47 | print("Removing old files") 48 | 49 | for file in files_to_remove: 50 | print("Removing file {}".format(file)) 51 | oss_bucket.delete_object(file) 52 | 53 | 54 | if __name__ == '__main__': 55 | main() 56 | -------------------------------------------------------------------------------- /docusaurus.config.js: -------------------------------------------------------------------------------- 1 | // @ts-check 2 | 3 | const config = { 4 | title: '洛谷开放平台文档', 5 | favicon: 'img/favicon.ico', 6 | 7 | url: 'https://docs.lgapi.cn/', 8 | baseUrl: '/open/', 9 | 10 | onBrokenLinks: 'throw', 11 | onBrokenMarkdownLinks: 'warn', 12 | 13 | i18n: { 14 | defaultLocale: 'zh-Hans', 15 | locales: ['zh-Hans'], 16 | }, 17 | 18 | presets: [ 19 | ['@docusaurus/preset-classic', { 20 | blog: false, 21 | pages: false, 22 | docs: { 23 | routeBasePath: '/' 24 | } 25 | }], 26 | ['redocusaurus', { 27 | specs: [ 28 | { id: 'open', spec: './openapi/_api.yaml', route: '/openapi' } 29 | ] 30 | }] 31 | ], 32 | 33 | themeConfig: { 34 | navbar: { 35 | title: '洛谷开放平台', 36 | logo: { 37 | alt: 'Luogu', 38 | src: 'img/logo.png' 39 | }, 40 | items: [{ 41 | position: 'left', 42 | // type: 'doc', 43 | to: '/', 44 | activeBaseRegex: '^/open/?$', 45 | label: '介绍' 46 | }, { 47 | position: 'left', 48 | to: '/judge/', 49 | activeBaseRegex: '^/open/judge/', 50 | label: '评测能力' 51 | }, { 52 | position: 'right', 53 | to: '/openapi', 54 | label: 'OpenAPI' 55 | }], 56 | }, 57 | footer: { 58 | style: 'dark', 59 | copyright: ` 60 | Copyright © ${new Date().getFullYear()} 上海洛谷网络科技有限公司. Built with Docusaurus.
61 | 沪ICP备18008322号 62 | ` 63 | }, 64 | prism: { 65 | theme: require('prism-react-renderer/themes/github'), 66 | darkTheme: require('prism-react-renderer/themes/dracula') 67 | } 68 | }, 69 | }; 70 | 71 | module.exports = config; 72 | -------------------------------------------------------------------------------- /.github/workflows/deploy.yml: -------------------------------------------------------------------------------- 1 | name: deploy website 2 | 3 | on: 4 | workflow_run: 5 | workflows: [build] 6 | types: [completed] 7 | branches: 8 | - 'master' 9 | 10 | concurrency: 11 | group: ${{ github.workflow }}:${{ github.ref }} 12 | cancel-in-progress: true 13 | 14 | jobs: 15 | check: 16 | runs-on: ubuntu-latest 17 | environment: publish 18 | if: | 19 | true 20 | && github.ref == 'refs/heads/master' 21 | && github.event.workflow_run.head_repository.full_name == github.event.repository.full_name 22 | && github.event.workflow_run.conclusion == 'success' 23 | outputs: 24 | secrets: ${{ steps.checker.outputs.secrets }} 25 | steps: 26 | - name: check if secrets exist 27 | id: checker 28 | shell: bash 29 | env: 30 | ALIOSS_AK: ${{ secrets.ALIOSS_AK }} 31 | ALIOSS_SK: ${{ secrets.ALIOSS_SK }} 32 | run: | 33 | function check() { 34 | if [[ -z "${!1}" ]]; then 35 | echo $1 NOT found 36 | exit 0 37 | fi 38 | } 39 | check ALIOSS_AK 40 | check ALIOSS_SK 41 | # all checked 42 | echo "secrets=ok" >> $GITHUB_OUTPUT 43 | echo secrets found 44 | 45 | deploy: 46 | runs-on: ubuntu-latest 47 | environment: publish 48 | needs: [check] 49 | if: needs.check.outputs.secrets == 'ok' 50 | steps: 51 | - name: checkout 52 | uses: actions/checkout@v4 53 | 54 | - name: setup python 55 | uses: actions/setup-python@v4 56 | with: { python-version: '3.10' } 57 | - name: pip install 58 | run: python3 -m pip install oss2 59 | 60 | - name: download artifact 61 | uses: dawidd6/action-download-artifact@v2 62 | with: 63 | run_id: ${{ github.event.workflow_run.id }} 64 | name: help-site 65 | path: build 66 | 67 | - name: deploy site 68 | env: 69 | ALIOSS_AK: ${{ secrets.ALIOSS_AK }} 70 | ALIOSS_SK: ${{ secrets.ALIOSS_SK }} 71 | ALIOSS_BUCKET: ${{ vars.ALIOSS_BUCKET }} 72 | ALIOSS_ENDPOINT: ${{ vars.ALIOSS_ENDPOINT }} 73 | run: python3 .deploy.py -p open/ build 74 | -------------------------------------------------------------------------------- /docs/api/async-result.mdx: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar_position: 4 3 | --- 4 | 5 | import ApiSchema from '@theme/ApiSchema'; 6 | 7 | # 异步结果推送 8 | 9 | 对于异步请求,平台提供两种消息推送方案:WebSocket 模式和 HTTP callback 模式,OpenApp 可以自行在控制台配置。无论选择哪种模式获得的数据都是一致的。对于公网可以访问的 OpenApp,我们推荐使用 HTTP callback 模式,否则建议使用 WebSocket 模式。 10 | 11 | :::note 什么是异步 12 | 13 | 异步区别于同步,在调用一个 API 时,异步的请求尽管是成功的,但是只能拿到一个 ID,真正的结果不会立刻返回。 14 | 15 | 假设评测一道题目需要消耗 30 秒时间,如果同步返回的话,需要维持一个 30 秒的长 HTTP 连接,不确定因素很大。但是我们因此使用异步的方式:结果不会立刻返回,而是返回一个请求 ID。OpenApp 后续可以通过 ID 获取执行的结果。 16 | 17 | ::: 18 | 19 | 为了方便 OpenApp 识别消息相关的内容,所有异步请求在提交时都有一个字段: 20 | 21 | 22 | 23 | 平台会在异步操作完成时,将结果 POST 到 HTTP callback URL 或发送到相关的 WebSocket 频道,并附上 `trackId` 和 `requestId` 以方便用户区分结果对应的请求: 24 | 25 | 26 | 27 | :::tip 28 | 29 | 虽然异步请求都有结果查询的 API,但为了提高效率、减轻平台计算负担,我们推荐优先使用消息推送。尽管如此,消息推送的成功与否是不能保证的。因此在根据消息推送获得结果的同时,仍需对长时间未返回执行结果的请求调用结果查询接口来检查运行状态。 30 | 31 | ::: 32 | 33 | ## HTTP callback 模式 34 | 35 | 在控制台配置了 OpenApp 的 HTTP callback URL 之后,异步调用结果会通过 HTTP POST 发送到 OpenApp 设置的 callback URL。 36 | 37 | 为了保证结果的完整和可信,在 callback 时还会加入一个名为 `Luogu-API-Callback-Sign` 的 HTTP Header,这个 Header 值使用这样的规则计算:`base64_encode(sha256_hmac(trim('{HTTP Header Date}\r\n{HTTP Request Body}'), '{OpenApp Token}'))`。 38 | 39 | 假设接收这个 callback 的 OpenApp 的 token 为 `01gt8s4bnbesna15e9f6wvk5pn:w1MmbjBCsDYjXpgS`,那么对于下面这个 callback 请求: 40 | 41 | ``` 42 | POST /callback HTTP/1.1 43 | Date: Fri, 17 Mar 2023 06:34:25 GMT 44 | Luogu-API-Callback-Sign: dkY3sq6VvxAVtLnW/lpyP65pkYgwwrZTerLP+VJ/D8k= 45 | 46 | {"success":true} 47 | ``` 48 | 49 | 可以类似这样进行验证: 50 | 51 | ```php 52 | $token = '01gt8s4bnbesna15e9f6wvk5pn:w1MmbjBCsDYjXpgS'; 53 | $data = trim($_SERVER['HTTP_DATE']."\r\n".file_get_contents('php://input')); // 此时值为 "Fri, 17 Mar 2023 06:34:25 GMT\r\n{\"success\":true}" 54 | $sign = hash_hmac('sha256', $data, $token, true); 55 | $verified = $sign === base64_decode($_SERVER['HTTP_LUOGU_API_CALLBACK_SIGN']); 56 | ``` 57 | 58 | ## WebSocket 模式 59 | 60 | 对于公网无法直接访问的 OpenApp,可以选择 WebSocket 模式接收消息推送。 61 | 62 | 洛谷开放平台的 WebSocket 端点为 `wss://open-ws.lgapi.cn/ws?token=&channel=`,它的 query 参数解释如下: 63 | 64 | 65 | 66 | 平台进行消息推送时具有这样的结构:`"channel name" + "\x00" + "message"`,WebSocket Message 类型为 Text,如下图所示。 67 | 68 | ![WebSocket messages](image/ws-msg.png) 69 | 70 | 只要 WebSocket 连接成功即为鉴权成功,连接成功后服务器也会在 `AUTH_WELCOME` 频道(不需要订阅)发送一条消息。如果参数有误或 token 失效,会在连接建立之前以对应的 HTTP 状态码展示。 71 | 72 | :::note 73 | 74 | 每个 App 的连接数限制为 3,如果超过限制会导致较早打开的连接被踢出,服务器每隔 30 秒会发送一次 PING 帧以保持 TCP 连接活跃。 75 | 76 | ::: 77 | -------------------------------------------------------------------------------- /docs/judge/langs.md: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar_position: 3 3 | --- 4 | 5 | # 语言支持 6 | 7 | 洛谷的语言支持如无特别的编译器版本说明,均会随着时间而更新。 8 | 9 | 除 C/C++/Pascal 外的语言,由于常数时间差距,不保证正确算法的执行所用时间和内存能够通过评测而不超出限制。洛谷不为此类语言提供多余的时间和内存限制。 10 | 11 | 评测环境中定义环境变量 `ONLINE_JUDGE=luogu`,若编译器支持也会带上此常量或宏,可据此判断是否在评测环境。 12 | 13 | 评测机更新时间:2021-12-01,nixpkgs commit hash `57be0c5d9650a5c3970439ba7a1f4a017cd98cc0`。 14 | 15 | ## C/C++ 家族 16 | 17 | GCC 版本当前为 11.2.0。 18 | 19 | 所有 GCC 编译时均会带上 `-fPIC -fno-asm -lm -march=native` 参数。 20 | 21 | :::caution 注意 22 | 23 | 为了比赛等情况下的公平,在 C/C++ 代码的编译中,如果出现了通过 pragma 和 attribute 打开优化开关的行为是会导致编译失败的,详见[公告贴](https://www.luogu.com.cn/discuss/259685)。不限制使用评测机 CPU 支持的指令集。 24 | 25 | ::: 26 | 27 | | 类型 | 标识符 | 28 | |-----------------|--------------| 29 | | ISO C99 (GCC) | `c/99/gcc` | 30 | | ISO C++98 (GCC) | `cxx/98/gcc` | 31 | | ISO C++11 (GCC) | `cxx/11/gcc` | 32 | | ISO C++14 (GCC) | `cxx/14/gcc` | 33 | | ISO C++17 (GCC) | `cxx/17/gcc` | 34 | | ISO C++20 (GCC) | `cxx/20/gcc` | 35 | 36 | 另外,对于 NOI 系列的参赛环境,提供以下专门的编译类型: 37 | 38 | | 类型 | 标识符 | | 39 | |------------------------|------------------|-------------------------------------------------------------------| 40 | | ISO C++14 w/ GCC 9.3.0 | `cxx/noi/202107` | [NOI 官网通知](https://www.noi.cn/gynoi/jsgz/2021-07-16/732450.shtml) | 41 | 42 | ## Python 家族 43 | 44 | Python 家族提供 CPython(常用版本)和 PyPy 两种解释器。CPython 环境安装了 NumPy 库。 45 | 46 | Python 2 已于 2020 年被官方宣布寿终正寝,因此平台已不再提供支持。 47 | 48 | | 类型 | 标识符 | 49 | |--------------------|--------------| 50 | | Python 3 (CPython) | `python3/c` | 51 | | Python 3 (PyPy) | `python3/py` | 52 | 53 | ## Pascal 54 | 55 | Pascal 使用 Free Pascal 编译器,当前版本为 3.2.0。 56 | 57 | | 类型 | 标识符 | 58 | |--------|--------------| 59 | | Pascal | `pascal/fpc` | 60 | 61 | ## Rust 62 | 63 | Rust 提供 rustc 一种编译器,并使用 nightly 版本、Rust edition 为 2021。 64 | 65 | | 类型 | 标识符 | 66 | |----------------------|--------------| 67 | | Rust nightly (rustc) | `rust/rustc` | 68 | 69 | ## Haskell 70 | 71 | Haskell 提供 Glasgow Haskell Compiler(GHC)一种编译器。 72 | 73 | Haskell 环境安装了[官网](https://www.haskell.org/)所列举的核心包和常用包(见 Features-Packages 栏)。 74 | 75 | | 类型 | 标识符 | 76 | |---------------|---------------| 77 | | Haskell (GHC) | `haskell/ghc` | 78 | 79 | ## Go 80 | 81 | | 类型 | 标识符 | 82 | |-----|------| 83 | | Go | `go` | 84 | 85 | ## PHP 86 | 87 | | 类型 | 标识符 | 88 | |-----|-------| 89 | | PHP | `php` | 90 | 91 | ## Ruby 92 | 93 | | 类型 | 标识符 | 94 | |------|--------| 95 | | Ruby | `ruby` | 96 | 97 | ## JavaScript 98 | 99 | JavaScript 提供 Node.js 一种解释器。 100 | 101 | | 类型 | 标识符 | 102 | |-------------|---------------| 103 | | Node.js LTS | `js/node/lts` | 104 | 105 | ## Perl 106 | 107 | | 类型 | 标识符 | 108 | |------|--------| 109 | | Perl | `perl` | 110 | 111 | ## Java 112 | 113 | Java 使用 OpenJDK 编译。 114 | 115 | | 类型 | 标识符 | 116 | |--------|----------| 117 | | Java 8 | `java/8` | 118 | 119 | ## Kotlin 120 | 121 | Kotlin 语言提供 JVM 一种编译目标,且 JVM 版本为 1.8(会随着评测机更新)。 122 | 123 | | 类型 | 标识符 | 124 | |------------|--------------| 125 | | Kotlin/JVM | `kotlin/jvm` | 126 | 127 | ## Scala 128 | 129 | Scala 编译目标版本为 1.8(会随着评测机更新)。 130 | 131 | | 类型 | 标识符 | 132 | |-------|---------| 133 | | Scala | `scala` | 134 | -------------------------------------------------------------------------------- /openapi/_api.yaml: -------------------------------------------------------------------------------- 1 | openapi: 3.0.3 2 | 3 | info: 4 | title: 洛谷开放平台 API 5 | description: 使用洛谷开放平台,实现云端评测等功能。 6 | version: 1.0.0 7 | 8 | servers: 9 | - url: 'https://open-v1.lgapi.cn' 10 | 11 | components: 12 | securitySchemes: 13 | api: 14 | type: http 15 | scheme: basic 16 | schemas: 17 | AsyncRequestCommon: 18 | type: object 19 | properties: 20 | trackId: 21 | type: string 22 | maxLength: 64 23 | required: false 24 | description: 由 OpenApp 定义,这里的内容会原封不动地在结果中返回。 25 | 26 | AsyncResponseCommon: 27 | type: object 28 | properties: 29 | requestId: 30 | type: string 31 | description: Request ID, 用来查询请求结果 32 | example: 1BwHdxEa4LTFnL619bxRwC 33 | 34 | AsyncResultCommon: 35 | type: object 36 | properties: 37 | requestId: 38 | type: string 39 | description: 异步请求的 ID,在提交时返回给 OpenApp。 40 | example: 1BwHdxEa4LTFnL619bxRwC 41 | trackId: 42 | type: string 43 | description: 在提交请求时填写,会原样返回。 44 | 45 | GeneralErrorResponse: 46 | type: object 47 | properties: 48 | errorCode: 49 | type: integer 50 | description: 错误代码,与 HTTP Status 相同 51 | example: 400 52 | errorType: 53 | type: string 54 | description: 错误类型 55 | example: Lentille\SymfonyBundle\Exception\FormErrorException 56 | errorMessage: 57 | type: integer 58 | description: 错误信息 59 | example: Form is not valid. 60 | errorData: 61 | type: object 62 | description: 错误相关数据,根据 errorType 的不同而变化 63 | 64 | LentilleFormError: 65 | type: object 66 | properties: 67 | lentilleFormError: 68 | type: number 69 | enum: 70 | - 1 71 | description: 恒为 1,标识此为 LentilleFormError 72 | example: 1 73 | submitted: 74 | type: boolean 75 | description: 表单提交是否成功 76 | example: true 77 | valid: 78 | type: boolean 79 | description: 表单校验是否成功 80 | example: false 81 | fields: 82 | type: array 83 | description: 表单出错的字段 84 | items: 85 | properties: 86 | name: 87 | type: string 88 | description: 出错字段名 89 | example: lang 90 | value: 91 | type: string 92 | description: 出错字段值 93 | example: cxx 94 | message: 95 | type: string 96 | description: 出错字段信息 97 | example: cxx is not a valid language 98 | 99 | 100 | WebSocketQueryParam: 101 | type: object 102 | properties: 103 | token: 104 | type: string 105 | description: OpenApp Token 106 | example: 01gt8s4bnbesna15e9f6wvk5pn:w1MmbjBCsDYjXpgS 107 | channel: 108 | type: string 109 | description: 要订阅的频道列表,只有订阅了相应频道才会收到相应推送。多个频道以半角逗号分隔。 110 | example: judge.result,some-other-example-channel 111 | tags: 112 | - name: 评测 113 | description: 提交代码以使用洛谷题库评测 114 | - name: 查询 115 | description: 查询开放平台账户状态 116 | 117 | paths: 118 | /judge/problem: 119 | $ref: './judge.yaml#/paths/~1problem' 120 | /judge/result: 121 | $ref: './judge.yaml#/paths/~1result' 122 | /judge/quotaAvailable: 123 | $ref: './judge.yaml#/paths/~1quotaAvailable' 124 | -------------------------------------------------------------------------------- /.idea/codeStyles/Project.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 243 | -------------------------------------------------------------------------------- /openapi/judge.yaml: -------------------------------------------------------------------------------- 1 | openapi: 3.0.3 2 | info: ~ 3 | 4 | components: 5 | schemas: 6 | JudgeProblem: 7 | description: 使用洛谷题库评测代码 8 | type: object 9 | allOf: 10 | - type: object 11 | properties: 12 | pid: 13 | type: string 14 | description: 题目 PID 15 | example: P1001 16 | required: true 17 | - $ref: '#/components/schemas/JudgeRequestCommon' 18 | - $ref: './_api.yaml#/components/schemas/AsyncRequestCommon' 19 | 20 | JudgeRun: 21 | description: 使用洛谷评测机运行代码 22 | type: object 23 | allOf: 24 | - type: object 25 | properties: 26 | input: 27 | type: string 28 | maxLength: 7168 29 | required: true 30 | description: 标准输入内容 31 | - $ref: '#/components/schemas/JudgeRequestCommon' 32 | - $ref: './_api.yaml#/components/schemas/AsyncRequestCommon' 33 | 34 | JudgeRecord: 35 | description: 评测记录 36 | type: object 37 | properties: 38 | compile: 39 | nullable: true 40 | allOf: 41 | - $ref: '#/components/schemas/CompileResult' 42 | judge: 43 | description: 评测结果,如果为 null 则表示结果还没有生成。如果 status 为 Waiting 或 Judging,则评测还没完成。 44 | nullable: true 45 | type: object 46 | allOf: 47 | - $ref: '#/components/schemas/ScoringResult' 48 | - type: object 49 | properties: 50 | subtasks: 51 | description: 子任务结果列表 52 | type: array 53 | items: 54 | allOf: 55 | - $ref: '#/components/schemas/ScoringResult' 56 | - type: object 57 | properties: 58 | cases: 59 | description: 测试点结果列表 60 | type: array 61 | items: 62 | allOf: 63 | - $ref: '#/components/schemas/ScoringResult' 64 | - type: object 65 | properties: 66 | signal: 67 | description: 程序退出时的信号,非 0 一般为异常 68 | type: integer 69 | exitCode: 70 | description: 程序退出时的返回值,非 0 一般为非正常结束 71 | type: integer 72 | description: 73 | description: 对测试点结果的描述 74 | type: string 75 | nullable: true 76 | 77 | RunResult: 78 | description: 执行结果 79 | type: object 80 | properties: 81 | output: 82 | nullable: true 83 | description: 标准输出内容 84 | type: string 85 | result: 86 | nullable: true 87 | description: 执行信息,有此信息标识执行完成 88 | type: object 89 | properties: 90 | cpuTime: { type: integer } 91 | memory: { type: integer } 92 | exitCode: { type: integer } 93 | signal: { type: integer } 94 | excess: { type: integer, nullable: true } 95 | compile: 96 | nullable: true 97 | allOf: 98 | - $ref: '#/components/schemas/CompileResult' 99 | 100 | CompileResult: 101 | description: 编译结果 102 | type: object 103 | properties: 104 | success: 105 | description: 编译是否成功 106 | type: boolean 107 | message: 108 | description: 编译器返回信息 109 | type: string 110 | example: | 111 | /tmp/compiler_y2u2icgr/src: 在函数‘void dfs(int, int, char, int)’中: 112 | /tmp/compiler_y2u2icgr/src:28:16: 警告:数组下标类型为‘char’ [-Wchar-subscripts] 113 | move_to(psw[wy]); 114 | ^ 115 | opt2: 116 | description: 编译时是否打开 `O2`(或类似的)优化开关 117 | type: boolean 118 | 119 | ScoringResult: 120 | description: 计分结果,是评测结果、子任务结果、测试点结果的抽象。 121 | type: object 122 | properties: 123 | id: 124 | type: integer 125 | status: 126 | $ref: '#/components/schemas/JudgeStatus' 127 | score: 128 | type: integer 129 | description: 得分 130 | time: 131 | type: integer 132 | description: 运行时使用的时间(毫秒,ms) 133 | memory: 134 | type: integer 135 | description: 运行时使用的空间(内存,千字节,KiB) 136 | 137 | JudgeStatus: 138 | type: integer 139 | description: | 140 | 评测结果、子任务、测试点的状态。 141 | - 0, Waiting, 任务等待执行 142 | - 1, Judging, 评测中 143 | - 2, Compile Error, 编译失败 144 | - 3, Output Limit Exceeded, 输出超限 145 | - 4, Memory Limit Exceeded, 内存超限 146 | - 5, Time Limit Exceeded, 运行时间超限 147 | - 6, Wrong Answer, 答案错误 148 | - 7, Runtime Error, 运行时错误 149 | - 11, Invalid, 结果非法(一般是内部错误等,可以反馈) 150 | - 12, Accepted, 结果正确、评测通过 151 | - 14, Overall Unaccepted, 评测不通过(评测结果、子任务中使用,根据计分方式返回的评测失败) 152 | 153 | JudgeType: 154 | description: 评测执行类型 155 | type: string 156 | enum: 157 | - judge 158 | # - run 159 | 160 | JudgeCallback: 161 | description: | 162 | 评测接口执行结果 163 | 164 | 无论是主动请求结果 API 还是使用 HTTP callback 或 WebSocket 等消息通知渠道获取结果,其值均遵守此结构。 165 | type: object 166 | allOf: 167 | - type: object 168 | properties: 169 | type: 170 | $ref: '#/components/schemas/JudgeType' 171 | data: 172 | $ref: '#/components/schemas/JudgeRecord' 173 | - $ref: '_api.yaml#/components/schemas/AsyncResultCommon' 174 | 175 | JudgeRequestCommon: 176 | type: object 177 | properties: 178 | lang: 179 | type: string 180 | description: 代码语言,见语言支持列表 181 | example: cxx/14/gcc 182 | required: true 183 | o2: 184 | type: boolean 185 | description: | 186 | 打开 `-O2`(或类似的)编译优化开关 187 | 188 | 但不一定真的会开,受到题目限制,即使这里传入 false 也可能是打开的,反之亦然。 189 | 190 | 到底有无使用 O2 编译优化需要查询编译结果中的返回。 191 | required: true 192 | code: 193 | type: string 194 | description: 要评测的代码 195 | required: true 196 | example: | 197 | #include 198 | int main() { 199 | int a,b; 200 | scanf("%d%d",&a,&b); 201 | printf("%d\n", a+b); 202 | return 0; 203 | } 204 | 205 | paths: 206 | /problem: 207 | post: 208 | summary: 提交题库评测 209 | description: | 210 | 提交代码,洛谷将使用洛谷题库测试数据和评测资源对代码的正确性进行评判。 211 | 212 | 这是异步请求,执行结果关联的 WebSocket 通知频道为 `judge.result`。 213 | tags: [ 评测 ] 214 | requestBody: 215 | content: 216 | application/json: 217 | schema: 218 | $ref: '#/components/schemas/JudgeProblem' 219 | responses: 220 | '200': 221 | description: 提交成功 222 | content: 223 | application/json: 224 | schema: 225 | $ref: '_api.yaml#/components/schemas/AsyncResponseCommon' 226 | '402': 227 | description: 额度不足,没有足够的配额来完成请求,需要充值 228 | 229 | /run: 230 | post: 231 | summary: 提交题库评测 232 | description: | 233 | 提交代码,使用洛谷评测机资源运行程序。 234 | 235 | 这是异步请求,执行结果关联的 WebSocket 通知频道为 `judge.result`。 236 | tags: [ 评测 ] 237 | requestBody: 238 | content: 239 | application/json: 240 | schema: 241 | $ref: '#/components/schemas/JudgeRun' 242 | responses: 243 | '200': 244 | description: 提交成功 245 | content: 246 | application/json: 247 | schema: 248 | $ref: '_api.yaml#/components/schemas/AsyncResponseCommon' 249 | '402': 250 | description: 额度不足,没有足够的配额来完成请求,需要充值 251 | 252 | /result: 253 | get: 254 | summary: 查询评测结果 255 | description: | 256 | 使用提交评测时获得的 Request ID 查询评测结果。评测结果只会缓存 1 小时,如果使用轮询获取结果请及时查询。 257 | tags: [ 评测 ] 258 | parameters: 259 | - 260 | name: id 261 | in: path 262 | description: Request ID, 于提交时获得 263 | required: true 264 | example: 1BwHdxEa4LTFnL619bxRwC 265 | schema: 266 | type: string 267 | responses: 268 | '200': 269 | description: 评测已经完成或已有部分评测结果,返回评测结果 270 | content: 271 | application/json: 272 | schema: 273 | $ref: '#/components/schemas/JudgeCallback' 274 | '204': 275 | description: 评测尚未完成,还没有任何结果产生 276 | 277 | /quotaAvailable: 278 | get: 279 | summary: 查询账户评测可用计费点 280 | description: 查询当前账户的评测可用计费点情况 281 | tags: [ 查询, 评测 ] 282 | responses: 283 | '200': 284 | description: 查询成功 285 | content: 286 | application/json: 287 | schema: 288 | type: object 289 | properties: 290 | quotas: 291 | type: array 292 | description: 可用计费点列表 293 | items: 294 | type: object 295 | properties: 296 | availablePoints: 297 | type: integer 298 | description: 可用计费点 299 | example: 30000 300 | createTime: 301 | type: integer 302 | description: 计费点创建时间 303 | format: int64 304 | example: 1697620471 305 | validAfter: 306 | type: integer 307 | description: 计费点生效时间 308 | format: int64 309 | example: 1713542400 310 | expireTime: 311 | type: integer 312 | description: 计费点过期时间 313 | format: int64 314 | example: 1721491199 315 | points: 316 | type: object 317 | description: 计费套餐详情 318 | properties: 319 | max: 320 | type: integer 321 | description: 套餐最大计费点 322 | example: 30000 323 | used: 324 | type: integer 325 | description: 已使用计费点 326 | example: 0 327 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International 2 | 3 | Creative Commons Corporation ("Creative Commons") is not a law firm and does not provide legal services or legal advice. Distribution of Creative Commons public licenses does not create a lawyer-client or other relationship. Creative Commons makes its licenses and related information available on an "as-is" basis. Creative Commons gives no warranties regarding its licenses, any material licensed under their terms and conditions, or any related information. Creative Commons disclaims all liability for damages resulting from their use to the fullest extent possible. 4 | 5 | Using Creative Commons Public Licenses 6 | 7 | Creative Commons public licenses provide a standard set of terms and conditions that creators and other rights holders may use to share original works of authorship and other material subject to copyright and certain other rights specified in the public license below. The following considerations are for informational purposes only, are not exhaustive, and do not form part of our licenses. 8 | 9 | Considerations for licensors: Our public licenses are intended for use by those authorized to give the public permission to use material in ways otherwise restricted by copyright and certain other rights. Our licenses are irrevocable. Licensors should read and understand the terms and conditions of the license they choose before applying it. Licensors should also secure all rights necessary before applying our licenses so that the public can reuse the material as expected. Licensors should clearly mark any material not subject to the license. This includes other CC-licensed material, or material used under an exception or limitation to copyright. More considerations for licensors : wiki.creativecommons.org/Considerations_for_licensors 10 | 11 | Considerations for the public: By using one of our public licenses, a licensor grants the public permission to use the licensed material under specified terms and conditions. If the licensor's permission is not necessary for any reason–for example, because of any applicable exception or limitation to copyright–then that use is not regulated by the license. Our licenses grant only permissions under copyright and certain other rights that a licensor has authority to grant. Use of the licensed material may still be restricted for other reasons, including because others have copyright or other rights in the material. A licensor may make special requests, such as asking that all changes be marked or described. Although not required by our licenses, you are encouraged to respect those requests where reasonable. More considerations for the public : wiki.creativecommons.org/Considerations_for_licensees 12 | 13 | Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International Public License 14 | 15 | By exercising the Licensed Rights (defined below), You accept and agree to be bound by the terms and conditions of this Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International Public License ("Public License"). To the extent this Public License may be interpreted as a contract, You are granted the Licensed Rights in consideration of Your acceptance of these terms and conditions, and the Licensor grants You such rights in consideration of benefits the Licensor receives from making the Licensed Material available under these terms and conditions. 16 | 17 | Section 1 – Definitions. 18 | 19 | a. Adapted Material means material subject to Copyright and Similar Rights that is derived from or based upon the Licensed Material and in which the Licensed Material is translated, altered, arranged, transformed, or otherwise modified in a manner requiring permission under the Copyright and Similar Rights held by the Licensor. For purposes of this Public License, where the Licensed Material is a musical work, performance, or sound recording, Adapted Material is always produced where the Licensed Material is synched in timed relation with a moving image. 20 | b. Copyright and Similar Rights means copyright and/or similar rights closely related to copyright including, without limitation, performance, broadcast, sound recording, and Sui Generis Database Rights, without regard to how the rights are labeled or categorized. For purposes of this Public License, the rights specified in Section 2(b)(1)-(2) are not Copyright and Similar Rights. 21 | c. Effective Technological Measures means those measures that, in the absence of proper authority, may not be circumvented under laws fulfilling obligations under Article 11 of the WIPO Copyright Treaty adopted on December 20, 1996, and/or similar international agreements. 22 | d. Exceptions and Limitations means fair use, fair dealing, and/or any other exception or limitation to Copyright and Similar Rights that applies to Your use of the Licensed Material. 23 | e. Licensed Material means the artistic or literary work, database, or other material to which the Licensor applied this Public License. 24 | f. Licensed Rights means the rights granted to You subject to the terms and conditions of this Public License, which are limited to all Copyright and Similar Rights that apply to Your use of the Licensed Material and that the Licensor has authority to license. 25 | g. Licensor means the individual(s) or entity(ies) granting rights under this Public License. 26 | h. NonCommercial means not primarily intended for or directed towards commercial advantage or monetary compensation. For purposes of this Public License, the exchange of the Licensed Material for other material subject to Copyright and Similar Rights by digital file-sharing or similar means is NonCommercial provided there is no payment of monetary compensation in connection with the exchange. 27 | i. Share means to provide material to the public by any means or process that requires permission under the Licensed Rights, such as reproduction, public display, public performance, distribution, dissemination, communication, or importation, and to make material available to the public including in ways that members of the public may access the material from a place and at a time individually chosen by them. 28 | j. Sui Generis Database Rights means rights other than copyright resulting from Directive 96/9/EC of the European Parliament and of the Council of 11 March 1996 on the legal protection of databases, as amended and/or succeeded, as well as other essentially equivalent rights anywhere in the world. 29 | k. You means the individual or entity exercising the Licensed Rights under this Public License. Your has a corresponding meaning. 30 | Section 2 – Scope. 31 | 32 | a. License grant. 33 | 1. Subject to the terms and conditions of this Public License, the Licensor hereby grants You a worldwide, royalty-free, non-sublicensable, non-exclusive, irrevocable license to exercise the Licensed Rights in the Licensed Material to: 34 | A. reproduce and Share the Licensed Material, in whole or in part, for NonCommercial purposes only; and 35 | B. produce and reproduce, but not Share, Adapted Material for NonCommercial purposes only. 36 | 2. Exceptions and Limitations. For the avoidance of doubt, where Exceptions and Limitations apply to Your use, this Public License does not apply, and You do not need to comply with its terms and conditions. 37 | 3. Term. The term of this Public License is specified in Section 6(a). 38 | 4. Media and formats; technical modifications allowed. The Licensor authorizes You to exercise the Licensed Rights in all media and formats whether now known or hereafter created, and to make technical modifications necessary to do so. The Licensor waives and/or agrees not to assert any right or authority to forbid You from making technical modifications necessary to exercise the Licensed Rights, including technical modifications necessary to circumvent Effective Technological Measures. For purposes of this Public License, simply making modifications authorized by this Section 2(a)(4) never produces Adapted Material. 39 | 5. Downstream recipients. 40 | A. Offer from the Licensor – Licensed Material. Every recipient of the Licensed Material automatically receives an offer from the Licensor to exercise the Licensed Rights under the terms and conditions of this Public License. 41 | B. No downstream restrictions. You may not offer or impose any additional or different terms or conditions on, or apply any Effective Technological Measures to, the Licensed Material if doing so restricts exercise of the Licensed Rights by any recipient of the Licensed Material. 42 | 6. No endorsement. Nothing in this Public License constitutes or may be construed as permission to assert or imply that You are, or that Your use of the Licensed Material is, connected with, or sponsored, endorsed, or granted official status by, the Licensor or others designated to receive attribution as provided in Section 3(a)(1)(A)(i). 43 | b. Other rights. 44 | 1. Moral rights, such as the right of integrity, are not licensed under this Public License, nor are publicity, privacy, and/or other similar personality rights; however, to the extent possible, the Licensor waives and/or agrees not to assert any such rights held by the Licensor to the limited extent necessary to allow You to exercise the Licensed Rights, but not otherwise. 45 | 2. Patent and trademark rights are not licensed under this Public License. 46 | 3. To the extent possible, the Licensor waives any right to collect royalties from You for the exercise of the Licensed Rights, whether directly or through a collecting society under any voluntary or waivable statutory or compulsory licensing scheme. In all other cases the Licensor expressly reserves any right to collect such royalties, including when the Licensed Material is used other than for NonCommercial purposes. 47 | Section 3 – License Conditions. 48 | 49 | Your exercise of the Licensed Rights is expressly made subject to the following conditions. 50 | 51 | a. Attribution. 52 | 1. If You Share the Licensed Material, You must: 53 | A. retain the following if it is supplied by the Licensor with the Licensed Material: 54 | i. identification of the creator(s) of the Licensed Material and any others designated to receive attribution, in any reasonable manner requested by the Licensor (including by pseudonym if designated); 55 | ii. a copyright notice; 56 | iii. a notice that refers to this Public License; 57 | iv. a notice that refers to the disclaimer of warranties; 58 | v. a URI or hyperlink to the Licensed Material to the extent reasonably practicable; 59 | B. indicate if You modified the Licensed Material and retain an indication of any previous modifications; and 60 | C. indicate the Licensed Material is licensed under this Public License, and include the text of, or the URI or hyperlink to, this Public License. 61 | For the avoidance of doubt, You do not have permission under this Public License to Share Adapted Material. 62 | 63 | 2. You may satisfy the conditions in Section 3(a)(1) in any reasonable manner based on the medium, means, and context in which You Share the Licensed Material. For example, it may be reasonable to satisfy the conditions by providing a URI or hyperlink to a resource that includes the required information. 64 | 3. If requested by the Licensor, You must remove any of the information required by Section 3(a)(1)(A) to the extent reasonably practicable. 65 | Section 4 – Sui Generis Database Rights. 66 | 67 | Where the Licensed Rights include Sui Generis Database Rights that apply to Your use of the Licensed Material: 68 | 69 | a. for the avoidance of doubt, Section 2(a)(1) grants You the right to extract, reuse, reproduce, and Share all or a substantial portion of the contents of the database for NonCommercial purposes only and provided You do not Share Adapted Material; 70 | b. if You include all or a substantial portion of the database contents in a database in which You have Sui Generis Database Rights, then the database in which You have Sui Generis Database Rights (but not its individual contents) is Adapted Material; and 71 | c. You must comply with the conditions in Section 3(a) if You Share all or a substantial portion of the contents of the database. 72 | For the avoidance of doubt, this Section 4 supplements and does not replace Your obligations under this Public License where the Licensed Rights include other Copyright and Similar Rights. 73 | 74 | Section 5 – Disclaimer of Warranties and Limitation of Liability. 75 | 76 | a. Unless otherwise separately undertaken by the Licensor, to the extent possible, the Licensor offers the Licensed Material as-is and as-available, and makes no representations or warranties of any kind concerning the Licensed Material, whether express, implied, statutory, or other. This includes, without limitation, warranties of title, merchantability, fitness for a particular purpose, non-infringement, absence of latent or other defects, accuracy, or the presence or absence of errors, whether or not known or discoverable. Where disclaimers of warranties are not allowed in full or in part, this disclaimer may not apply to You. 77 | b. To the extent possible, in no event will the Licensor be liable to You on any legal theory (including, without limitation, negligence) or otherwise for any direct, special, indirect, incidental, consequential, punitive, exemplary, or other losses, costs, expenses, or damages arising out of this Public License or use of the Licensed Material, even if the Licensor has been advised of the possibility of such losses, costs, expenses, or damages. Where a limitation of liability is not allowed in full or in part, this limitation may not apply to You. 78 | c. The disclaimer of warranties and limitation of liability provided above shall be interpreted in a manner that, to the extent possible, most closely approximates an absolute disclaimer and waiver of all liability. 79 | Section 6 – Term and Termination. 80 | 81 | a. This Public License applies for the term of the Copyright and Similar Rights licensed here. However, if You fail to comply with this Public License, then Your rights under this Public License terminate automatically. 82 | b. Where Your right to use the Licensed Material has terminated under Section 6(a), it reinstates: 83 | 1. automatically as of the date the violation is cured, provided it is cured within 30 days of Your discovery of the violation; or 84 | 2. upon express reinstatement by the Licensor. 85 | For the avoidance of doubt, this Section 6(b) does not affect any right the Licensor may have to seek remedies for Your violations of this Public License. 86 | 87 | c. For the avoidance of doubt, the Licensor may also offer the Licensed Material under separate terms or conditions or stop distributing the Licensed Material at any time; however, doing so will not terminate this Public License. 88 | d. Sections 1, 5, 6, 7, and 8 survive termination of this Public License. 89 | Section 7 – Other Terms and Conditions. 90 | 91 | a. The Licensor shall not be bound by any additional or different terms or conditions communicated by You unless expressly agreed. 92 | b. Any arrangements, understandings, or agreements regarding the Licensed Material not stated herein are separate from and independent of the terms and conditions of this Public License. 93 | Section 8 – Interpretation. 94 | 95 | a. For the avoidance of doubt, this Public License does not, and shall not be interpreted to, reduce, limit, restrict, or impose conditions on any use of the Licensed Material that could lawfully be made without permission under this Public License. 96 | b. To the extent possible, if any provision of this Public License is deemed unenforceable, it shall be automatically reformed to the minimum extent necessary to make it enforceable. If the provision cannot be reformed, it shall be severed from this Public License without affecting the enforceability of the remaining terms and conditions. 97 | c. No term or condition of this Public License will be waived and no failure to comply consented to unless expressly agreed to by the Licensor. 98 | d. Nothing in this Public License constitutes or may be interpreted as a limitation upon, or waiver of, any privileges and immunities that apply to the Licensor or You, including from the legal processes of any jurisdiction or authority. 99 | Creative Commons is not a party to its public licenses. Notwithstanding, Creative Commons may elect to apply one of its public licenses to material it publishes and in those instances will be considered the "Licensor." The text of the Creative Commons public licenses is dedicated to the public domain under the CC0 Public Domain Dedication. Except for the limited purpose of indicating that material is shared under a Creative Commons public license or as otherwise permitted by the Creative Commons policies published at creativecommons.org/policies, Creative Commons does not authorize the use of the trademark "Creative Commons" or any other trademark or logo of Creative Commons without its prior written consent including, without limitation, in connection with any unauthorized modifications to any of its public licenses or any other arrangements, understandings, or agreements concerning use of licensed material. For the avoidance of doubt, this paragraph does not form part of the public licenses. 100 | 101 | Creative Commons may be contacted at creativecommons.org. 102 | --------------------------------------------------------------------------------