/****************************************************************************************************
去年天津区预赛水题,刚开始没想法,后来想应该是直接dfs就行了,然后就写了这个屎一样的代码。。。写得真难看啊。。。
****************************************************************************************************/
#include <iostream>
#include <functional>
#include <algorithm>
//#include <hash_map> //Visual C++ lib
#include <complex>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <sstream>
#include <utility>
#include <bitset>
#include <cctype>
#include <cstdio>
#include <limits>
#include <memory>
#include <string>
#include <vector>
#include <cmath>
#include <ctime>
#include <queue>
#include <stack>
#include <list>
#include <map>
#include <set>
using namespace std;
#define LOWBIT(x) ( (x) & ( (x) ^ ( (x) - 1 ) ) )
#define CLR(x, k) memset((x), (k), sizeof(x))
#define CPY(t, s) memcpy((t), (s), sizeof(s))
#define LEN(s) static_cast<int>( strlen((s)) )
#define SZ(s) static_cast<int>( (s).sizeof() )
typedef double LF;
typedef long long LL; //GNU C++
typedef unsigned long long ULL;
//typedef __int64 LL; //Visual C++ 2010
//typedef unsigned __int64 ULL;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef pair<double, double> PDD;
//typedef hash_map<int, int>::iterator HMI;
typedef map<int, int>::iterator MI;
typedef vector<int>::iterator VI;
typedef list<int>::iterator LI;
typedef set<int>::iterator SI;
const int INF_INT = 0x3f3f3f3f;
const LL INF_LL = 0x7fffffffffffffffLL; //15f
const double oo = 10e9;
const double eps = 10e-9;
const double PI = acos(-1.0);
const int MAXP = 23;
struct Player
{
string name, pos;
int key;
}player[MAXP];
map<string, int>NP;
map<string, int>SP;
int pcnt[6], flag[6], maze[MAXP][MAXP];
bool sign[MAXP];
bool inline cmp(const Player &pa, const Player &pb)
{
return SP[ pa.pos ] < SP[ pb.pos ];
}
void preprocess()
{
SP.clear();
SP.insert( pair<string, int>("goalkeeper", 0) );
SP.insert( pair<string, int>("defender", 1) );
SP.insert( pair<string, int>("midfielder", 2) );
SP.insert( pair<string, int>("striker", 3) );
return ;
}
int maxi;
void dfs(int crt, int state, int tot, int gk_cnt, int df_cnt, int mf_cnt, int sk_cnt)
{
if (0 == state && gk_cnt >= 1)
{
crt = flag[state] - 1;
++state;
}
if (1 == state && df_cnt >= 4)
{
crt = flag[state] - 1;
++state;
}
if (2 == state && mf_cnt >= 4)
{
crt = flag[state] - 1;
++state;
}
if (3 == state && sk_cnt >= 2)
{
crt = flag[state] - 1;
++state;
}
if (4 == state)
{
maxi = max(maxi, tot);
return ;
}
for (int nxt = crt + 1; nxt < flag[state]; ++nxt)
{
int buf = tot + player[nxt].key;
for (int ind = 0; ind < nxt; ++ind)
{
if (sign[ind])
{
buf += maze[ind][nxt];
}
}
sign[nxt] = true;
dfs(nxt, state, buf, 0 == state ? gk_cnt + 1 : gk_cnt, 1 == state ? df_cnt + 1 : df_cnt, 2 == state ? mf_cnt + 1 : mf_cnt, 3 == state ? sk_cnt + 1 : sk_cnt);
sign[nxt] = false;
}
return ;
}
void ace()
{
int m, val;
string na, nb;
while (cin >> player[0].name >> player[0].key >> player[0].pos)
{
for (int i = 1; i < 23; ++i)
{
cin >> player[i].name >> player[i].key >> player[i].pos;
}
sort(player, player + 23, cmp);
NP.clear();
CLR(pcnt, 0);
for (int i = 0; i < 23; ++i)
{
++pcnt[ SP[ player[i].pos ] ];
NP.insert( pair<string, int>(player[i].name, i) );
}
CLR(maze, 0);
for (cin >> m; m--; )
{
cin >> na >> nb >> val;
maze[ NP[na] ][ NP[nb] ] = maze[ NP[nb] ][ NP[na] ] = val;
}
if (pcnt[0] < 1 || pcnt[1] < 4 || pcnt[2] < 4 || pcnt[3] < 2)
{
puts("impossible");
continue ;
}
flag[0] = pcnt[0];
for (int i = 1; i < 4; ++i)
{
flag[i] = flag[i - 1] + pcnt[i];
}
CLR(sign, false);
maxi = -INF_INT;
dfs(-1, 0, 0, 0, 0, 0, 0);
printf("%d\n", maxi);
}
return ;
}
int main()
{
preprocess();
ace();
return 0;
}
相关推荐
win11下的MySQL安装
目前官方最新版本是8.0.26,考虑到其稳定性、可靠性还需一定周期保证,所以使用官方版求稳定仍然建议5.7系列。3、选择MySQL Servers 5.7.38 -x64,然后按绿色箭头将选中的版本移植到右边选中框中。4、点击下方蓝色Advanced Options,选择安装位置。1、在开始界面搜索MySQL,点击command line。4、在“系统变量”中选择“path”,点击编辑。5、新建——>增加MySQL路径——>确定,12、execute,安装好后next。9、不需要做修改,直接点击next。.
HDU 3720 Arranging Your Team(2010天津现场赛A)
【题目链接】http://acm.hdu.edu.cn/showproblem.php?pid=3720 【解题报告】 分析出来枚举不会爆掉就可以做了,普遍做法是枚举每个人取或者不取,取够11个人并且满足阵型为1-4-4-2就更新一次总分数,这一步可以用DFS实现。第一遍写的思路很乱,隔天再做还好些,不过仍然写了很久。对于组织稍微复杂些的数据还是不太擅长,需要多加练习,多参考别人的优秀代
ADS2019学习笔记:三、SPICE model导入
以BZX84-C33 SPICE model为例,学习如何在ADS2019中导入SPICE model。
Arranging Your Team HDU - 3720 【DFS】
思路 题意:此题大意是指首先给你23个队员的信息,包括他们的名字,能力值,在赛场上的职位。然后给出几个若能满足某两个队员同时在球场上就额外加上一定的值。最后让你从23个队员中选出11个人,使得最终的value最大。 具体思路:由于从样例中可以发现字符串比较多,加之需要进行姓名和姓名、score之间关系的记录,这就用到了map。利用dfs对所有队员进行遍历,具体说明在代码中指出。 AC代码...
hdu 1195 Open the Lock(bbfs(双向广搜))
<br />第一次使用双向广搜算法求解,感觉效率的确提高了不止两倍。刚开始的一直WA,后来发现是每次都要扩展一层的节点,然后在扩展另一层的节点,而不是每次只扩展一个节点。<br /> /* Author: ACb0y Date: 2010-9-21 Type: bbfs(双向广搜) ProblemId: hdu 1195 Open the Lock Result: AC */ #include <iostream> #include <queue> using namespace
陀螺仪与加速度计的姿态融合——互补滤波
本篇文章我们来讲讲如何将陀螺仪和加速度计的数据结合起来,获取更准确的姿态数据,使用的是互补滤波的方法。
hdu 3720 Arranging Your Team dfs
思路很简单直接暴力,只是代码复杂了点 View Code #include <iostream> #include <string> #include <map> #define Min -0x3f3f3f3f using namespace std; map<string,int> m; struct nod...
A133在Android13上适配百兆以太网
NOTE] 【技术支持问题】问题背景/平台。
DFS+hdu3720
Online Judge Online Exercise Online Teaching Online Contests Exercise Author F.A.Q Hand In Hand Online Acmers Forum | Discuss Statistical Charts Problem Archive Realtime Judge Statu
YOLO26 改进 | 基于特征蒸馏 | 知识蒸馏 (Response & Feature-based Distillation)
本文系统介绍了YOLO26中的知识蒸馏技术,包含五大核心方法:基于响应的蒸馏(学习分类概率)、基于特征的蒸馏(学习中间层表示)、基于关系的蒸馏(学习特征关联)、通道维度蒸馏(CWD)和前景背景分离蒸馏(FGD)。文章深入解析了每种方法的数学原理与实现细节,并提出动态训练策略,包括一致性匹配和蒸馏权重退火机制。通过教师模型向学生模型传递"暗知识",在保持模型轻量化的同时逼近大模型性能。配套代码支持模块化组合不同蒸馏方法,为YOLO26模型压缩提供了一套完整的解决方案。
7、RNA 二级结构预测:包含接吻发夹基序的新策略
本文提出三种用于预测RNA二级结构中接吻发夹基序的新策略,结合规范化规则与非歧义动态规划,分别在时间与空间复杂度之间进行权衡。策略A以O(n⁴)时间和O(n²)空间实现高效预测;策略B通过存储次优结果扩大搜索空间,空间复杂度升至O(n³);策略C全面探索组合可能,时间复杂度为O(n⁵),但保持O(n²)空间。实验表明不同策略适用于不同复杂度的序列,为RNA结构预测提供了灵活且可扩展的解决方案。
HDU 3720 Arranging Your Team(DFS)
题目链接 队内赛里,匆匆忙忙写的。 1 #include <cstdio> 2 #include <cstring> 3 #include <iostream> 4 #include <vector> 5 #include <string> 6 #include <map> 7 ...
网表导入virtuoso后发现pg pin忘记connect_pg_net/globalNetConnect怎么办?
数模混合项目中经常需要一些需要到virtuoso去连接的线,比如IO上的pg和一些信号线,除了在pr工作中设置skip route之外还需要做好net的赋值,告诉工具虽然我没在物理上有连接,但是实际上应该连什么net,这部分提现在网表里。在Default Net Name中也填写net name,因为这个net需要做global操作,即在顶层定义这个net,所以需要在net name后加个!打开schematic,删除指定cell pin所接net的label。
HDU 3720 Arranging Your Team
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3720 题意:有4种一共23球员,需要选出10个球员组成4-4-2 阵容和1个守门员,每个球员都有能力值,以及2个球员之间可能会有combin,额外增加或者减少能力值 思路:一开始就想到了dfs,但是很蠢的选择了递推到11层,每层从23个球员进行挑选的方式,后来看了题解……进行了剪枝
SAP B1中文培訓教材_SDK
公司内部培训资料,对开发工具 ,DIAPI, UIAPI,Add-ON有详细解说
Data-Structures-and-Algorithm-Analysis-in-Java.pdf
作者: Weiss, Mark A. 出版社: Addison Wesley Data Structures and Algorithm Analysis in Java is an “advanced algorithms” book that fits between traditional CS2 and Algorithms Analysis courses. In the old ACM Curriculum Guidelines, this course was known as CS7. This text is for readers who want to learn good programming and algorithm analysis skills simultaneously so that they can develop such programs with the maximum amo...
HDU 3720
没什么好说的,最近太水,各种犯2...#include #include #include #include #include #include #include #include #include #include #include #include
lwip-2.0.3
lwip是瑞典计算机科学院(SICS)的Adam Dunkels 开发的一个小型开源的TCP/IP协议栈。实现的重点是在保持TCP协议主要功能的基础上减少对RAM 的占用。
hdu 3720 Arranging Your Team
http://acm.hdu.edu.cn/showproblem.php?pid=3720 水题 代码: #include<iostream> #include<stdio.h> #include<string.h> #include<math.h> #include<algorithm> #include<v...
深度学习工具包 DeepLearningToolbox
深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[](https://bitdeli.com/free "Bitdeli Badge")
hdu 3720——Arranging Your Team
#include #include #include #include #include using namespace std; struct Player { string name; int score; int pos; Player(){} Player(string nn,int ss,int pp) { name=nn;
hdu 3720 Arranging Your Team 枚举
不可能解可以直接判断。 搭配产生的附加分可以用一个二维数组保存。 枚举1442,4种类型的人,因为总人数只有23个,所以可以搜索暴力枚举,然后保存最优解。 #include #include #include #include #include #include #include #include #include #include #include
搜索-hdu-3720-Arranging Your Team
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=3720 题目大意: 有23个人,告诉每个人的名字,能力值,以及踢球的位置。要求选出1个守门员,2个前锋,4个中场,4个后卫。给m个关系,该关系的两个人如果同时在场,就会得到相应的分数值va(注意va可以为负值)。求怎样安排使得在场的人总价值最大。 解题思路: 先处理出每种位置的人分布,然
HDU 3720 Arranging Your Team
先分组,然后暴力;注意 初始化时不要为0 会有负数;我直接二进制枚举; dfs是正解;呵呵 #include <iostream> #include <cstdio> #include <cstring> #include <string> #include <vector> #include <map>...
HDU 3720 深搜 枚举
DES:从23个队员中选出4—4—2—1共4种11人来组成比赛队伍。给出每个人对每个职位的能力值。给出m组人在一起时会产生的附加效果。问你整场比赛人员的能力和最高是多少。 用深搜暴力枚举每种类型的人选择情况。感觉是这个深搜写的很机智。 在vector中存结构体就会很慢。TLE。直接存序号就AC了。以后还是尽量少用结构体吧。 #include<stdio.h> ...
hdu3270Arranging Your Team(dfs)
http://acm.hdu.edu.cn/showproblem.php?pid=3720 1 #include <iostream> 2 #include<cstdio> 3 #include<cstring> 4 #include<algorithm> 5 #include<stdlib.h> ...
2万+



被折叠的 条评论
为什么被折叠?



