摘要:
区别在于图的可达性。如果由任意节点出发(以任意节点为根)可以到达所有节点, 那么遍历就只需要跑一次dfs;若可达性无法保证,则需要多次运行dfs; #include<bits/stdc++.h> using namespace std; #define N 10001 int m,n; int vt 阅读全文
摘要:
#include<bits/stdc++.h> using namespace std; #define N 10001 int m,n,t; int dp[N]; vector<pair<int,int>>v[N]; int main() { cin>>m>>n; int a,b,x; for(i 阅读全文
摘要:
样题通往奥格瑞玛的道路 #include<bits/stdc++.h> using namespace std; const int N=10001; long long f[N]; vector<pair<int,long long>>vec[N]; priority_queue<pair<lon 阅读全文
摘要:
洛谷乌龟棋 与琪露诺速冻青蛙不同的是,移动某步长有次数限制。速冻青蛙由于没有次数限制,步数不用加入dp数组考虑。而乌龟棋步数有限制,以步数构建dp数组,位置可由dp数组计算出。 #include<bits/stdc++.h> using namespace std; long long dp[41] 阅读全文
摘要:
洛谷染色问题,即2024CSP-S第三题。 原题复述: 给定一个长度为 n 的正整数数组 A,其中所有数从左至右排成一排。你需要将 A 中的每个数染成红色或蓝色之一,然后按如下方式计算最终得分: 设 C 为长度为 n 的整数数组,对于 A 中的每个数 左侧没有与其同色的数,则令 Ci=0。否则,记其 阅读全文
摘要:
python import sys InputList=sys.stdin.readlines() print(InputList) 说明:在输入完后,单独另起一行输入CTRL+z,回车 c++ #include<bits/stdc++.h> using namespace std; int h[5 阅读全文