嘘~ 正在从服务器偷取页面 . . .

ChatGPT 辅助写题解的技巧


ChatGPT 辅助写题解的技巧

q779 你是不是不写题跑来写这种东西了啊?

施工中,咕咕咕...

一、公式格式问题

有些题,比如洛谷爬的 CF 题,它的行内公式都是 $ abc $ 的格式

然后我的博客是不支持这样写的,仅支持 $abc$ ,即没有空格的写法

比如我下一篇文章(也就是我正在写的题解),它的文本就是这么样。

我们可以让 ChatGPT 来搞定这种智障的事:

把下面的文本中形如 $ x $ 的部分全部替换成 $x$

如图:

然后这个傻fufu的 ChatGPT 好像不能输出两种语言的混合文本。

事实上确实如此,它似乎只会单语言的文本,不过这不重要,至少它还帮我修了 <= 这种东西。


二、复制题面

有些网页,比如OI中转站,用简悦没法正确识别题面,可以用以下方式生成题面:

帮我修一下下面的文本,修成 markdown 文本,并且使用行内公式:
<这里贴上直接复制后乱掉的 markdown 文本>

生成如下:

题目描述
有一棵 $n$ 个节点的有根树,$1$ 号点为根节点。第 $i$ 的父节点为 $f_i$ ($1\leq f_i < i \leq n$)。你每星期可以选择不超过 $m$ 个节点删掉,需要保证被删掉的节点是没有父节点的。删完后,会剩下一个森林 (若干棵树)。求最少多少星期才能删完所有的节点。

输入格式
第一行包含两个正整数 $n,m$ ($1\leq m\leq n$)。

第二行包含 $n-1$ 个正整数 $f_2,f_3,\cdots,f_n$ ($1\leq f_i<i\leq n$)。

输出格式
第一行输出一个整数 $t$,表示最少需要的时间。

接下来 $t$ 行,第 $i$ 行表示第 $i$ 星期删的点,其中第一个整数 $s_i$ 表示这周删的点的个数,接下来 $s_i$ 个整数分别是这周肝的点的标号。

效果还是非常不错的,至少可以直接复制了。

不过此方法不适用于特别复杂的公式,建议使用 Mathpix Snipping Tool,或者直接手打。

upd.2023-05-17-20-19-10:现在发现先用 Mathpix 扫一下再让 ChatGPT 修效果更好。

说到这个,顺便吐槽一下,我周围的 OIer 好像都没我打公式熟练,不知道为什么,挺好记的呀


三、建设英文站

突然想到可以用 ChatGPT 建设英文站,方案如下:

帮我把下面的 Markdown 文本翻译成英语,并以代码展示,不要渲染:
<这里放完整的题解源码>

效果如下:

Here is the translated Markdown text in English, with the code displayed as a code block:

```markdown
---
title: "CF794C Naming Company Solution"
tag: ["algorithm", "strings"]
categories: "OI"
mathjax: true
---

# CF794C Naming Company Solution

Problem link: [CF794C Naming Company](https://www.luogu.com.cn/problem/CF794C)

> **Problem Statement**:
>
> Here is the modified text, formatted in Markdown with inline formulas:
>
> A and B each have a string of length $n$, consisting of lowercase letters, denoted by $s$ and $t$ respectively. There is also a target string $f$ of length $n$, initially composed of `?` symbols.
>
> Now, A and B take turns performing the following operation:
>
> 1. They select a character $x$ from their own string.
> 2. They replace one `?` in $f$ with $x$.
> 3. They remove $x$ from their own string.
>
> The game ends when there are no more `?` symbols in $f$.
>
> A's goal is to make the lexicographical order of $f$ as small as possible, while B's goal is to make it as large as possible.
>
> A is the first player. Your task is to determine the final string $f$ after the game ends.
>
> Note: The strings $s$ and $t$ may contain multiple duplicate characters, and only one character can be removed at a time.

One obvious greedy strategy is for both players to fill the beginning of $f$ with characters that benefit them the most.

However, this greedy strategy is incorrect because it results in a larger answer when the smallest character chosen by A is greater than the largest character chosen by B.

So, what can we do instead? We can employ reverse greedy strategy in such cases, which ensures that the problematic position in $f$ is filled with a character that is not greater than the largest character chosen by B.

Time complexity: $\mathcal{O}(n)$

Code:

```cpp
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define INF 0x3f3f3f3f3f3f3f3f
void up(int &x,int y) { x < y ? x = y : 0; }
void down(int &x,int y) { x > y ? x = y : 0; }
#define N ((int)(3e5 + 15))

char s[N];
int n,a[N],b[N],f[N];
signed main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    // freopen("check.in","r",stdin);
    // freopen("check.out","w",stdout);
    cin >> (s + 1); n = strlen(s + 1);
    for(int i = 1; i <= n; i++) a[i] = s[i] - 'a';
    cin >> (s + 1); n = strlen(s + 1);
    for(int i = 1; i <= n; i++) b[i] = s[i] - 'a';
    sort(a + 1, a + 1 + n, less<int>());
    sort(b + 1, b + 1 + n, greater<int>());
    int x = 0, y = 0, pos = n;
    for(int i = 1; i <= n; i++)
    {
        if(a[x + 1] >= b[y + 1]) { pos =
```

然后没生成完,让它继续就可以了(不过我这里是代码,所以没什么必要翻译)


文章作者: q779
版权声明: 本博客所有文章除特别声明外,均采用 CC BY-NC-ND 4.0 许可协议。转载请注明来源 q779 !
评论
  目录