F - Food

本文介绍了一种解决餐厅服务问题的算法,旨在通过合理的食物和饮料分配方案来满足尽可能多顾客的需求。考虑到每位顾客对食物和饮料的不同偏好,以及餐厅提供的种类数量限制,该算法通过构建图模型并运用最大流最小割原理找到最优解。

https://vjudge.net/contest/402729#problem/F

You, a part-time dining service worker in your college’s dining hall, are now confused with a new problem: serve as many people as possible.
  The issue comes up as people in your college are more and more difficult to serve with meal: They eat only some certain kinds of food and drink, and with requirement unsatisfied, go away directly.
  You have prepared F (1 <= F <= 200) kinds of food and D (1 <= D <= 200) kinds of drink. Each kind of food or drink has certain amount, that is, how many people could this food or drink serve. Besides, You know there’re N (1 <= N <= 200) people and you too can tell people’s personal preference for food and drink.
  Back to your goal: to serve as many people as possible. So you must decide a plan where some people are served while requirements of the rest of them are unmet. You should notice that, when one’s requirement is unmet, he/she would just go away, refusing any service.

Input

  There are several test cases.
  For each test case, the first line contains three numbers: N,F,D, denoting the number of people, food, and drink.
  The second line contains F integers, the ith number of which denotes amount of representative food.
  The third line contains D integers, the ith number of which denotes amount of representative drink.
  Following is N line, each consisting of a string of length F. e jth character in the ith one of these lines denotes whether people i would accept food j. “Y” for yes and “N” for no.
  Following is N line, each consisting of a string of length D. e jth character in the ith one of these lines denotes whether people i would accept drink j. “Y” for yes and “N” for no.
  Please process until EOF (End Of File).

Output

  For each test case, please print a single line with one integer, the maximum number of people to be satisfied.

Sample Input

4 3 3
1 1 1
1 1 1
YYN
NYY
YNY
YNY
YNY
YYN
YYN
NNY

Sample Output

3

Sponsor

代码:

#include <iostream>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <deque>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <map>
#include <stack>
#include <set>
#include<time.h>
using namespace std;
typedef long long ll;
const ll maxn=200000+10;
ll n,m,k,s,t,h[maxn],cur[maxn],cnt=1,vis[maxn];
ll F,D;
char x[maxn];
struct node{
    ll to,nt,w;
}e[maxn];
void add(ll u,ll v,ll w)
{
    e[++cnt]={v,h[u],w};
    h[u]=cnt;
}
queue<ll>q;
bool bfs()
{
    memset(vis,0,sizeof(vis));
    vis[s]=1;
    q.push(s);
    while(!q.empty())
    {
        ll u=q.front();
        q.pop();
        cur[u]=h[u];
        for(ll i=h[u];i;i=e[i].nt)
        {
            ll v=e[i].to,w=e[i].w;
            if(w&&!vis[v])
            {
                vis[v]=vis[u]+1;
                q.push(v);
            }
        }
    }
    return vis[t];

}
ll dfs(ll u,ll flow)
{
    if(u==t)
        return flow;
    ll res=flow;
    for(ll i=cur[u];i;i=e[i].nt)
    {
        ll v=e[i].to,w=e[i].w;
        if(w&&vis[u]+1==vis[v])
        {
            ll now=dfs(v,min(res,w));
            if(!now)
                vis[v]=1;
            else
            {
                e[i].w-=now;
                e[i^1].w+=now;
                res-=now;
            }
        }
        if(!res)
        return flow;
    }
    return flow-res;
}
int main()
{
    while(~scanf("%lld %lld %lld",&n,&F,&D))
    {
        memset(cur,0,sizeof(cur));
        memset(h,0,sizeof(h));
        s=0;
        t=n*2+F+D+1;
        cnt=1;
        for(int j=1;j<=F;j++)
        {
            int u;
            scanf("%d",&u);
            add(0,j,u);
            add(j,0,0);
        }
        for(int j=1;j<=D;j++)
        {
            int u;
            scanf("%d",&u);
            add(j+F+n*2,t,u);
            add(t,j+F+n*2,0);
        }
        for(int i=1;i<=n;i++)
        {
            scanf("%s",x);
            int len=strlen(x);
            for(int j=0;j<len;j++)
            {
                if(x[j]=='Y')
                {
                    add(j+1,i+F,1);
                    add(i+F,j+1,0);
                }
            }

            add(i+F,i+F+n,1);
            add(i+F+n,i+F,0);
        }
        for(int i=1;i<=n;i++)
        {
            scanf("%s",x);
            int len=strlen(x);
            for(int j=0;j<len;j++)
            {
                if(x[j]=='Y')
                {
                    add(i+F+n,F+n*2+j+1,1);
                    add(F+n*2+j+1,i+F+n,0);
                }
            }
        }
        ll ans=0;
        while(!q.empty())
            q.pop();
        while(bfs())
        {
            ans+=dfs(s,0x7fffffff);
            //cout<<ans<<endl;
        }
        printf("%lld\n",ans);
    }

    return 0;
}

 

