USACO holstein AC code
/*
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的更多相关文章
- 20ms Ac Code
Rectangle Aread C Code #include <stdio.h> int computeArea(int A,int B,int C,int D,int E,int F, ...
- 【USACO】AC自动机
Description 对,这就是裸的AC自动机. 要求:在规定时间内统计出模版字符串在文本中出现的次数. Input 第一行:模版字符串的个数N. 第2->N+1行:N个字符串.(每个模版字符 ...
- cjoj P1435 - 【模板题 USACO】AC自动机 && 洛谷 P3796 【模板】AC自动机(加强版)
又打了一遍AC自动稽. 海星. 好像是第一次打trie图,很久以前就听闻这个思想了.OrzYYB~ // It is made by XZZ #include<cstdio> #inclu ...
- BZOJ3940:[USACO]Censoring(AC自动机,栈)
Description Farmer John has purchased a subscription to Good Hooveskeeping magazine for his cows, so ...
- USACO holstein 超时代码
/* ID:kevin_s1 PROG:holstein LANG:C++ */第八组数据跪了.半天都不出结果 #include <iostream> #include <cstdi ...
- 杭电1004 ac code
#include <stdio.h> #include <string.h> #include <stdlib.h> #define STR_LEN 256 str ...
- USACO Cow Cars
洛谷 P2909 [USACO08OPEN]牛的车Cow Cars https://www.luogu.org/problemnew/show/P2909 JDOJ 2584: USACO 2008 ...
- USACO Making the Grade
洛谷 P2893 [USACO08FEB]修路Making the Grade https://www.luogu.org/problemnew/show/P2893 JDOJ 2566: USACO ...
- USACO Mooo Moo
洛谷 P2214 [USACO14MAR]哞哞哞Mooo Moo 洛谷传送门 JDOJ 2416: USACO 2014 Mar Silver 3.Mooo Moo JDOJ传送门 Descripti ...
随机推荐
- Install OpenCV-Python in Ubuntu
之前安装python版opencv,需要下载whl文件,进行安装,这是在window环境下的: 安装opencv_python,下载whl包 安装系统python下的opencv 今天发现一个简单的方 ...
- iOS开发-UITableView自定义Cell
UITableView在iOS中开发的重要地位是毋庸置疑的,基本上应用中用到的比例是一半左右,而且大部分情况都是需要自定义单元格的,这样用户看到的App才能更有美感.之前写过UITableView的基 ...
- IT知识大扫盲
做了这么多软件开发,下列一些知识不一定都懂. 首先,说一些电子商务扫盲的名词: 常见的电子商务类型有:C2C.B2B.B2C.C2B.O2O等等,下面来简要说明下这几种类型. C2C(Customer ...
- Java信号量Semaphore
Semaphore Semaphore分为单值和多值两种,前者只能被一个线程获得,后者可以被若干个线程获得. Semaphore实现的功能就类似厕所有5个坑,假如有10个人要上厕所,那么同时只能有多少 ...
- 转:Deep learning系列(十五)有监督和无监督训练
http://m.blog.csdn.net/article/details?id=49591213 1. 前言 在学习深度学习的过程中,主要参考了四份资料: 台湾大学的机器学习技法公开课: Andr ...
- sklearn文本特征提取
http://cloga.info/2014/01/19/sklearn_text_feature_extraction/ 文本特征提取 词袋(Bag of Words)表征 文本分析是机器学习算法的 ...
- Java-JUC(十一):线程8锁
题目: 判断以下8种情况,输出的内容 题目一:一个Number实例对象number,两个非静态同步方法getOne,getTwo,两个线程打印输出(一个线程调用number.getOne,另外一个线程 ...
- unity3d Player Settings 中的Stripping Level(剥离等级)对应每个等级具体剥离了哪些库
http://docs.unity3d.com/410/Documentation/ScriptReference/MonoCompatibility.html
- Node js : Best way to define entity class
If you start to use a DB like mongo, you might be better off creating objects with mongoose but th ...
- Creating fields using CSOM
When creating a field, whether you are using CAML, server-side object mode, or one of the client-s ...