From 9c505e630f07012cbe8493313ce70c4d257a71d1 Mon Sep 17 00:00:00 2001 From: Zengtudor Date: Thu, 6 Nov 2025 21:00:34 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E5=A4=9A=E4=B8=AA?= =?UTF-8?q?=E7=AE=97=E6=B3=95=E9=A2=98=E7=9B=AE=E8=A7=A3=E5=86=B3=E6=96=B9?= =?UTF-8?q?=E6=A1=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 添加P14357.cpp、employ.cpp、replace.cpp、road.cpp和club.cpp的初始实现 refactor: 移除P14361.cpp中未使用的dfs函数和smallsolve函数 --- src/11/4/P14361.cpp | 21 ---------- src/11/6/P14357.cpp | 3 ++ src/11/6/club.cpp | 98 ++++++++++++++++++++++++++++++++++++++++++++ src/11/6/employ.cpp | 34 +++++++++++++++ src/11/6/replace.cpp | 45 ++++++++++++++++++++ src/11/6/road.cpp | 95 ++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 275 insertions(+), 21 deletions(-) create mode 100644 src/11/6/P14357.cpp create mode 100644 src/11/6/club.cpp create mode 100644 src/11/6/employ.cpp create mode 100644 src/11/6/replace.cpp create mode 100644 src/11/6/road.cpp diff --git a/src/11/4/P14361.cpp b/src/11/4/P14361.cpp index 25cad75..4baefce 100644 --- a/src/11/4/P14361.cpp +++ b/src/11/4/P14361.cpp @@ -18,26 +18,6 @@ struct S{ std::vectors; std::bitset vis; -sl void dfs(ll now,ll nans){ - if(now==n+1){ - ans=std::max(ans,nans); - return; - } - for(ll i=1;i<=3;i++){ - if(club[i]>=n/2)continue; - club[i]++; - dfs(now+1,nans+a[now][i]); - club[i]--; - } -} - -sl bool smallsolve(){ - if(n>10)return false; - dfs(0,0); - std::cout<>n; ans=0; @@ -47,7 +27,6 @@ sl void solve(){ for(ll i=1;i<=n;i++){ std::cin>>a[i][1]>>a[i][2]>>a[i][3]; } - if(smallsolve())return; for(ll i=1;i<=n;i++){ ll tmp[4]; for(ll j=1;j<=3;j++)tmp[j]=a[i][j]; diff --git a/src/11/6/P14357.cpp b/src/11/6/P14357.cpp new file mode 100644 index 0000000..294989d --- /dev/null +++ b/src/11/6/P14357.cpp @@ -0,0 +1,3 @@ +int main(){ + +} \ No newline at end of file diff --git a/src/11/6/club.cpp b/src/11/6/club.cpp new file mode 100644 index 0000000..f7f55a0 --- /dev/null +++ b/src/11/6/club.cpp @@ -0,0 +1,98 @@ +#include +using namespace std; +using ll = long long; + +const ll maxn = 1e5+7; +ll n,a[maxn][4],numclub[3+1],smallans=0; +bool viss[maxn]; + +#define printf + +static inline void dfs(ll nn,ll nans){ + if(nn>n){ + smallans=max(smallans,nans); + return; + } + + for(ll i=1;i<=3;i++){ + if(numclub[i]>=n/2)continue; + numclub[i]++; + dfs(nn+1,nans+a[nn][i]); + numclub[i]--; + } +} + +static inline void solvesmall(){ + smallans=0; + numclub[0]=numclub[1]=numclub[2]=numclub[3]=0; + for(ll i=1;i<=n;i++){ + for(ll j=1;j<=3;j++){ + cin>>a[i][j]; + } + } + dfs(1,0); + cout<>n; + if(n<=11){ + solvesmall(); + return; + } + numclub[0]=numclub[1]=numclub[2]=0; + for(ll i=0;i<=n;i++)viss[i]=false; + struct S{ + ll diff,size,club,i; + inline bool operator<(const S&other)const{ + if(diff==other.diff)return size>other.size; + return diff>other.diff; + } + }; + vector s; + s.reserve(n+1); + for(ll i=1;i<=n;i++){ + struct Tmp{ + ll size,j; + inline bool operator<(const Tmp&other)const{ + return size>other.size; + } + }tmp[4]; + for(ll j=1;j<=3;j++){ + ll b; + cin>>b; + tmp[j]={b,j}; + } + sort(tmp+1,tmp+1+3); + for(ll j=1;j<=3;j++){ + s.push_back({tmp[j].size-tmp[2].size,tmp[j].size,tmp[j].j,i}); + // printf("S{diff=%lld, size=%lld, club=%lld, i=%lld}\n",s.back().diff,s.back().size,s.back().club,s.back().i); + } + } + sort(s.begin(),s.end()); + for(ll i=0;i>t; + while(t--)solve(); +} \ No newline at end of file diff --git a/src/11/6/employ.cpp b/src/11/6/employ.cpp new file mode 100644 index 0000000..87b768b --- /dev/null +++ b/src/11/6/employ.cpp @@ -0,0 +1,34 @@ +#include +using namespace std; +using ll = long long; + +const ll maxn = 500+7,p=998'244'353; +ll n,m,a[maxn],ans=0; +string s; + +int main(){ + // freopen("employ.in","r",stdin); + // freopen("employ.out","w",stdout); + iostream::sync_with_stdio(false); + cin.tie(nullptr); + cin>>n>>m; + cin>>s; + s=" "+s; + for(ll i=1;i<=n;i++){ + cin>>a[i]; + } + sort(a+1,a+1+n); + do{ + ll no=0; + for(ll i=1;i<=n;i++){ + if(no>=a[i]){ + continue; + } + if(s[i]=='0'){ + no++; + } + } + if(n-no>=m)ans=(ans+1)%p; + }while(next_permutation(a+1,a+1+n)); + cout< +using namespace std; +using ll = long long; + +const ll maxn = 2e5+7; +ll n,q; + +string s[maxn][2],r[maxn][2]; +static inline bool issame(int idx,const string&a,const string&b){ + if(idx+b.size()>a.size()){ + return false; + } + for(int i=0;i>n>>q; + for(int i=1;i<=n;i++){ + cin>>s[i][0]>>s[i][1]; + } + for(ll i=1;i<=q;i++){ + cin>>r[i][0]>>r[i][1]; + ll ans=0; + for(ll j=1;j<=n;j++){ + for(ll k=0;k +using namespace std; +using ll = long long; +#define sl static inline +const int maxm = 1e6+7,maxn=1e4+7; +int n,m,k; +struct R{ + int u,v,w; + inline bool operator<(const R&o)const{ + return w vr(r+1,r+1+m); + for(int i=1;i<=k;i++){ + for(ll j=1;j>n>>m>>k; + for(int i=1;i<=m;i++){ + cin>>r[i].u>>r[i].v>>r[i].w; + } + for(int i=1;i<=k;i++){ + cin>>c[i].w; + for(int j=1;j<=n;j++){ + cin>>c[i].cw[j]; + } + } + if(checkA()){ + return 0; + } + if(checkB()){ + return 0; + } +} \ No newline at end of file