标题
增加 1 行删除 1 行
1CNOI风格题面生成汇总以及对fuzzy的超级改进1CNOI风格题面新速通,制作效率倍增!(附带主流方式汇总)
正文
增加 609 行删除 39 行
2 行未改动34567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162633 行未改动6768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171182 行未改动下面会对主流的几种生成方式进行总结和评价:## [Typora 主题](https://www.luogu.com.cn/article/bc382rd4)方式:采取使用建立 Typora 的 cnoi 主题风格的模板并且进行生成。[perm](https://www.luogu.com.cn/problem/U674531)优点:生成方式简单易上手。缺点:没有代码行号和页眉,表格有些 bug。总结就是缺少灵魂。## [tuack](https://gitee.com/mulab/oi_tools)方式:在 python 环境下进行生成。优点:+ CCF和Thu的所有题面均使用上面的项目进行生成。+ 可以进行更专业的出题,例如在部分分检测上。+ 支持多种风格题面。+ 可以自行对部分内容和源码进行更改。缺点:+ 过于复杂,不易上手,初次尝试容易出现 bug。+ 对 markdown 下的部分语法支持不太好。+ 需要安装和配置XeLaTeX,内存占用过大。好像有了 tuack-ng,好像对 tuack 进行了重构,人性化了一些。## [CNOI Statement Generator](https://www.luogu.com.cn/article/q7mrgqf9)方式:在里面直接使用 markdown 原生语法即可,**大家不要忘了改页边距为2.2!!!!!**优点:+ 简单超级容易上手。+ 网页版内存占用小。+ 可以和写题解的同时在网站上完成。缺点:+ 网页版的只能手动来展示后续样例,无法调用 typst 内置函数。+ 网页版的自由性较弱,无法进行更改。## [fuzzy](https://github.com/Wallbreaker5th/fuzzy-cnoi-statement)方式:使用 typst 进行生成,**需要提前下好字体**。优点:+ 自由性强,可以自由更改。+ 支持大量typst源生内容。+ 可以批量设置样例。::::success[code]```typ#for (i,case) in range(3, 6).zip(($3tilde 4$,$5 tilde 6$,3 行未改动这个样例满足测试点 #case 的条件限制。]}```::::+ 格式较为仿真。缺点:+ 对 latex 的兼容性较差,网络对typst的教程较小。改进方法:在代码的第一行引入[mitex](https://github.com/mitex-rs/mitex):`#import "@preview/mitex:0.2.5": *;`- 表格生成方式比较困难,~~且好像无代替方式。~~+ 二级缩进和三级缩进有问题,而且好像无法更改!# 对fuzzy的使用进行进一步介绍目前对fuzzy的具体使用过程还是介绍比较少的。## 步骤1:下载相关字体- Consolas- New Computer Modern- 方正书宋(FZShuSong-Z01S)- 方正黑体(FZHei-B01S)- 方正仿宋(FZFangSong-Z02S)- 方正楷体(FZKai-Z03S)- Fira Mono (APIO以后使用的新字体)其中方正字体大家请到方正的官网下载,其余的在互联网很轻松的就能找到。具体传入计算机的过程大家可以上网搜索,随便就能找到。## 步骤2:配置typst相关环境下载插件 [Tinymist Typst](https://marketplace.visualstudio.com/items?itemName=myriad-dreamin.tinymist)。下载插件 [vscode-pdf](https://marketplace.visualstudio.com/items?itemName=tomoki1207.pdf)。在 VScode 商店搜索即可。# 重磅改进与新模板2 行未改动3456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566673 行未改动71727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876882 行未改动下面会对主流的几种生成方式进行总结和评价:## [Typora 主题](https://www.luogu.com.cn/article/bc382rd4)方式:采取使用建立 Typora 的 cnoi 主题风格的模板并且进行生成。[perm](https://www.luogu.com.cn/problem/U674531)优点:生成方式简单易上手。缺点:没有代码行号和页眉,表格有些 bug。总结就是缺少灵魂。## [tuack](https://gitee.com/mulab/oi_tools)方式:在 python 环境下进行生成。优点:- CCF 和 Thu 的所有题面均使用上面的项目进行生成。- 可以进行更专业的出题,例如在部分分检测上。- 支持多种风格题面。- 可以自行对部分内容和源码进行更改。缺点:- 过于复杂,不易上手,初次尝试容易出现 bug。- 对 markdown 下的部分语法支持不太好。- 需要安装和配置 XeLaTeX,内存占用过大。好像有了 tuack-ng,好像对 tuack 进行了重构,人性化了一些。## [CNOI Statement Generator](https://www.luogu.com.cn/article/q7mrgqf9)方式:在里面直接使用 markdown 原生语法即可,**大家不要忘了改页边距为 2.2!!!!!**优点:- 简单超级容易上手。- 网页版内存占用小。- 可以和写题解的同时在网站上完成。缺点:- 网页版的只能手动来展示后续样例,无法调用 typst 内置函数。- 网页版的自由性较弱,无法进行更改。## [fuzzy](https://github.com/Wallbreaker5th/fuzzy-cnoi-statement)方式:使用 typst 进行生成,**需要提前下好字体**。作者: [破壁人五号](https://www.luogu.com.cn/user/37676)优点:- 自由性强,可以自由更改。- 支持大量 typst 源生内容。- 可以批量设置样例。:::success[code]```typ#for (i,case) in range(3, 6).zip(($3tilde 4$,$5 tilde 6$,3 行未改动这个样例满足测试点 #case 的条件限制。]}```:::- 格式较为仿真。缺点:- 对 latex 的兼容性较差,网络对 typst 的教程较小。改进方法:在代码的第一行引入 [mitex](https://github.com/mitex-rs/mitex):`#import "@preview/mitex:0.2.5": *;`* 表格生成方式比较困难,~~且好像无代替方式。~~- 二级缩进和三级缩进有问题,而且好像无法更改!# 对 fuzzy 的使用进行进一步介绍目前对 fuzzy 的具体使用过程还是介绍比较少的。## 步骤 1:下载相关字体- Consolas- New Computer Modern- 方正书宋(FZShuSong-Z01S)- 方正黑体(FZHei-B01S)- 方正仿宋(FZFangSong-Z02S)- 方正楷体(FZKai-Z03S)- Fira Mono (APIO 以后使用的新字体)其中方正字体大家请到方正的官网下载,其余的在互联网很轻松的就能找到。具体传入计算机的过程大家可以上网搜索,随便就能找到。## 步骤 2:配置 typst 相关环境下载插件 [Tinymist Typst](https://marketplace.visualstudio.com/items?itemName=myriad-dreamin.tinymist)。下载插件 [vscode-pdf](https://marketplace.visualstudio.com/items?itemName=tomoki1207.pdf)。在 VScode 商店搜索即可。# 重磅改进与新模板首先新建一个文件夹,然后将下面题目中的文件下载并且打开:[点击下载](https://www.luogu.com.cn/problem/U689089)里面有一个是我生成的,还有一个是原作者的那个使用介绍。然后里面会有一个 **m.typ**,然后打开里面。然后你会发现这个代码会报错完了,不要怕!!!右击第一行的 fuzzy 的转到引用,然后把代码全部注释掉,换成下面的这个::::success[code]```cpp// Typst template for making NOI-like problems// Author: Wallbreaker5th,Eclatara// MIT-0 License#import "@preview/codelst:2.0.2": sourcecode#import "@preview/tablem:0.3.0": tablem, three-line-table#let 字号 = (初号: 42pt,小初: 36pt,一号: 26pt,小一: 24pt,二号: 22pt,小二: 18pt,三号: 16pt,小三: 15pt,四号: 14pt,中四: 13pt,小四: 12pt,五号: 10.5pt,小五: 9pt,六号: 7.5pt,小六: 6.5pt,七号: 5.5pt,小七: 5pt,)#let default-fonts = (mono: "Fira Mono",// mono: "Consolas",serif: "New Computer Modern",cjk-serif: "FZShuSong-Z01S",cjk-sans: "FZHei-B01S",cjk-mono: "FZFangSong-Z02S",cjk-italic: "FZKai-Z03S",)#let empty-par = {par()[#v(0em, weak: true)#h(0em)]}#let add-empty-par(it) = {itempty-par}#let default-problem-fullname(problem) = {if (problem.at("name", default: none) != none) {problem.nameif (problem.at("name-en", default: none) != none) {"(" + problem.name-en + ")"}} else {problem.at("name-en", default: "")}}#let default-header(contest-info, current-problem) = {set par(first-line-indent: 0em)if (current-problem == none) {return}set text(size: 字号.五号)contest-info.nameh(1fr)let round = contest-info.at("round", default: none)if (round != none) {round + " "}default-problem-fullname(current-problem)v(-2pt)line(length: 100%, stroke: 0.3pt)}#let default-footer(contest-info, current-problem) = {if (current-problem == none) {return}set text(size: 字号.五号)align(center,{[第]counter(page).display()[页]h(2em)[共]context{let cnt = counter(page).final().at(0)link((page:cnt, x:0pt, y:0pt), text(fill: rgb("#00f"), [#cnt]))}[页]})}#let make-formula(s) = {let numbers = s.matches(regex("[\d.]+"))let last-end = 0for n in numbers {let start = n.startlet end = n.endlet number = n.texts.slice(last-end, start)math.equation(number)last-end = end}s.slice(last-end, s.len())}#let three-line-table = tablem.with(render: (columns: auto, align: center, ..args) => {table(columns: columns,stroke: none,align: center + horizon,table.hline(y: 0),table.hline(y: 1, stroke: .5pt),..args,table.hline(),)})#let data-constraints-table-args = {(stroke: (x, y) => (left: if (x > 0) { .4pt },bottom: 2pt,top: if(y == 0) { 2pt } else if (y == 1) { 1.2pt } else { .4pt }),align: center+horizon,)}#let current-problem-idx = counter("current-problem-idx")#let statement-page-begin = state("statement-page-begin", false)#let document-class(contest-info,problem-list,custom-fonts: (:),header: default-header,footer: default-footer,) = {let fonts = default-fonts + custom-fontslet get-current-problem(here) = {let idx = current-problem-idx.at(here).at(0) - 1if (idx >= 0) { problem-list.at(idx) }}let init(it) = {set text(font: ((name: fonts.serif,covers: "latin-in-cjk"), fonts.cjk-serif), size: 字号.小四, lang: "zh", region: "CN")show emph: set text(font: ((name: fonts.serif,covers: "latin-in-cjk"), fonts.cjk-italic))show strong: st => { // Dotted strong textset text(font: ((name: fonts.serif,covers: "latin-in-cjk"), fonts.cjk-sans))show regex("\p{sc=Hani}+"): s => {underline(s, offset: 3pt, stroke: (cap: "round",thickness: 0.1em,dash: (array: (0em, 1em), phase: 0.5em)))}st}show raw: set text(font: ((name: fonts.mono,covers: "latin-in-cjk"), fonts.cjk-mono), size: 字号.小四)set list(indent: 1.75em, marker: ([•], [#h(-1em)•]))set enum(indent: 1.75em,numbering: x => {grid(columns: (0em, auto),align: bottom,hide[悲], numbering("1.", x)) // As a workaround})show heading: set text(font: ((name: fonts.serif,covers: "latin-in-cjk"),fonts.cjk-sans), weight: 500)show heading.where(level: 1): it => {set text(size: 字号.小二)set heading(bookmarked: true)pad(top: 8pt, align(center, it))}show heading.where(level: 2): it => {v(-8pt)set text(size: 字号.小四)set heading(bookmarked: true)pad(left: 1.5em, top: 1em, bottom: .5em, [【]+box(it)+[】])}show raw.where(block: true): it => {show raw.line: line => {if (line.text == "" and line.number == line.count) {return []}box(grid(columns: (0em, 1fr),align: (right, left),move(text(str(line.number), fill: gray, size: 0.8em),dx: -1em,dy: 0.1em,),line.body))}block(width: 100%,inset: (left: 0.5em, right: 0.5em, top: 0.7em, bottom: 0.7em),stroke: 0.5pt + rgb("#00f"),breakable: true,{set par(first-line-indent: 0em)it})}// show raw.where(block: true): it => {// show raw.line: it => {// if (it.text == "" and it.number == it.count) {// return// }// box(// grid(// columns: (0em, 1fr),// align: (right, left),// move(// text(str(it.number), fill: gray, size: 0.8em),// dx: -1em,// dy: 0.1em,// ),// it.body// )// )// }// pad(// rect(it, stroke: 0.5pt + rgb("#00f"), width: 100%, inset: (y: 0.7em)),// left: 0.5em// )// }// Page Layoutset page(margin: 2.2cm,header: context header(contest-info, get-current-problem(here())),footer: context if(statement-page-begin.at(here())) {footer(contest-info, get-current-problem(here()))},)show table: pad.with(y: .5em)set par(first-line-indent: (amount: 2em, all: true), leading: 0.7em)// Looks right but I'm not sure about the exact valueset par(spacing: 0.6em)it}let title() = {align(center, {text(contest-info.name, size: 字号.二号, font: ((name: fonts.serif,covers: "latin-in-cjk"), fonts.cjk-sans))parbreak()v(10pt)let name-en = contest-info.at("name-en", default: none)if (name-en != none) {text(name-en, size: 字号.小一)parbreak()v(10pt)}let round = contest-info.at("round", default: none)if (round != none) {emph(text(round, size: 字号.二号))parbreak()}let author = contest-info.at("author", default: none)if (author != none) {text(author, size: 字号.小三, font: ((name: fonts.serif,covers: "latin-in-cjk"), fonts.cjk-sans))parbreak()v(5pt)}let time = contest-info.at("time", default: none)if (time != none) {text(time, size: 字号.小三, font: ((name: fonts.serif,covers: "latin-in-cjk"), fonts.cjk-sans))}})}let problem-table(extra-rows: (:),languages: (("C++", "cpp"),),compile-options: (("C++", "-O2 -std=c++14 -static"),),) = {let default-row = (wrap: text,always-display: false,default: "无",)let rows = (name: (name: "题目名称",always-display: true,),type: (name: "题目类型",always-display: true,default: "传统型",),name-en: (name: "目录",wrap: raw,always-display: true,),executable: (name: "可执行文件名",wrap: raw,always-display: true,default: x => x.name-en,),input: (name: "输入文件名",wrap: raw,always-display: true,default: x => x.name-en + ".in",),output: (name: "输出文件名",wrap: raw,always-display: true,default: x => x.name-en + ".out",),time-limit: (name: "每个测试点时限",wrap: make-formula,),memory-limit: (name: "内存限制",wrap: make-formula,),test-case-count: (name: "测试点数目",default: "10",wrap: make-formula,),subtask-count: (name: "子任务数目",default: "1",),test-case-equal: (name: "测试点是否等分",default: "是",),pre-test-case-count: (name: "预测试点数目",default: "无",wrap: make-formula,),author :(name: "出题人",default: p => ( p. author))) + extra-rowsrows = rows.pairs().map(row => (row.at(0), default-row + row.at(1)))set table(align: bottom)let first-column-width = if (problem-list.len() <= 3) { 22% } else { 1fr }let columns = (first-column-width, ) + (1fr, ) * problem-list.len()table(columns: columns,stroke: 0.4pt,..{rows.filter(row => {let (field, r) = rowif (r.always-display) {true} else {problem-list.any(p => p.at(field, default: none) != none)}}).map(row => {let (field, r) = row(text(r.name), )problem-list.map(p => {let v = p.at(field, default: none)let w = if (v == none) {if (type(r.default) == str) {(r.wrap)(r.default)} else if (type(r.default) == function) {(r.wrap)((r.default)(p))} else if (type(r.default) == content) {(r.wrap)(r.default)}} else {v}if (type(w) == str) {(r.wrap)(w)} else {w}})}).flatten()})[提交源程序文件名]table(columns: columns,stroke: 0.4pt,align: horizon,..{languages.map(l => {if (l.len() == 2) {l += (1em, )}(text(size: l.at(2))[对于 #l.at(0) #h(1fr) 语言], )problem-list.map(p => {let v = p.at("submit-file-name", default: p.name-en + "." + l.at(1))if (type(v) == str) {raw(v)} else if (type(v) == function){v(l.at(1))} else {v}})}).flatten()})[编译选项]table(columns: columns,align: (left+bottom, center+bottom),stroke: 0.4pt,..{compile-options.map(l => {if (l.len() == 2) {l += (1em, )}(text(size: l.at(2))[对于 #l.at(0) #h(1fr) 语言],table.cell(colspan: problem-list.len(),raw(l.at(1))))}).flatten()})}let next-problem() = {current-problem-idx.step()pagebreak()statement-page-begin.update(it => true)context {let problem = get-current-problem(here())heading(level: 1, default-problem-fullname(problem))}}let filename(it) = {set text(style: "italic", weight: "bold")it}let current-filename(ext) = context {let problem = get-current-problem(here())filename(problem.at("name-en") + "." + ext)}let current-sample-filename(idx, ext) = context {let problem = get-current-problem(here())filename(problem.at("name-en") + "/" + problem.at("name-en") + str(idx) + "." + ext)}let data-constraints-table-args = {(stroke: (x, y) => (left: if (x > 0) { .4pt },bottom: 2pt,top: if(y == 0) { 2pt } else if (y == 1) { 1.2pt } else { .4pt }),align: center+horizon,)}(init: init,title: title,problem-table: problem-table,next-problem: next-problem,filename: filename,current-filename: current-filename,current-sample-filename: current-sample-filename,data-constraints-table-args: data-constraints-table-args)}```:::下面就能正常显示了,如果不行的话可以私信我。## 简略介绍一共主要引入了四个包,分别是生成题面,引入 latex 语法,算法代码块,md 表格转 typ (在 fuzzy 中)。具体的使用说明大家可以上网上搜,或者点击库的引用,然后找到源文件夹,里面会有一个说明的。- **在生成题面的过程中,首页上没有的可以自由添加,然后没必要的可以自由注释掉。**- 字体加粗与 md 的操作不同,应该为单星号。- \#mitext (\`\`) 可以代替 #mi(\`\`) ,里面可以放入基本上任何的 latex 的公式。可能我就想起来那么多了,还有的话可能会继续更新。