-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathacm-playground.html
More file actions
328 lines (314 loc) · 19.6 KB
/
Copy pathacm-playground.html
File metadata and controls
328 lines (314 loc) · 19.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="Zero2Leetcode ACM 模拟 IDE - 支持 Python 与 Go、stdin/stdout、输出对比和 Python 断点调试">
<title>ACM 模拟 IDE | Zero2Leetcode</title>
<script>
(function(){var s=localStorage.getItem('z2l-theme');var t=s||(window.matchMedia('(prefers-color-scheme:light)').matches?'light':'dark');document.documentElement.setAttribute('data-theme',t);})();
</script>
<link rel="icon" type="image/svg+xml" href="assets/images/logo.svg">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link
href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=Fira+Code:wght@400;500&display=swap"
rel="stylesheet">
<link rel="stylesheet" href="assets/css/style.css?v=2">
<link rel="stylesheet" href="assets/css/acm-playground.css?v=20260716">
<!-- CodeMirror 5 -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.65.18/codemirror.min.css">
<link rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.65.18/theme/material-darker.min.css">
<link rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.65.18/theme/eclipse.min.css">
<link rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.65.18/addon/hint/show-hint.min.css">
</head>
<body>
<!-- 导航栏 -->
<nav class="navbar">
<div class="nav-container">
<a href="./" class="nav-logo">
<img src="assets/images/logo.svg" alt="Logo" class="logo-icon">
<span class="logo-text">Zero2Leetcode</span>
</a>
<ul class="nav-menu">
<li><a href="https://onefly.top/zero2Agent/" target="_blank" class="nav-link nav-friend-link">Zero2Agent</a></li>
<li><a href="./#roadmap" class="nav-link">学习路线</a></li>
<li><a href="./#modules" class="nav-link">知识模块</a></li>
<li><a href="./#problems" class="nav-link">题目清单</a></li>
<li><a href="playground.html" class="nav-link">本地力扣模拟</a></li>
<li><a href="acm-playground.html" class="nav-link nav-link-active">ACM 模拟</a></li>
</ul>
<div class="nav-actions">
<button class="theme-toggle" id="theme-toggle" type="button" aria-label="切换主题" title="切换主题">
<svg class="icon-sun" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="5"/><line x1="12" y1="1" x2="12" y2="3"/><line x1="12" y1="21" x2="12" y2="23"/><line x1="4.22" y1="4.22" x2="5.64" y2="5.64"/><line x1="18.36" y1="18.36" x2="19.78" y2="19.78"/><line x1="1" y1="12" x2="3" y2="12"/><line x1="21" y1="12" x2="23" y2="12"/><line x1="4.22" y1="19.78" x2="5.64" y2="18.36"/><line x1="18.36" y1="5.64" x2="19.78" y2="4.22"/></svg>
<svg class="icon-moon" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 12.79A9 9 0 1111.21 3 7 7 0 0021 12.79z"/></svg>
</button>
<button class="nav-toggle" aria-label="打开菜单">
<span></span>
<span></span>
<span></span>
</button>
</div>
</div>
</nav>
<!-- 主内容区 -->
<main class="acm-main">
<!-- 顶部工具栏 -->
<div class="acm-toolbar">
<div class="toolbar-left">
<select id="language-select" class="template-select language-select" aria-label="编程语言" title="编程语言">
<option value="python">Python 3</option>
<option value="go">Go</option>
</select>
<select id="template-select" class="template-select">
<option value="">选择输入模板...</option>
<option value="single">单个整数</option>
<option value="two">两个整数</option>
<option value="array">读取数组</option>
<option value="matrix">读取矩阵</option>
<option value="multi">多组测试用例</option>
<option value="string">读取字符串</option>
<option value="graph">读取图(邻接表)</option>
</select>
<span class="toolbar-divider"></span>
<span id="runtime-status" class="runtime-status loading">Python 加载中...</span>
<span class="toolbar-divider"></span>
<select id="timeout-select" class="template-select" title="执行超时时间">
<option value="10000">超时: 10s</option>
<option value="30000">超时: 30s</option>
<option value="60000">超时: 60s</option>
<option value="300000">超时: 5min</option>
<option value="0">无限制</option>
</select>
</div>
<div class="toolbar-right">
<button id="run-btn" class="btn btn-run" disabled>
<svg width="16" height="16" viewBox="0 0 16 16" fill="currentColor">
<path d="M4 2l10 6-10 6V2z" />
</svg>
运行<span class="run-shortcut"> (Ctrl+Enter)</span>
</button>
<button id="debug-btn" class="btn btn-debug" disabled>
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round">
<path d="M12 2a4 4 0 00-4 4v2H6a2 2 0 00-2 2v1a6 6 0 003 5.2V20a2 2 0 002 2h6a2 2 0 002-2v-3.8A6 6 0 0020 11v-1a2 2 0 00-2-2h-2V6a4 4 0 00-4-4z"/>
<path d="M9 11h.01"/><path d="M15 11h.01"/>
</svg>
调试
</button>
<button id="reset-btn" class="btn btn-reset">重置</button>
<button id="save-code-btn" class="btn btn-save-code" type="button">
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
<path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/>
<polyline points="7 10 12 15 17 10"/>
<line x1="12" y1="15" x2="12" y2="3"/>
</svg>
保存代码
</button>
</div>
</div>
<!-- 两栏布局:编辑器 | 输入输出+调试 -->
<div class="acm-layout">
<!-- 左侧:代码编辑器 -->
<div class="acm-panel acm-panel-editor">
<div class="panel-header">
<span class="panel-title">代码编辑器</span>
<div class="panel-header-tools">
<span id="language-hint" class="panel-hint">Python 3 · ACM 模式</span>
<div class="workspace-actions" role="group" aria-label="练习导入导出">
<button id="import-workspace-btn" class="workspace-action-btn" type="button" title="导入练习包(JSON)" aria-label="导入练习包(JSON)">
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
<path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/>
<polyline points="17 8 12 3 7 8"/>
<line x1="12" y1="3" x2="12" y2="15"/>
</svg>
<span class="workspace-action-label">导入练习</span>
</button>
<button id="export-workspace-btn" class="workspace-action-btn" type="button" title="导出练习包(JSON)" aria-label="导出练习包(JSON)">
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
<path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/>
<polyline points="7 10 12 15 17 10"/>
<line x1="12" y1="15" x2="12" y2="3"/>
</svg>
<span class="workspace-action-label">导出练习</span>
</button>
</div>
</div>
</div>
<div class="panel-body editor-body">
<textarea id="code-editor"></textarea>
</div>
</div>
<!-- 右侧:输入输出 + 调试 -->
<div class="acm-panel-right">
<!-- 输入区 -->
<div class="acm-panel acm-panel-input">
<div class="panel-header">
<span class="panel-title">
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<path d="M21 15v4a2 2 0 01-2 2H5a2 2 0 01-2-2v-4"/>
<polyline points="7 10 12 15 17 10"/>
<line x1="12" y1="15" x2="12" y2="3"/>
</svg>
输入 (stdin)
</span>
<button id="clear-input-btn" class="panel-action-btn" title="清空输入">清空</button>
</div>
<div class="panel-body io-body">
<textarea id="stdin-area" class="io-textarea" placeholder="在这里粘贴测试输入... 例如: 5 1 3 2 5 4" spellcheck="false"></textarea>
</div>
</div>
<!-- 输出区 -->
<div class="acm-panel acm-panel-output">
<div class="panel-header">
<span class="panel-title">
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<path d="M21 15v4a2 2 0 01-2 2H5a2 2 0 01-2-2v-4"/>
<polyline points="17 8 12 3 7 8"/>
<line x1="12" y1="3" x2="12" y2="15"/>
</svg>
输出 (stdout)
</span>
<span id="run-status" class="run-status"></span>
</div>
<div class="panel-body io-body">
<pre id="stdout-area" class="io-output">点击「运行」或按 Ctrl+Enter 执行代码</pre>
</div>
</div>
<!-- 期望输出区 -->
<div class="acm-panel acm-panel-expected">
<div class="panel-header">
<span class="panel-title">
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<path d="M22 11.08V12a10 10 0 11-5.93-9.14"/>
<polyline points="22 4 12 14.01 9 11.01"/>
</svg>
期望输出(可选,用于对比)
</span>
<span id="diff-result" class="diff-result"></span>
</div>
<div class="panel-body io-body">
<textarea id="expected-area" class="io-textarea" placeholder="粘贴期望输出,自动与实际输出对比..." spellcheck="false"></textarea>
</div>
</div>
<!-- 调试面板(默认隐藏) -->
<div id="debug-panel" class="acm-panel acm-panel-debug" style="display:none;">
<div class="panel-header">
<span class="panel-title">
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round">
<path d="M12 2a4 4 0 00-4 4v2H6a2 2 0 00-2 2v1a6 6 0 003 5.2V20a2 2 0 002 2h6a2 2 0 002-2v-3.8A6 6 0 0020 11v-1a2 2 0 00-2-2h-2V6a4 4 0 00-4-4z"/>
</svg>
调试回放
</span>
<button id="debug-close-btn" class="panel-action-btn" title="关闭调试">关闭</button>
</div>
<div class="debug-controls">
<button id="debug-prev" class="debug-step-btn" title="上一步">
<svg width="16" height="16" viewBox="0 0 24 24" fill="currentColor"><path d="M15.41 7.41L14 6l-6 6 6 6 1.41-1.41L10.83 12z"/></svg>
</button>
<span id="debug-step-info" class="debug-step-info">Step 0/0</span>
<button id="debug-next" class="debug-step-btn" title="下一步">
<svg width="16" height="16" viewBox="0 0 24 24" fill="currentColor"><path d="M10 6L8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z"/></svg>
</button>
<span class="debug-controls-sep"></span>
<button id="debug-prev-bp" class="debug-step-btn" title="上一个断点">
<svg width="16" height="16" viewBox="0 0 24 24" fill="currentColor"><path d="M18.41 16.59L13.82 12l4.59-4.59L17 6l-6 6 6 6z"/><path d="M6 6h2v12H6z"/></svg>
</button>
<button id="debug-next-bp" class="debug-step-btn" title="下一个断点">
<svg width="16" height="16" viewBox="0 0 24 24" fill="currentColor"><path d="M5.59 7.41L10.18 12l-4.59 4.59L7 18l6-6-6-6z"/><path d="M16 6h2v12h-2z"/></svg>
</button>
</div>
<div class="debug-body">
<div class="debug-vars-header">变量状态</div>
<div id="debug-vars" class="debug-vars">
<div class="debug-placeholder">点击「调试」开始录制执行过程</div>
</div>
</div>
</div>
</div>
</div>
<!-- 底部状态栏 -->
<div class="acm-statusbar">
<span id="status-info">就绪</span>
<span class="statusbar-sep">|</span>
<span id="status-time"></span>
<span class="statusbar-right">
<span class="statusbar-tip">Ctrl+Enter 运行</span>
<span class="statusbar-sep">|</span>
<span id="debug-tip" class="statusbar-tip">点击行号设置断点</span>
</span>
</div>
</main>
<input id="workspace-file-input" type="file" accept=".json,application/json" hidden>
<div id="file-toast" class="file-toast" role="status" aria-live="polite"></div>
<dialog id="save-code-dialog" class="file-dialog" aria-labelledby="save-code-title">
<form id="save-code-form" class="file-dialog-form">
<div class="file-dialog-header">
<h2 id="save-code-title">保存代码</h2>
<button id="save-code-close" class="dialog-close-btn" type="button" aria-label="关闭保存窗口" title="关闭">
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" aria-hidden="true">
<line x1="18" y1="6" x2="6" y2="18"/>
<line x1="6" y1="6" x2="18" y2="18"/>
</svg>
</button>
</div>
<div class="file-dialog-body">
<label for="save-code-filename">文件名</label>
<div id="filename-field" class="filename-field">
<input id="save-code-filename" type="text" value="main" maxlength="120" autocomplete="off" spellcheck="false" aria-describedby="save-code-extension save-code-error" aria-invalid="false">
<span id="save-code-extension" class="filename-extension">.py</span>
</div>
<p id="save-code-error" class="filename-error" role="alert"></p>
</div>
<div class="file-dialog-footer">
<button id="save-code-cancel" class="dialog-btn dialog-btn-cancel" type="button">取消</button>
<button class="dialog-btn dialog-btn-confirm" type="submit">
<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
<path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/>
<polyline points="7 10 12 15 17 10"/>
<line x1="12" y1="15" x2="12" y2="3"/>
</svg>
保存
</button>
</div>
</form>
</dialog>
<!-- CodeMirror JS -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.65.18/codemirror.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.65.18/mode/python/python.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.65.18/mode/go/go.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.65.18/addon/hint/show-hint.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.65.18/addon/selection/active-line.min.js"></script>
<!-- Pyodide -->
<script src="https://cdn.jsdelivr.net/pyodide/v0.26.4/full/pyodide.js"></script>
<!-- ACM Playground Logic -->
<script src="assets/js/acm-playground.js?v=20260716"></script>
<!-- Theme toggle -->
<script>
(function () {
var btn = document.getElementById('theme-toggle');
if (!btn) return;
function currentTheme() {
return document.documentElement.getAttribute('data-theme') || 'dark';
}
function syncEditorTheme(theme) {
if (window.acmEditor && window.acmEditor.setOption) {
window.acmEditor.setOption('theme', theme === 'light' ? 'eclipse' : 'material-darker');
}
}
btn.addEventListener('click', function () {
var next = currentTheme() === 'dark' ? 'light' : 'dark';
document.documentElement.setAttribute('data-theme', next);
localStorage.setItem('z2l-theme', next);
syncEditorTheme(next);
});
var initCheck = setInterval(function () {
if (window.acmEditor) { syncEditorTheme(currentTheme()); clearInterval(initCheck); }
}, 200);
setTimeout(function () { clearInterval(initCheck); }, 10000);
})();
</script>
</body>
</html>