- ACM
讨论区
- @ 2025-11-17 19:04:11
公民在这可以发表自己的讨论但是要文明
8 条评论
-
gf24240 LV 7 MOD @ 2025-12-10 13:17:43 -
@ 2025-12-8 12:59:45/*鼠标样式*/ * { cursor: url(https://cdn.luogu.com.cn/upload/image_hosting/m0z68fn1.png), url(https://cdn.luogu.com.cn/upload/image_hosting/m0z68fn1.png), default !important; } -
@ 2025-12-7 18:50:38最长公共子序列细明
#include <iostream> #include <unordered_map> #define int long long using namespace std; const int N = 1e4 + 5; int n, m, dp[N][N]; string a, b; unordered_map <int, unordered_map <int, string> > lcs; signed main() { cin >> a >> b; n = a.size() - 1; m = b.size() - 1; for (int i = 1; i <= n; ++i) { for (int j = 1; j <= m; ++j) { if (a[i] == b[j]) { dp[i][j] = dp[i - 1][j - 1] + 1; lcs[i][j] = lcs[i - 1][j - 1] + a[i]; } else { dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]); if (dp[i][j] != dp[i - 1][j])lcs[i][j] = lcs[i][j - 1]; else lcs[i][j] = lcs[i - 1][j]; } } } cout << dp[n][m] << "\n" << lcs[n][m]; return 0; } -
@ 2025-12-7 18:50:37#include <bits/stdc++.h> using namespace std; string s1,s2; int n,m,dp[1005][1005]; int main() { cin>>s1>>s2; n=s1.size()-1; m=s2.size()-1; for(int i=1; i<=n; i++) { for(int j=1; j<=m; j++) { if(s1[i]==s2[j]) { dp[i][j]=dp[i-1][j-1]+1; }else{ dp[i][j]=max(dp[i-1][j],dp[i][j-1]); } } } cout<<dp[n][m]<<endl; string lcs; int i=n, j=m; while(i>0 && j>0) { if(s1[i]==s2[j]) { lcs=s1[i]+lcs; i--; j--; } else if(dp[i-1][j]>dp[i][j-1]) { i--; } else { j--; } } cout<<lcs; return 0; } -
@ 2025-12-5 19:22:46#include <bits/stdc++.h> using namespace std; int t; int n,C; int w[1005],c[1005],dp[1005]; int main(){ cin>>t; while(t--){ cin>>n>>C; for(int i=1;i<=n;i++)cin>>w[i]; for(int i=1;i<=n;i++)cin>>c[i]; for(int i=1;i<=n;i++){ for(int j=C;j>=w[i];j--){ dp[j]=max(dp[j],dp[j-w[i]]+c[i]); } } cout<<dp[C]<<"\n"; } return 0; } -
@ 2025-12-4 13:47:48可以用这个做 C++ 中文版
#include <map> #include <sstream> #include <iostream> using namespace std; map <string, string> def; string toEn(string str) { if (def.count(str))return toEn(def[str]); if (str == "#导入")return "#include"; if (str == "使用")return "using"; if (str == "命名空间")return "namespace"; if (str == "标准")return "std"; if (str == "主函数")return "main"; if (str == "《输入输出流》")return "<iostream>"; if (str == "整型")return "int"; if (str == "字符串")return "string"; if (str == "长整型")return "long long"; if (str == "循环")return "for"; if (str == "如果成立则循环")return "while"; if (str == "返回")return "return"; if (str == "如果")return "if"; if (str == "输入")return "cin"; if (str == "输出")return "cout"; if (str == "或")return "||"; if (str == "且")return "&&"; if (str == "等于")return "=="; if (str == "小于等于")return "<="; if (str == "小于")return "<"; if (str == "大于")return ">"; if (str == "大于等于")return ">="; if (str == "不等于")return "!="; if (str == "加")return "+"; if (str == "加上")return "+="; if (str == "减")return "-"; if (str == "减去")return "-="; if (str == "自增")return "++"; if (str == "自减")return "--"; if (str == "为")return "="; if (str == "(")return "("; if (str == ")")return ")"; if (str == "()")return "()"; if (str == ";")return ";"; return str; } int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); //freopen("code.in", "r", stdin); //freopen("code.out", "w", stdout); int Tabn = 0; string line; while (getline(cin, line)) { stringstream sss(line); stringstream ss2(line); string inp, tab; while (ss2 >> tab)if (tab == "}")--Tabn; for (int i = 1; i <= Tabn; ++i)cout << "\t"; bool flag = 1; while (sss >> inp) { if (inp == "#替换") { string bef, aft; sss >> bef >> aft; def[bef] = aft; flag = 0; continue; } if (inp == "{")++Tabn; cout << toEn(inp) << " "; } if (flag)cout << "\n"; } return 0; }输入问题就能得到 AI 的回答(false)
#include <bits/stdc++.h> using namespace std; int main() { string a; getline(cin, a); a = "start https://chat.baidu.com/search?word=" + a; system(a.c_str()); system("exit"); return 0; }可以生成你在洛谷练习的表格
#include <map> #include <iostream> #include <algorithm> using namespace std; int n = 8; string names[10] = {"", "暂无评定", "入门", "普及-", "普及/提高-", "普及+/提高", "提高+/省选-", "省选/NOI-", "NOI/NOI+/CTSC"}; string colors[10] = {"", "#bfbfbf", "#fe4c61", "#f39c11", "#ffc116", "#52c41a", "#3498db", "#9d3dcf", "#0e1d69"}; int lens[10], socs[10]; struct stu { int name; int soc, len; }a[10]; bool cmp(stu x, stu y) { return x.soc > y.soc; } void print(int name, int len) { cout << "\\textbf{" << names[name] << "} &: \\color{#ffffff}\\colorbox{" << colors[name] << "}{\\hspace{" << len / 20.0 << "cm}" << socs[name] << "\\hspace{" << len / 20.0 << "cm}} \\\\" << endl; } int main() { //ios::sync_with_stdio(0); //cin.tie(0); cout.tie(0); for (int i = 1; i <= n; ++i) { cin >> a[i].soc; socs[i] = a[i].soc; a[i].name = i; if (a[i].soc == 0)a[i].soc = -1; } sort(a + 1, a + 9, cmp); a[1].len = 100; for (int i = 2; i <= n; ++i) { a[i].len = a[i].soc * a[i - 1].len / a[i - 1].soc; } for (int i = 1; i <= n; ++i) { lens[a[i].name] = a[i].len; } cout << "\\boxed{" << endl; cout << "\\begin{aligned}" << endl; for (int i = 1; i <= n; ++i) { print(i, lens[i]); } cout << "\\end{aligned}" << endl; cout << "}"; return 0; } -
@ 2025-12-3 19:22:44得到题目 Markdown
注:须下载
#!/usr/bin/env python3 """ by jason 2025-07-26 copyright wanwusangzhi 2024-2025 """ import requests, re, sys from bs4 import BeautifulSoup import html2text # ========== 按需修改 ========== BASE_URL = "https://www.bcoi.cn/d/gf24" # 你的站点根域名 LOGIN_URL = f'{BASE_URL}/login' # login page Problem_ID = "food2" HOME_URL = f'{BASE_URL}/p/{Problem_ID}' USERNAME = "" # 你的账号 PASSWORD = "" # 你的密码 # =============================== def main(): s = requests.Session() s.headers.update({ 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) ' 'AppleWebKit/537.36 (KHTML, like Gecko) ' 'Chrome/120.0.0.0 Safari/537.36' }) # 1. 拉登录页,取 csrf login_html = s.get(LOGIN_URL).text soup = BeautifulSoup(login_html, 'lxml') csrf = (soup.find('meta', attrs={'name': 'csrf-token'}) or soup.find('input', attrs={'name': re.compile(r'csrf|_csrf')})) if csrf: csrf = csrf.get('content') or csrf['value'] else: csrf = '' # 站点没开 csrf 验证 # 2. 提交账号密码 resp = s.post(LOGIN_URL, data={ 'uname': USERNAME, 'password': PASSWORD, '_csrf': csrf }, allow_redirects=False) if resp.status_code != 302: raise RuntimeError('登录失败,请检查账号密码或抓包核对字段名') # 3. 登录成功后拿首页 home_html = s.get(HOME_URL).text soup = BeautifulSoup(home_html, 'html.parser') for katex_span in soup.find_all('span', class_='katex'): annotation = katex_span.find('annotation') if annotation: katex_span.replace_with(f"${annotation.text}$") # 可选:加 $ 变成 LaTeX 公式 # 查找class="problem-content"的div problem_content = soup.find('div', class_='problem-content') html=problem_content print(html) # 创建 html2text 处理器 h = html2text.HTML2Text() h.ignore_links = False # 不忽略链接 h.bypass_tables = False # 不忽略表格 h.ignore_images = False # 不忽略图片 h.body_width = 0 # 不自动换行 # 转换 HTML 为 Markdown markdown = h.handle(str(html)) print(markdown) with open("p.md","w",encoding='utf-8') as f: f.write(markdown) if __name__ == '__main__': main() -
@ 2025-11-17 20:07:41不建议给讨论乱加无关标签
- 1