/*
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. macOS Sierra10.12.5 显示允许任何来源

    在终端输入:sudo spctl --master-disable即可.

  2. 检索(retrieval && search )-单目标-多目标跟踪-MTMC Tracking和 ReID

    跨摄像头多目标跟踪(Multi-Target Multi-Camera Tracking, MTMC Tracking) 跨摄像头多目标跟踪(Multi-Target Multi-Camera Tra ...

  3. CSS只是进化的一部分

    Bert Bos是一位计算机科学家,他也是CSS的创始人之一.在CSS的发展过程中,Bos是最早与Håkon Wium Lie(CSS之父)合作的人之一.在1996年,他加入了World Wide W ...

  4. css之图片羽化处理

    需求: 对图片做css羽化处理 实现: <!DOCTYPE html> <html lang="en"> <head> <meta cha ...

  5. TOJ 1220 填数字游戏 / 深搜

    填数字游戏 时间限制(普通/Java):1000MS/10000MS     运行内存限制:65536KByte 描述 有个小游戏,让你填写以下方框,要求: a1+a2+a3+M=b1+b2+b3+M ...

  6. High performance find query using lean() in mongoose

    原文: http://www.tothenew.com/blog/high-performance-find-query-using-lean-in-mongoose-2/ ------------- ...

  7. (转)SVN服务器搭建和使用(三) 附vs2013 svn插件

    转自:http://www.cnblogs.com/xiaobaihome/archive/2012/03/20/2408089.html vs 2013 svn插件:http://www.visua ...

  8. String escape/unescape into XML

    Is there any C# function which could be used to escape and un-escape a string, which could be used t ...

  9. [Functional Programming] Using JS, FP approach with Arrow or State Monad

    Using Naive JS: const {modify, get} = require('crocks/State'); const K = require('crocks/combinators ...

  10. Spring MVC中使用errors标签

    先创建一个实体类,后续的验证都基于这个实体类: public class Goods { private String goodsName; private String city; private ...