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 ...
随机推荐
- python %s深入解析
默认我们通常用字符串填充它 'Keep %s, and you will aways make %' % ('moving', 'it') 如果你就此止步,那就错过了一些神乎其技的用法 比如: arr ...
- jquery写简单的div切换
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- CI在ngnix的配置
CI的访问路径是酱紫的: http://localhost/index.php/cname/mname 其中cname为controller的名称,mname为method的名称 但是nginx会把i ...
- 二叉树建立,遍历和二叉排序树的判断【c++】
// test.cpp : Defines the entry point for the console application. // #include "stdafx.h" ...
- haproxy测试
环境: Clients:N台linux, 使用“ab -k -c 20000...” 并发2w 请求haproxy Haproxy Server: R610 2*8核 2.4G Real Server ...
- python 单步调试初探(未完待续)
pdb 调试: import pdb pdb.set_trace() pudb 调试: http://python.jobbole.com/82638/
- android so调试时遇到的坑 - arm流水线
直接看下面这段ARM汇编: 此时运行到的代码为ADD R3,PC 此时看一下寄存器窗口的值: 按理来说执行完ADD R3,PC后的效果应该是R3=R3+PC ,R3=40A1D5C8 但是我们可以执行 ...
- C/C++ 中判断某一文件或目录是否存在
方法一:C++中比较简单的一种办法(使用文件流打开文件) #include <iostream> #include <fstream> using namespace std; ...
- Shell判断字符串包含关系的几种方法
现在每次分析网站日志的时候都需要判断百度蜘蛛是不是真实的蜘蛛,nslookup之后需要判断结果中是否包含“baidu”字符串 以下给出一些shell中判断字符串包含的方法,来源程序员问答网站 stac ...
- js 定时器
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title> ...