跳到主要内容

洛谷开放平台 API (1.0.0)

Download OpenAPI specification:Download

使用洛谷开放平台,实现云端评测等功能。

评测

提交代码以使用洛谷题库评测

提交题库评测

提交代码,洛谷将使用洛谷题库测试数据和评测资源对代码的正确性进行评判。

这是异步请求,执行结果关联的 WebSocket 通知频道为 judge.result

Request Body schema: application/json
pid
string

题目 PID

lang
string

代码语言,见语言支持列表

o2
boolean

打开 -O2(或类似的)编译优化开关

但不一定真的会开,受到题目限制,即使这里传入 false 也可能是打开的,反之亦然。

到底有无使用 O2 编译优化需要查询编译结果中的返回。

code
string

要评测的代码

trackId
string <= 64 characters

由 OpenApp 定义,这里的内容会原封不动地在结果中返回。

Responses

Request samples

Content type
application/json
{
  • "pid": "P1001",
  • "lang": "cxx/14/gcc",
  • "o2": true,
  • "code": "#include <stdio.h>\nint main() {\n int a,b;\n scanf(\"%d%d\",&a,&b);\n printf(\"%d\\n\", a+b);\n return 0;\n}\n",
  • "trackId": "string"
}

Response samples

Content type
application/json
{
  • "requestId": "1BwHdxEa4LTFnL619bxRwC"
}

查询评测结果

使用提交评测时获得的 Request ID 查询评测结果。评测结果只会缓存 1 小时,如果使用轮询获取结果请及时查询。

path Parameters
id
required
string
Example: 1BwHdxEa4LTFnL619bxRwC

Request ID, 于提交时获得

Responses

Response samples

Content type
application/json
{
  • "type": "judge",
  • "data": {
    },
  • "requestId": "1BwHdxEa4LTFnL619bxRwC",
  • "trackId": "string"
}

查询账户评测可用计费点

查询当前账户的评测可用计费点情况

Responses

Response samples

Content type
application/json
{
  • "quotas": [
    ]
}

查询

查询开放平台账户状态

查询账户评测可用计费点

查询当前账户的评测可用计费点情况

Responses

Response samples

Content type
application/json
{
  • "quotas": [
    ]
}