240 |
241 |
242 |
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 |
--------------------------------------------------------------------------------