<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>KittenGen | 帮助文档</title>
    <link href="/static/css/bootstrap.min.css" rel="stylesheet">
    <script src="/static/js/jquery.min.js"></script>
    <script src="/static/js/bootstrap.min.js"></script>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
    <link rel="stylesheet" href="/static/css/github-dark.min.css">
    <script src="/static/js/highlight.min.js"></script>
    <script src="/static/js/cpp.min.js"></script>

    <style>
        :root {
            --primary-color: #5e35b1;
            --secondary-color: #7e57c2;
            --accent-color: #ff6f00;
            --light-bg: #f8f9fa;
            --dark-bg: #1a1a1a;
        }

        body {
            background: linear-gradient(135deg, #f5f7fa 0%, #e4e7f4 100%);
            min-height: 100vh;
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
            line-height: 1.6;
        }

        .card {
            border: none;
            box-shadow: 0 15px 40px rgba(0, 0, 0, 0.12);
            border-radius: 16px;
            overflow: hidden;
            margin-top: 20px;
        }

        .card-header {
            background: linear-gradient(to right, var(--primary-color), var(--secondary-color));
            color: white;
            padding: 25px 30px;
            border-bottom: none;
            font-weight: 600;
        }

        .card-body {
            padding: 30px;
        }

        .section-title {
            position: relative;
            padding-left: 20px;
            margin: 30px 0 20px;
            font-weight: 700;
            color: var(--primary-color);
            border-left: 4px solid var(--accent-color);
        }

        .btn-primary {
            background: linear-gradient(to right, var(--primary-color), var(--secondary-color));
            border: none;
            padding: 14px 36px;
            font-weight: 600;
            font-size: 18px;
            border-radius: 12px;
            transition: all 0.3s ease;
            box-shadow: 0 5px 15px rgba(94, 53, 177, 0.3);
        }

        .btn-primary:hover {
            transform: translateY(-3px);
            box-shadow: 0 8px 20px rgba(94, 53, 177, 0.4);
        }

        .list-group-item {
            border-radius: 8px !important;
            margin-bottom: 10px;
            border: 1px solid rgba(0,0,0,0.05);
            padding: 15px 20px;
            transition: all 0.2s;
        }

        .list-group-item:hover {
            transform: translateX(5px);
            box-shadow: 0 5px 15px rgba(0, 0, 0, 0.05);
        }

        pre {
            border-radius: 12px;
            border: 1px solid rgba(0,0,0,0.1);
            box-shadow: inset 0 1px 10px rgba(0,0,0,0.05);
            padding: 20px !important;
            margin: 20px 0;
            overflow: auto;
            max-height: 500px;
        }

        .nav-tabs {
            border: none;
            margin-bottom: 25px;
            background: white;
            border-radius: 12px;
            padding: 5px;
            box-shadow: 0 5px 15px rgba(0, 0, 0, 0.05);
        }

        .nav-tabs .nav-link {
            border: none;
            padding: 12px 30px;
            font-weight: 600;
            color: #555;
            border-radius: 10px;
            transition: all 0.3s;
        }

        .nav-tabs .nav-link.active {
            background: linear-gradient(to right, var(--primary-color), var(--secondary-color));
            color: white;
            box-shadow: 0 5px 15px rgba(94, 53, 177, 0.3);
        }

        .feature-icon {
            display: inline-flex;
            align-items: center;
            justify-content: center;
            width: 40px;
            height: 40px;
            background: linear-gradient(to bottom right, #e0e7ff, #d1e0ff);
            border-radius: 10px;
            margin-right: 15px;
            color: var(--primary-color);
            font-size: 18px;
        }

        .logo-header {
            display: flex;
            align-items: center;
            gap: 15px;
            margin-bottom: 10px;
        }

        .logo-icon {
            width: 60px;
            height: 60px;
            background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
            border-radius: 16px;
            display: flex;
            align-items: center;
            justify-content: center;
            color: white;
            font-size: 28px;
            font-weight: bold;
            box-shadow: 0 8px 20px rgba(94, 53, 177, 0.3);
        }

        .logo-text {
            font-size: 32px;
            font-weight: 800;
            background: linear-gradient(to right, var(--primary-color), var(--accent-color));
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
            margin: 0;
            letter-spacing: -0.5px;
        }

        .header-subtitle {
            font-size: 18px;
            color: rgba(255,255,255,0.85);
            margin-bottom: 0;
        }

        .example-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin: 30px 0 15px;
        }

        .example-title {
            font-weight: 700;
            color: #444;
            font-size: 20px;
        }

        .lang-badge {
            padding: 6px 15px;
            border-radius: 20px;
            font-weight: 600;
            font-size: 14px;
        }

        .python-badge {
            background: linear-gradient(to right, #3776ab, #4b8bbe);
            color: white;
        }

        .cpp-badge {
            background: linear-gradient(to right, #649ad2, #00599c);
            color: white;
        }

        .info-box {
            background: rgba(94, 53, 177, 0.05);
            border-radius: 12px;
            padding: 20px;
            margin: 25px 0;
            border-left: 4px solid var(--primary-color);
        }

        .info-box h5 {
            color: var(--primary-color);
            margin-bottom: 10px;
        }

        .container {
            max-width: 1000px;
        }

        .back-btn-container {
            margin: 30px 0;
            text-align: center;
        }

        .code-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            background: #343a40;
            padding: 10px 15px;
            border-radius: 8px 8px 0 0;
            color: white;
            font-size: 14px;
        }

        .copy-btn {
            background: rgba(255,255,255,0.15);
            border: none;
            color: white;
            border-radius: 6px;
            padding: 4px 12px;
            font-size: 13px;
            cursor: pointer;
            transition: all 0.2s;
        }

        .copy-btn:hover {
            background: rgba(255,255,255,0.25);
        }

        .tab-content {
            background: white;
            border-radius: 0 0 12px 12px;
            padding: 25px;
            box-shadow: 0 5px 20px rgba(0,0,0,0.05);
        }

        .hljs {
            background: #1e1e1e !important;
            border-radius: 0 0 8px 8px;
            padding: 20px !important;
        }
    </style>
</head>
<body class="bg-light">
<div class="container py-5">
    <div class="card shadow">
        <div class="card-header">
            <div class="logo-header">
                <div class="logo-icon">KG</div>
                <h1 class="logo-text">KittenGen</h1>
            </div>
            <p class="header-subtitle">数据生成器使用说明</p>
        </div>

        <div class="card-body">
            <!-- 语言选择选项卡 -->
            <ul class="nav nav-tabs" id="langTab" role="tablist">
                <li class="nav-item" role="presentation">
                    <button class="nav-link active" id="python-tab" data-bs-toggle="tab"
                            data-bs-target="#python" type="button" role="tab">
                        <i class="fab fa-python me-2"></i>Python 生成器
                    </button>
                </li>
                <li class="nav-item" role="presentation">
                    <button class="nav-link" id="cpp-tab" data-bs-toggle="tab"
                            data-bs-target="#cpp" type="button" role="tab">
                        <i class="fas fa-code me-2"></i>C++ 生成器
                    </button>
                </li>
            </ul>

            <div class="tab-content" id="langTabContent">
                <!-- Python 帮助内容 -->
                <div class="tab-pane fade show active" id="python" role="tabpanel">
                    <h3 class="section-title">
                        <i class="fab fa-python text-primary me-2"></i>Python 生成器使用说明
                    </h3>

                    <div class="info-box">
                        <h5><i class="fas fa-lightbulb me-2"></i>快速提示</h5>
                        <p class="mb-0">使用Python生成器可以快速创建测试数据，已内置random库，支持所有标准Python功能。</p>
                    </div>

                    <h4 class="section-title">基本规范</h4>
                    <ul class="list-group mb-4">
                        <li class="list-group-item">
                            <div class="d-flex align-items-center">
                                <span class="feature-icon"><i class="fas fa-hashtag"></i></span>
                                <div>
                                    <strong>代码中可以使用全局变量 <code>num: int</code></strong> -
                                    表示当前测试点编号（从 1 开始）
                                </div>
                            </div>
                        </li>
                        <li class="list-group-item">
                            <div class="d-flex align-items-center">
                                <span class="feature-icon"><i class="fas fa-random"></i></span>
                                <div>
                                    <strong>random 库已自动预导入</strong> -
                                    可直接使用 randint, choice, random 等函数
                                </div>
                            </div>
                        </li>
                        <li class="list-group-item">
                            <div class="d-flex align-items-center">
                                <span class="feature-icon"><i class="fas fa-print"></i></span>
                                <div>
                                    <strong>使用 print 函数直接输出</strong> -
                                    内容会自动写入输入文件，无需文件操作
                                </div>
                            </div>
                        </li>
                        <li class="list-group-item">
                            <div class="d-flex align-items-center">
                                <span class="feature-icon"><i class="fas fa-code"></i></span>
                                <div>
                                    <strong>支持 CYaRon 库</strong> -
                                    可快捷生成图、树、向量等数据
                                    参见
                                    <a href="/help/cyaron/" class="help-link">CYaRon 文档</a>
                                </div>
                            </div>
                        </li>
                    </ul>

                    <div class="example-header">
                        <h4 class="section-title">示例代码</h4>
                        <span class="lang-badge python-badge">Python</span>
                    </div>
                    <p class="text-muted mb-3">一个单点修改，区间查询的数据结构题</p>

                    <div class="border rounded overflow-hidden">
                        <div class="code-header">
                            <span>maker.py</span>
                            <button class="copy-btn" onclick="copyCode(this, 'python-code')">
                                <i class="fas fa-copy me-1"></i>复制代码
                            </button>
                        </div>
                        <pre class="m-0"><code class="language-python" id="python-code"># 测试点规模配置
N = [0, 100, 2000, 100000, 100000, 200000, 200000, 300000, 400000, 500000, 500000]
Q = [0, 100, 2000, 100000, 100000, 200000, 200000, 300000, 400000, 500000, 500000]
E9 = 10 ** 9

# 根据测试点编号获取规模
n, q = N[num], Q[num]
print(n, q)

# 生成n个随机数作为初始数组
for i in range(n):
    print(randint(-E9, E9), end=' ')
print()

# 生成q个操作
for i in range(q):
    opt = choice([1, 2])  # 随机选择操作类型
    l = randint(1, n)     # 随机左端点

    if opt == 1:
        # 单点修改操作
        print(opt, l, randint(-E9, E9))
    else:
        # 区间查询操作
        r = randint(1, n)
        if l > r:
            l, r = r, l
        print(opt, l, r)</code></pre>
                    </div>

                    <hr> <p class="text-muted mb-3">单源最短路模板题</p>

                    <div class="border rounded overflow-hidden">
                        <div class="code-header">
                            <span>maker.py</span>
                            <button class="copy-btn" onclick="copyCode(this, 'python-code2')">
                                <i class="fas fa-copy me-1"></i>复制代码
                            </button>
                        </div>
                        <pre class="m-0"><code class="language-python" id="python-code2"># 测试点规模配置
N = [0, 100, 2000, 100000, 100000, 200000, 200000, 300000, 400000, 500000, 500000]
M = [0, 100, 2000, 100000, 100000, 200000, 200000, 300000, 400000, 500000, 500000]
E9 = 10 ** 9

n = N[num]   # 点数
m = M[num]   # 边数
s = randint(1, n)   # 随机选取源点
print(n, m, s)
graph = cyaron.Graph.graph(n, m, weight_limit=E9)   # 生成一个n点，m边的随机图，边权限制为1e9
print(graph.to_str())   # 输出无向图，默认以一行一组u v w的形式输出</code></pre>
                    </div>
                </div>

                <!-- C++ 帮助内容 -->
                <div class="tab-pane fade" id="cpp" role="tabpanel">
                    <h3 class="section-title">
                        <i class="fas fa-code text-primary me-2"></i>C++ 生成器使用说明
                    </h3>

                    <div class="info-box">
                        <h5><i class="fas fa-lightbulb me-2"></i>快速提示</h5>
                        <p class="mb-0">使用C++生成器可以获得更好的性能，适合大规模数据与复杂逻辑场景。编译选项与 std.cpp 相同。</p>
                    </div>

                    <h4 class="section-title">基本规范</h4>
                    <ul class="list-group mb-4">
                        <li class="list-group-item">
                            <div class="d-flex align-items-center">
                                <span class="feature-icon"><i class="fas fa-hashtag"></i></span>
                                <div>
                                    <strong>可以从标准输入读取一个正整数 <code>num</code></strong> -
                                    表示当前测试点编号（从 1 开始）
                                </div>
                            </div>
                        </li>
                        <li class="list-group-item">
                            <div class="d-flex align-items-center">
                                <span class="feature-icon"><i class="fas fa-terminal"></i></span>
                                <div>
                                    <strong>将数据直接生成到标准输出</strong> -
                                    内容会自动写入输入文件，无需文件操作
                                </div>
                            </div>
                        </li>
                        <li class="list-group-item">
                            <div class="d-flex align-items-center">
                                <span class="feature-icon"><i class="fas fa-cogs"></i></span>
                                <div>
                                    <strong>支持标准库和STL</strong> -
                                    可使用所有C++标准库功能
                                </div>
                            </div>
                        </li>
                    </ul>

                    <div class="example-header">
                        <h4 class="section-title">示例代码</h4>
                        <span class="lang-badge cpp-badge">C++</span>
                    </div>
                    <p class="text-muted mb-3">一个单点修改，区间查询的数据结构题</p>

                    <div class="border rounded overflow-hidden">
                        <div class="code-header">
                            <span>maker.cpp</span>
                            <button class="copy-btn" onclick="copyCode(this, 'cpp-code')">
                                <i class="fas fa-copy me-1"></i>复制代码
                            </button>
                        </div>
                        <pre class="m-0"><code class="language-cpp" id="cpp-code">#include &lt;bits/stdc++.h&gt;
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int randint(int l, int r) {
    return uniform_int_distribution&lt;int&gt;(l, r)(rng);
}

// 测试点规模配置
const int N[] = {0, 100, 2000, 100000, 100000, 200000, 200000, 300000, 400000, 500000, 500000};
const int Q[] = {0, 100, 2000, 100000, 100000, 200000, 200000, 300000, 400000, 500000, 500000};
const int E9 = 1e9;
int num;

int main() {
    // 关闭同步加速输出
    ios::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);

    // 根据测试点编号获取规模
    cin >> num;
    int n = N[num];
    int q = Q[num];
    cout &lt;&lt; n &lt;&lt; " " &lt;&lt; q &lt;&lt; "\n";

    // 生成n个随机数作为初始数组
    for (int i = 0; i &lt; n; i++) {
        cout &lt;&lt; randint(-E9, E9) &lt;&lt; " ";
    }
    cout &lt;&lt; "\n";

    // 生成q个操作
    while (q--) {
        int opt = randint(1, 2);  // 随机选择操作类型
        int l = randint(1, n);    // 随机左端点

        if (opt == 1) {
            // 单点修改操作
            cout &lt;&lt; opt &lt;&lt; " " &lt;&lt; l &lt;&lt; " " &lt;&lt; randint(-E9, E9) &lt;&lt; "\n";
        } else {
            // 区间查询操作
            int r = randint(1, n);
            if (l > r) swap(l, r);
            cout &lt;&lt; opt &lt;&lt; " " &lt;&lt; l &lt;&lt; " " &lt;&lt; r &lt;&lt; "\n";
        }
    }

    cout &lt;&lt; flush;   // 注意刷新缓冲区
    return 0;
}</code></pre>
                    </div>
                </div>
            </div>

            <div class="back-btn-container">
                <a href="/" class="btn btn-primary btn-lg px-5">
                    <i class="fas fa-arrow-left me-2"></i>返回生成器
                </a>
            </div>
        </div>
    </div>
</div>

<script>
    // 初始化代码高亮
    document.addEventListener('DOMContentLoaded', (event) => {
        document.querySelectorAll('pre code').forEach((el) => {
            hljs.highlightElement(el);
        });
    });

    // 复制代码功能
    function copyCode(button, elementId) {
        const codeElement = document.getElementById(elementId);
        const textArea = document.createElement('textarea');
        textArea.value = codeElement.textContent;
        document.body.appendChild(textArea);
        textArea.select();
        document.execCommand('copy');
        document.body.removeChild(textArea);

        // 显示复制成功反馈
        const originalText = button.innerHTML;
        button.innerHTML = '<i class="fas fa-check me-1"></i>已复制';
        button.style.background = 'rgba(40, 167, 69, 0.8)';

        setTimeout(() => {
            button.innerHTML = originalText;
            button.style.background = '';
        }, 2000);
    }

    // 激活第一个选项卡
    const firstTab = new bootstrap.Tab(document.querySelector('#python-tab'));
    firstTab.show();
</script>
</body>
</html>