This commit is contained in:
Zengtudor 2024-09-15 17:35:54 +08:00
parent c69cdd105f
commit 194e80fe0d
5 changed files with 207 additions and 34 deletions

View File

@ -0,0 +1,54 @@
#include <cmath>
#include <cstdio>
#include<iostream>
#include <numeric>
#include <sstream>
#include <vector>
typedef unsigned int u8;
std::ostream& operator<<(std::ostream &os,const std::vector<int> &v){
os<<"vector { ";
for(int i=0;(u8)i<v.size()-1;i++){
os<<v[i]<<" ,";
}
os<<v[v.size()-1]<<" }";
return os;
}
template<typename ...Args>
void print(const Args& ...args){
((std::cout<<args),...);
}
template<typename ...Args>
void println(const Args& ...args){
std::stringstream ss;
((ss<<args<<" "),...);
ss<<"\n";
print(ss.str());
}
#define NAME_VALUE(v)#v,":",(v)
int main(){
println("Hello,World!","-by","Zengtudor");
println("End");
println(NAME_VALUE(std::pow(2,10)));
println(NAME_VALUE((int)0x7FFFFFFF));
std::vector<int> v(10);
v[0]=1;
for(int i=1;(u8)i<v.size();i++){
v[i]=(v[i-1]*3+2)%49;
}
println(NAME_VALUE(v));
println(NAME_VALUE(std::pow(3, 8)));
println(NAME_VALUE(std::gcd(41184, 65208)));
for(int i=1;i<=1e4;i++){
print(i,",");
}
print("\n");
}

46
20240908/P2016/P2016.cpp Normal file
View File

@ -0,0 +1,46 @@
#include <algorithm>
#include <climits>
#include <iostream>
#include <vector>
const int MAX_N = 1.5e5+5;
int n;
std::vector<int> v[MAX_N];
int dp[MAX_N][2];
void dfs(const int n,const int f){
for(auto &i:v[n]){
if(i!=f)dfs(i, n);
else continue;
dp[n][1]+=std::min(dp[i][0],dp[i][1]);
dp[n][0]+=dp[i][1];
}
}
int main(){
std::cin>>n;
for(int _i=0;_i<n;_i++){
dp[_i][1]=1;
int i,k;
std::cin>>i>>k;
for(int j=1;j<=k;j++){
int r;
std::cin>>r;
v[i].push_back(r);
v[r].push_back(i);
}
}
dfs(0,-1);
std::cout<<std::min(dp[0][1],dp[0][0]);
}
/*
4
0 1 1
1 2 2 3
2 0
3 0
*/

43
20240915/1808/1808.cpp Normal file
View File

@ -0,0 +1,43 @@
//http://noi.openjudge.cn/ch0206/1808
#include <algorithm>
#include <iostream>
#include <sstream>
#include <string>
const int MAX_LEN = 200+5;
std::string s1,s2;
int dp[MAX_LEN][MAX_LEN];
template<typename T>
T max(const T t1,const T t2,const T t3){
return std::max(t1,std::max(t2,t3));
}
template<typename ...Args>
void print(const Args&...args){
std::stringstream ss;
((ss<<args),...);
std::cout<<ss.str();
return;
}
int main(){
while (std::cin>>s1>>s2) {
for(int i=1;i<=s1.length();i++){
for(int j=1;j<=s2.length();j++){
if(s1[i-1]==s2[j-1]){
dp[i][j] = dp[i-1][j-1] + 1;
}else{
dp[i][j] = max(dp[i][j-1], dp[i-1][j], dp[i-1][j-1]);
}
}
}
// std::cout<<dp[s1.length()][s2.length()]<<"\n";
print(dp[s1.length()][s2.length()],"\n");
}
}
/*
abcfbc abfcab
programming contest
abcd mnp
*/

View File

@ -1,38 +1,59 @@
#include <cmath>
// #include <cmath>
// #include<iostream>
// #include <numeric>
// #include <sstream>
// #include <vector>
// typedef unsigned int u8;
// std::ostream& operator<<(std::ostream &os,const std::vector<int> &v){
// os<<"vector { ";
// for(int i=0;(u8)i<v.size()-1;i++){
// os<<v[i]<<" ,";
// }
// os<<v[v.size()-1]<<" }";
// return os;
// }
// template<typename ...Args>
// void print(const Args& ...args){
// ((std::cout<<args),...);
// }
// template<typename ...Args>
// void println(const Args& ...args){
// std::stringstream ss;
// ((ss<<args<<" "),...);
// ss<<"\n";
// print(ss.str());
// }
// #define NAME_VALUE(v)#v,":",(v)
// int main(){
// println("Hello,World!","-by","Zengtudor");
// println("End");
// println(NAME_VALUE(std::pow(2,10)));
// println(NAME_VALUE((int)0x7FFFFFFF));
// std::vector<int> v(10);
// v[0]=1;
// for(int i=1;(u8)i<v.size();i++){
// v[i]=(v[i-1]*3+2)%49;
// }
// println(v);
// println(NAME_VALUE(std::pow(3, 8)));
// println(NAME_VALUE(std::gcd(41184, 65208)));
// }
#include<iostream>
#include <vector>
#include<string>
void print(){
std::ostream& operator<<(std::ostream &os,const std::vector<int> &v){
os<<"vector { ";
for(int i=0;i<v.size()-1;i++){
os<<v[i]<<" ,";
}
os<<v[v.size()-1]<<" }";
return os;
}
template<typename ...Args>
void print(const Args& ...args){
((std::cout<<args),...);
}
template<typename ...Args>
void println(const Args& ...args){
(print(args," "),...);
print("\n");
}
#define NAME_VALUE(v)#v,":",(v)
int main(){
println("Hello,World!","-by","Zengtudor");
println("End");
println(NAME_VALUE(std::pow(2,10)));
println(NAME_VALUE((int)0x7FFFFFFF));
std::vector<int> v(10);
v[0]=1;
for(int i=1;i<v.size();i++){
v[i]=(v[i-1]*3+2)%49;
}
println(v);
std::string s;
std::cin>>s;
}

View File

@ -49,3 +49,12 @@ target("bitset")
target("P1352")
add_files("20240907/P1352/P1352.cpp")
target("testTpl")
add_files("20240907/testTpl/testTpl.cpp")
target("P2016")
add_files("20240908/P2016/P2016.cpp")
target("oj1808")
add_files("20240915/1808/1808.cpp")