/*
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. 标识符(IDentifier)

    ylbtech-Miscellaneos:标识符(IDentifier) A,返回顶部 1, 标识符(IDentifier)是指用来标识某个实体的一个符号.在不同的应用环境下有不同的含义. 在日常生活 ...

  2. boost并发编程boost::atomic

    三个用于并发编程的组件: atomic,thread,asio(用于同步和异步io操作)   atomic atomic,封装了不同计算机硬件的底层操作原语,提供了跨平台的原子操作功能,解决并发竞争读 ...

  3. 再看copy_on_write缩小临界区的例子

    本例子是模拟的读者写者问题,采用shared_ptr+写时拷贝实现,其中我觉得一个比较值得注意的地方是考虑到对象可能在临界区析构而将析构移除临界区,这对于多线程来说要多看多思. #include< ...

  4. WebService入门Demo

    以前写博客最主要的就是不知道写什么东西,现在感觉能写点东西,就是感觉博客随笔的标题挺难取的,最近工作中刚好用到了WebService,刚好可以写一篇博客.去年工作的时候自己也用到过,只是知道调用一些W ...

  5. springboot 项目mybatis plus 设置 jdbcTypeForNull (oracle数据库需配置JdbcType.NULL, 默认是Other)

    方法1: application.yml mybatis-plus: configuration: jdbc-type-for-null: 'null' #注意:单引号 方法2: 查看mp-start ...

  6. Hadoop视频教程汇总

    一 慕课网 1.Hadoop大数据平台架构与实践--基础篇(已学习) 链接:https://www.imooc.com/learn/391 2.Hadoop进阶(已学习) 链接:https://www ...

  7. 利用样式——android2.3实现android4.0风格的edittext

    先看效果: 思路:在源码里找到4.0风格的图片作为背景,xml文件定义点击时候边框变化 步骤: ①.在F:\sdk\sdk\platforms\android-14\data\res\drawable ...

  8. Logcat用法初探

    首先定位到adb所在的目录 将手机连接上电脑. 在命令行运行: adb devices 这个命令可以列出所有连上的移动设备. 在命令行运行: adb logcat 可以显示日志.   以下是例子截图: ...

  9. GPUImage API 文档之GPUImageFilter类

    GPUImageFilter类 方法 - (id)initWithVertexShaderFromString:(NSString *)vertexShaderString fragmentShade ...

  10. ASP.NET绑定学习

    1.直接绑定到页面成员<asp:Repeater ... DataSource='<%#页面方法或属性%>'></asp:Repeater> 2.绑定到数组< ...