抱歉,您的浏览器无法访问本站
本页面需要浏览器支持(启用)JavaScript
了解详情 >

本项测试可能已失效

代码块全屏测试

How To Use?

导入库文件即可 (写于 2020 年需要 jquery)

<link rel='stylesheet' href='https://static.mhuig.top/gh/MHuiG/blog-cdn@1.1.12/css/me.css'>
<script src='https://static.mhuig.top/gh/MHuiG/blog-cdn@1.1.12/js/me.js'></script>

去除 jquery 原生 js 版本 (2025 年 11 月):

js code
// 获取所有figcaption元素并添加点击事件监听
document.querySelectorAll('figcaption').forEach(figcaption => {
figcaption.addEventListener('click', function() {
// 切换全屏状态标志
const isFullscreen = !window.CodeBlockFullscreen;
window.CodeBlockFullscreen = isFullscreen;

// 获取相关DOM元素
const postElement = document.getElementById('post') || document.getElementById('docs') || document.getElementById('page');
if(!postElement) return;
const parentElement = this.parentElement;
const grandParentElement = parentElement.parentElement;
const htmlElement = document.documentElement;
const gutterElements = document.querySelectorAll('.highlight > table .gutter');

// 为元素添加/移除全屏相关类
postElement.classList.toggle('code-block-fullscreen', isFullscreen);
parentElement.classList.toggle('code-block-fullscreen', isFullscreen);
grandParentElement.classList.toggle('code-block-fullscreen', isFullscreen);
parentElement.classList.toggle('code-block-fullscreen-overflow-auto', isFullscreen);
htmlElement.classList.toggle('code-block-fullscreen-html-scroll', isFullscreen);


// 处理多个gutter元素
gutterElements.forEach(gutter => {
gutter.classList.toggle('code-block-fullscreen-gutter', isFullscreen);
});
});
});
css code
/*code-block-fullscreen*/
.code-block-fullscreen {
position:fixed !important;
top:0 !important;
left:0 !important;
width:100% !important;
height:100% !important;
min-width:100% !important;
z-index:9999999 !important;
margin:0 !important;
animation:elastic 3s !important;
}
.code-block-fullscreen-html-scroll {
overflow:hidden;
}
.code-block-fullscreen-overflow-auto {
overflow:auto;
}
.code-block-fullscreen-gutter {
height: calc(97vh) !important;
padding: 16px 12px !important;
vertical-align: top !important;
}
cpp code
#include <iostream>
using namespace std;

int main()
{
cout << "Hello, World!";
return 0;
}
python code
#!/usr/bin/python

print ("Hello, Python!")
code
#include <cstdio>
#include <iostream>
#include <vector>

using namespace std;

const int SIZE = 5e6 + 1;

struct edge
{
int to_node, id;
edge(int t, int i): to_node(t), id(i) {}
~edge() = default;
};

vector<int> edges[SIZE];
vector<edge> querys[SIZE];
int father[SIZE], mark[SIZE], ans[SIZE];

int n, m, s;

int getfa(int x)
{
if (father[x] == x)
return x;
else
return father[x] = getfa(father[x]);
}

void tarjan(int x)
{
mark[x] = 1;
for (auto i = edges[x].begin(); i != edges[x].end(); i++)
{
if (mark[*i])
continue;
tarjan(*i);
father[*i] = x;
}
for (auto i = querys[x].begin(); i != querys[x].end(); i++)
{
int y = (*i).to_node, id = (*i).id;
if (mark[y] == 2)
ans[id] = getfa(y);
}
mark[x] = 2;
}

int main()
{
int u, v;
scanf("%d%d%d", &n, &m, &s);
for (int i = 1; i <= n; i++)
{
father[i] = i;
mark[i] = 0;
}
for (int i = 1; i < n; i++)
{
scanf("%d%d", &u, &v);
edges[u].emplace_back(v);
edges[v].emplace_back(u);
}
int x, y;
for (int i = 1; i <= m; i++)
{
scanf("%d%d", &x, &y);
if (x == y)
ans[i] = 0;
else
{
querys[x].emplace_back(edge(y, i));
querys[y].emplace_back(edge(x, i));
}
}
tarjan(s);
for (int i = 1; i <= m; i++)
printf("%d\n", ans[i]);
return 0;
}
推荐阅读
网站纪念日自动灰屏实现方案 网站纪念日自动灰屏实现方案 图片墙 图片墙 JavaScript 反调试 JavaScript 反调试 不知名的碎片13 不知名的碎片13 梅林变换 梅林变换 论黎曼解析数论遗稿 西格尔(1932)[中文] 论黎曼解析数论遗稿 西格尔(1932)[中文]

留言区

Are You A Robot?