内容概要:本文详细介绍了一种基于Simulink的表贴式永磁同步电机(SPMSM)有限控制集模型预测电流控制(FCS-MPCC)仿真系统。通过构建PMSM数学模型、坐标变换、MPC控制器、SVPWM调制等模块,实现了对电机定子电流的高精度跟踪控制,具备快速动态响应和低稳态误差的特点。文中提供了完整的仿真建模步骤、关键参数设置、核心MATLAB函数代码及仿真结果分析,涵盖转速、电流、转矩和三相电流波形,验证了MPC控制策略在动态性能、稳态精度和抗负载扰动方面的优越性,并提出了参数自整定、加权代价函数、模型预测转矩控制和弱磁扩速等优化方向。; 适合人群:自动化、电气工程及其相关专业本科生、研究生,以及从事电机控制算法研究与仿真的工程技术人员;具备一定的电机原理、自动控制理论和Simulink仿真基础者更佳; 使用场景及目标:①用于永磁同步电机模型预测控制的教学演示、课程设计或毕业设计项目;②作为电机先进控制算法(如MPC、MPTC)的仿真验证平台;③支撑科研中对控制性能优化(如动态响应、抗干扰能力)的研究需求; 阅读建议:建议读者结合Simulink环境动手搭建模型,深入理解各模块间的信号流向与控制逻辑,重点掌握预测模型构建、代价函数设计与开关状态选择机制,并可通过修改电机参数或控制策略进行拓展实验,以增强实践与创新能力。
根据原作 https://pan.quark.cn/s/23d6270309e5 的源码改编 湖北省黄石市2021年中考数学试卷所包含的知识点广泛涉及了中学数学的基础领域,涵盖了实数、科学记数法、分式方程、几何体的三视图、立体几何、概率统计以及代数方程等多个方面。 接下来将对每道试题所关联的知识点进行深入剖析:1. 实数与倒数的定义:该题目旨在检验学生对倒数概念的掌握程度,即一个数a的倒数表达为1/a,因此-7的倒数可表示为-1/7。 2. 科学记数法的运用:科学记数法是一种表示极大或极小数字的方法,其形式为a×10^n,其中1≤|a|<10,n为整数。 此题要求学生运用科学记数法表示一个天文单位的距离,将1.4960亿千米转换为1.4960×10^8千米。 3. 分式方程的求解方法:考察学生解决包含分母的方程的能力,题目要求找出满足方程3/(2x-1)=1的x值,需通过消除分母的方式转化为整式方程进行解答。 4. 三视图的辨认:该题目测试学生对于几何体三视图(主视图、左视图、俯视图)的认识,需要识别出具有两个相同视图而另一个不同的几何体。 5. 立体几何与表面积的计算:题目要求学生计算由直角三角形旋转形成的圆锥的表面积,要求学生对圆锥的底面积和侧面积公式有所了解并加以运用。 6. 统计学的基础概念:题目涉及众数、平均数、极差和中位数的定义,要求学生根据提供的数据信息选择恰当的统计量。 7. 方程的整数解求解:考察学生在实际问题中进行数学建模的能力,通过建立方程来计算在特定条件下帐篷的搭建方案数量。 8. 三角学的实际应用:题目通过在直角三角形中运用三角函数来求解特定线段的长度。 利用正弦定理求解AD的长度是解答该问题的关键。 9. 几何变换的应用:题目要求学生运用三角板的旋转来求解特定点的...
由于未提供具体的引用内容,下面是一些通用的解决 “Artifact canteen - food - buyer:war exploded” 部署时出现错误的方法: ### 查看服务器日志详情 服务器日志通常会记录详细的错误信息,是解决部署问题的关键。不同的服务器查看日志的位置和方式有所不同: #### Tomcat Tomcat 的日志文件通常位于 `tomcat-home/logs` 目录下,主要查看 `catalina.out` 或 `catalina.YYYY-MM-DD.log` 文件。可以使用以下命令查看日志: ```bash tail -f /path/to/tomcat/logs/catalina.out ``` 在日志中查找关键字如 `ERROR`、`Exception` 等,定位具体的错误信息。 #### Jetty Jetty 的日志文件一般在 `jetty-home/logs` 目录下,查看 `jetty-YYYY_MM_DD.log` 文件。同样可以使用 `tail -f` 命令实时查看日志: ```bash tail -f /path/to/jetty/logs/jetty-YYYY_MM_DD.log ``` ### 常见错误及解决方法 #### 依赖问题 如果日志中显示 `ClassNotFoundException` 或 `NoClassDefFoundError` 等错误,可能是项目的依赖缺失或版本不兼容。 - 检查 `pom.xml`(如果是 Maven 项目)或 `build.gradle`(如果是 Gradle 项目)文件,确保所有依赖都正确添加且版本兼容。 - 清理并重新构建项目,以确保依赖被正确下载。 ```bash # Maven 项目 mvn clean install # Gradle 项目 gradle clean build ``` #### 配置问题 日志中出现配置相关的错误,如 `ConfigurationException` 等,可能是项目的配置文件有问题。 - 检查 `web.xml`、`application.properties` 或 `application.yml` 等配置文件,确保配置项正确。 - 检查服务器的配置,如端口号、上下文路径等是否与项目配置一致。 #### 权限问题 如果日志显示文件或目录访问权限不足的错误,需要检查相关文件和目录的权限。 - 确保 Tomcat 或 Jetty 有足够的权限访问项目文件和目录。 ```bash chmod -R 755 /path/to/project ``` #### 内存问题 日志中出现 `OutOfMemoryError` 等错误,可能是服务器内存不足。 - 调整服务器的 JVM 内存参数,例如在 `catalina.sh`(Tomcat)或 `start.ini`(Jetty)中增加 `Xmx` 和 `Xms` 参数。 ```bash # Tomcat 示例 JAVA_OPTS="-Xmx512m -Xms256m" ```
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值