/*
ID:kevin_s1
PROG:holstein
LANG:C++
*/ #include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <cstdlib>
#include <list>
#include <cmath> using namespace std; #define MAXV 26
#define MAXG 16
#define INF 327699 //gobal variable====
int V;
int requirement[MAXV];
int G;
int feed[MAXG][MAXV];
int result; int ans[MAXG];
int vit[MAXV];
int res[MAXG];
//================== //function==========
bool check(){
bool flag = true;
for(int i = 1; i <= V; i++){
if(vit[i] < requirement[i])
flag = false;
}
return flag;
} void DFS(int deep, int count){
if(deep == G + 1){
if(check() == false)
return;
if(count < result){
result = count;
for(int i = 1; i <= result; i++){
res[i] = ans[i];
}
}
return;
}
for(int i = 1; i <= V; i++){
vit[i] += feed[deep][i];
}
ans[count + 1] = deep;
DFS(deep + 1, count + 1);
for(int i = 1; i <= V; i++){
vit[i] -= feed[deep][i];
}
DFS(deep + 1, count);
return;
} //================== int main(){
freopen("holstein.in","r",stdin);
freopen("holstein.out","w",stdout);
cin>>V;
for(int i = 1; i <= V; i++){
cin>>requirement[i];
}
cin>>G;
for(int i = 1; i <= G; i++){
for(int j = 1; j <= V; j++){
cin>>feed[i][j];
}
}
memset(res, 0, sizeof(res));
memset(ans, 0, sizeof(ans));
memset(vit, 0, sizeof(vit));
result = INF;
DFS(1, 0);
cout<<result;
for(int i = 1; i <= result; i++){
cout<<" "<<res[i];
}
cout<<endl;
return 0;
}

USACO holstein AC code的更多相关文章

  1. 20ms Ac Code

    Rectangle Aread C Code #include <stdio.h> int computeArea(int A,int B,int C,int D,int E,int F, ...

  2. 【USACO】AC自动机

    Description 对,这就是裸的AC自动机. 要求:在规定时间内统计出模版字符串在文本中出现的次数. Input 第一行:模版字符串的个数N. 第2->N+1行:N个字符串.(每个模版字符 ...

  3. cjoj P1435 - 【模板题 USACO】AC自动机 && 洛谷 P3796 【模板】AC自动机(加强版)

    又打了一遍AC自动稽. 海星. 好像是第一次打trie图,很久以前就听闻这个思想了.OrzYYB~ // It is made by XZZ #include<cstdio> #inclu ...

  4. BZOJ3940:[USACO]Censoring(AC自动机,栈)

    Description Farmer John has purchased a subscription to Good Hooveskeeping magazine for his cows, so ...

  5. USACO holstein 超时代码

    /* ID:kevin_s1 PROG:holstein LANG:C++ */第八组数据跪了.半天都不出结果 #include <iostream> #include <cstdi ...

  6. 杭电1004 ac code

    #include <stdio.h> #include <string.h> #include <stdlib.h> #define STR_LEN 256 str ...

  7. USACO Cow Cars

    洛谷 P2909 [USACO08OPEN]牛的车Cow Cars https://www.luogu.org/problemnew/show/P2909 JDOJ 2584: USACO 2008 ...

  8. USACO Making the Grade

    洛谷 P2893 [USACO08FEB]修路Making the Grade https://www.luogu.org/problemnew/show/P2893 JDOJ 2566: USACO ...

  9. USACO Mooo Moo

    洛谷 P2214 [USACO14MAR]哞哞哞Mooo Moo 洛谷传送门 JDOJ 2416: USACO 2014 Mar Silver 3.Mooo Moo JDOJ传送门 Descripti ...

随机推荐

  1. 京东的Netty实践,京麦TCP网关长连接容器架构

    背景 早期京麦搭建 HTTP 和 TCP 长连接功能主要用于消息通知的推送,并未应用于 API 网关.随着逐步对 NIO 的深入学习和对 Netty 框架的了解,以及对系统通信稳定能力越来越高的要求, ...

  2. C/C++ 分支预测(likely unlikely)

    看一些代码时,会遇到likely unlikely, 查了查网上的资料,结合自己的理解记录一下. 1. 一些概念 指令周期是指执行一条指令所需要的时间,一般由若干个机器周期组成,是从取指令.分析指令到 ...

  3. 为什么你作为一个.NET的程序员工资那么低?(转)

    最近看到很多抱怨贴,也许有一定的道理,但是你想过没,为什么大部分.NET程序员工资相对低?我个人是这么看的: 大批半罐子水的程序员,永远被局限在.NET的原始的小圈圈里.前端不会(你放弃了一项很重要的 ...

  4. Pytorch 0.3加载0.4模型及其之间版本的变化

    1. 0.4中使用设备:.to(device) 2. 0.4中删除了Variable,直接tensor就可以 3. with torch.no_grad():的使用代替volatile:弃用volat ...

  5. Windows server 2012 R2 与 Windows 2016 的双系统重启选项

    一台主机上,同时安装了Windows 2012R2还有Windows 2016, 但是如何能在任意一个系统重启到另一个呢? 下图中,在Win2012R2中,无法选择重启到2016中. 解决方案 === ...

  6. CentOS7配置Mysql热备份

    Mysql 的安装: 本人习惯讲安装包放在 /usr/local/src/ ①.[root@localhost ~]#cd /usr/local/src/ ②.[root@localhostsrc]# ...

  7. eclipse 创建普通maven项目

  8. 在UTF-8中,一个汉字为什么需要三个字节?(转)

    http://www.cnblogs.com/web21/p/6092414.html UNICODE是万能编码,包含了所有符号的编码,它规定了所有符号在计算机底层的二进制的表示顺序.有关Unicod ...

  9. (转)【Unity Shaders】Vertex Magic —— 访问顶点颜色

    转自:http://blog.csdn.net/candycat1992/article/details/38147767 本系列主要参考<Unity Shaders and Effects C ...

  10. Install Hyper-V on Windows 10

      Enable Hyper-V to create virtual machines on Windows 10.Hyper-V can be enabled in many ways includ ...