摘要: 图有最小生成树的充要条件:图是可达的 常见表述:从某节点出发可到达其余节点 #include<bits/stdc++.h> using namespace std; struct edge { int a,b,w; bool operator<(edge &other) { return w<oth 阅读全文
posted @ 2024-12-02 20:13 邓佑孤 阅读(7) 评论(0) 推荐(0)
摘要: 题目传送门 #include<bits/stdc++.h> using namespace std; #define max(a,b) a>b?a:b #define min(a,b) a>b?b:a int n;int a[1001];int g[1001][1001]; int main() { 阅读全文
posted @ 2024-12-02 11:22 邓佑孤 阅读(11) 评论(0) 推荐(0)
摘要: 入门题目: 最大子树和、女仆咖啡厅桌游吧 #include<bits/stdc++.h> using namespace std; int f[16001];int cnt[16001];int a[16001]; vector<int>e[16001];int n;int mx=-10000000 阅读全文
posted @ 2024-11-22 20:47 邓佑孤 阅读(6) 评论(0) 推荐(0)
摘要: 洛谷乌龟棋 与琪露诺速冻青蛙不同的是,移动某步长有次数限制。速冻青蛙由于没有次数限制,步数不用加入dp数组考虑。而乌龟棋步数有限制,以步数构建dp数组,位置可由dp数组计算出。 #include<bits/stdc++.h> using namespace std; long long dp[41] 阅读全文
posted @ 2024-11-10 10:53 邓佑孤 阅读(6) 评论(0) 推荐(0)
摘要: 洛谷染色问题,即2024CSP-S第三题。 原题复述: 给定一个长度为 n 的正整数数组 A,其中所有数从左至右排成一排。你需要将 A 中的每个数染成红色或蓝色之一,然后按如下方式计算最终得分: 设 C 为长度为 n 的整数数组,对于 A 中的每个数 左侧没有与其同色的数,则令 Ci=0。否则,记其 阅读全文
posted @ 2024-11-07 21:18 邓佑孤 阅读(41) 评论(0) 推荐(0)
摘要: python import sys InputList=sys.stdin.readlines() print(InputList) 说明:在输入完后,单独另起一行输入CTRL+z,回车 c++ #include<bits/stdc++.h> using namespace std; int h[5 阅读全文
posted @ 2024-11-06 20:53 邓佑孤 阅读(13) 评论(0) 推荐(0)
摘要: n=int(input()) def get_premi(max_val): v=[1]*(max_val+1) for x in range(2,max_val+1): if v[x]: for i in range(x*x,max_val+1,x): v[i]=0 premi=[i for i 阅读全文
posted @ 2024-11-05 21:53 邓佑孤 阅读(9) 评论(0) 推荐(0)
摘要: 以洛谷无向图求环问题为例 #include<bits/stdc++.h> using namespace std; #define ll long long #define reg register int int n,m;int a[19][19];ll f[1<<19][19];ll res=0 阅读全文
posted @ 2024-10-09 10:23 邓佑孤 阅读(9) 评论(0) 推荐(0)
摘要: char *p1,*p2,buf[100000]; #define nc() (p1==p2 && (p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++) inline int read() { int fl=1,w=0;char ch=g 阅读全文
posted @ 2024-10-02 21:15 邓佑孤 阅读(26) 评论(0) 推荐(0)
摘要: 洛谷P1725 记忆化搜索显然更简单,因为遍历了所有可能(包括无法实现的解),用时长,最后两个点会TLE #include<bits/stdc++.h> using namespace std; int n,l,r;int v[300005];int f[300005]; int m(int id) 阅读全文
posted @ 2024-09-11 19:39 邓佑孤 阅读(6) 评论(0) 推荐(0)