adv钓鱼题
4
10
4 5
6 2
10 2
10
4 5
6 2
10 2
60
1 20
29 20
50 20
60
1 20
20 20
60 20 #include<stdio.h>
#define SIZE 100
int data[SIZE];
int Gate[3][2];
int D[3];
int num;
int bushu,minbushu;
int pos[SIZE]; int leftorder(int p){
int ps=Gate[p][0];
int people=Gate[p][1];
int left=0;
int right=num-1;
int orig=0;
int count=0;
for(int n=people;n>0;){
if(ps-orig-1>=left&&pos[ps-1-orig]==0){
pos[ps-orig-1]=-(p+1);
count=count+orig+1;
n--;
}
if(n==0) break;
if(ps-1+orig<=right&&pos[ps-1+orig]==0){
pos[ps+orig-1]=-(p+1);
n--;
count=count+orig+1;
}
orig++;
}
return count;
}
int rightorder(int p){
int ps=Gate[p][0];
int people=Gate[p][1];
int left=0;
int right=num-1;
int orig=0;
int count=0;
for(int n=people;n>0;){
if(ps-1+orig<=right&&pos[ps-1+orig]==0){
pos[ps+orig-1]=-(p+1);
n--;
count=count+orig+1;
}
if(n==0) break;
if(ps-orig-1>=left&&pos[ps-1-orig]==0){
pos[ps-orig-1]=-(p+1);
n--;
count=count+orig+1;
}
orig++;
}
return count;
}
void init(int p){
for(int i=0;i<num;i++){
if(pos[i]==-p-1){
pos[i]=0;
}
}
}
void DFS(int step,int bushu){
if(step==3){ if(bushu<minbushu){
minbushu=bushu;
}
return;
}
if(bushu>minbushu) return;
for(int i=0;i<3;i++){
if(!D[i]){
D[i]=1;
if(i==0){
DFS(step+1,bushu+leftorder(i));
init(i);
}
if(i==2){ DFS(step+1,bushu+rightorder(i));
init(i);
}
if(i==1){
DFS(step+1,bushu+leftorder(i));
init(i);
DFS(step+1,bushu+rightorder(i));
init(i);
}
D[i]=0;
}
}
} int main(){
//将txt内数据读入
freopen("a.txt","r",stdin);
int nCase;
scanf("%d",&nCase);
for(int tc=0;tc<nCase;tc++)
{
scanf("%d",&num);
for(int i=0;i<3;i++)
{
scanf("%d%d",&Gate[i][0],&Gate[i][1]);
}
for(int i=0;i<3;i++){
D[i]=0;
}
for(int i=0;i<SIZE;i++){
pos[i]=0;
}
minbushu=0x0FFFFFFF;
bushu=0;
DFS(0,0);
printf("%d\n",minbushu); //打印读入数据
/*cout<<num<<endl;
for(int i=0;i<3;i++){
cout<<Gate[i][0]<<" "<<Gate[i][1]<<endl;
}*/
}
return 0;
}
adv钓鱼题的更多相关文章
- adv联系题
http://www.cnblogs.com/kuangbin/archive/2011/07/29/2120667.html(新)
- MySQL每天产生了多大容量的binlog,用SQL语句能查到吗?
首先,这是个假设性命题(又一个钓鱼题). 这个需求完全可以通过系统层命令,配合MySQL中的"FLUSH BINARY LOGS"快速完成. 运行SHOW MASTER/BINAR ...
- 洛谷P1717 钓鱼
P1717 钓鱼 41通过 116提交 题目提供者该用户不存在 标签贪心 难度提高+/省选- 提交该题 讨论 题解 记录 最新讨论 暂时没有讨论 题目描述 话说发源于小朋友精心设计的游戏被电脑组的童鞋 ...
- 【托业】【新托业TOEIC新题型真题】学习笔记9-题库七+八--P4-5
109.intend 意为“打算,意欲”,含有将来的含义,故不用将来时态 110.must do sth 必须做某事 111.recession 经济衰退,不景气 rebound 反弹:反应 recr ...
- 【托业】【新托业TOEIC新题型真题】学习笔记5-题库二->P7
--------------------------------------单词-------------------------------------- amenity 适意:休闲设施 onsit ...
- [重点]delphi 实现 根据给定的标题去《中国青年报》网上电子报数据中查找匹配的内容,并从该内容中取出引题、正题、副题、作者和正文。
项目要求:根据给定的标题去<中国青年报>网上电子报数据中查找匹配的内容,并从该内容中取出引题.正题.作者和正文. unit Unit1; interface uses Winapi.Win ...
- 2010-2011 ACM-ICPC, NEERC, Moscow Subregional Contest Problem I. Interest Targeting 模拟题
Problem I. Interest Targeting 题目连接: http://codeforces.com/gym/100714 Description A unique display ad ...
- 一道关于chm设计ctf钓鱼的一些思考
版权声明:本文为博主的原创文章,未经博主同意不得转载 题目:flag就是文件指向的地址 文件: 作为一名web狗的出题人,这道ctf有点意思不是在于因为它难,而是相对于一些代码审计以及一些杂项题来说, ...
- 钓鱼(洛谷 P1717)
题目描述 话说发源于小朋友精心设计的游戏被电脑组的童鞋们藐杀之后非常不爽,为了表示安慰和鼓励,VIP999决定请他吃一次“年年大丰收”,为了表示诚意,他还决定亲自去钓鱼,但是,因为还要准备2013NO ...
随机推荐
- PowerDesigner使用
首先我们需要创建一个测试数据库,为了简单,我们在这个数据库中只创建一个Student表和一个Major表.其表结构和关系如下所示. 看看怎样用PowerDesigner快速的创建出这个数据库吧. 1. ...
- ios 导航栏的显示和隐藏切换
从简单的一个没有导航栏的界面A push到另一个有导航栏的界面 B,在界面A的逻辑中加入下面逻辑: 屏幕快照 2016-03-30 上午10.35.24.png 这样完美的处理了这个场景变换需求.引起 ...
- Centos7 修改mysql指定用户的密码
1.登陆mysql或者mariadb(两种任选其一) [root@localhost ~]# mysql -u root [root@localhost ~]# mysql -uroot -p 2.切 ...
- Jprofile监控本地tomact
第一步:安装Jprofile后,点击jprofiler.exe 第二步:配置要监控的tomact 1.点击startcenter 2.弹出对话框,点击new session下面的new server ...
- C++ 系列:C++ 基础 001
Copyright © 1900-2016, NORYES, All Rights Reserved. http://www.cnblogs.com/noryes/ 欢迎转载,请保留此版权声明. -- ...
- [leetcode] 题型整理之字符串处理
71. Simplify Path Given an absolute path for a file (Unix-style), simplify it. For example,path = &q ...
- 《DSP using MATLAB》示例Example5.10
代码: n = 0:10; x = 10*(0.8) .^ n; [xec, xoc] = circevod(x); %% -------------------------------------- ...
- 关于MFi认证你所必须要知道的事情
MFiLogo 前面我写了一篇文章<iOS App连接外设的几种方式>,其中EAP和NCM是都需要做MFi认证.对于苹果的MFI认证,对iOS开发的同学来说其实是一个比较陌生并且繁琐的to ...
- Codeforces444C DZY Loves Colors(线段树)
题目 Source http://codeforces.com/problemset/problem/444/C Description DZY loves colors, and he enjoys ...
- HDU4609 & FFT
关于这道题请移步kuangbin爷的blog:http://www.cnblogs.com/kuangbin/archive/2013/07/24/3210565.html 感觉我一辈子也不能写出这么 ...