JZOI1134 迷宫(maze)
#include <bits/stdc++.h>
#define ll long long
#define INF 2147483647
#define mem_INF 2139062143
#define ll_INF 9223372036854775807
#define eps 1e-8
#define fuckrand() ( ( rand() << 15 ) ^ rand() )
using namespace std;
inline int read() {
int x = 0,tmp = 1;char ch = getchar();
while( ch < '0' || ch > '9' ) {if ( ch == '-' ) tmp = -1; ch = getchar();}
while( ch >= '0' && ch <= '9'){x = x * 10 + ch - '0'; ch = getchar(); }
return x * tmp;
}
struct Node {
int to, next, t, w;
} edge[21000];
bool used[11000];
int N, M, __t__, v;
int head[110], idx = 0, ans_t = __t__, ans_w = 0;
inline void ade( int u, int v, int t, int w ) {
edge[++ idx].to = v;
edge[idx].w = w;
edge[idx].t = t;
edge[idx].next = head[u];
head[u] = idx;
}
inline void add( int u, int v, int t, int w ) {
ade( u, v, t, w );
ade( v, u, t, w );
}
void dfs( int now, int t, int w ) {
if( t > __t__ || w > v ) return;
else if( now == N ) {
if( w < ans_w ) return;
if( w > ans_w ) {
ans_w = w;
ans_t = t;
} else if( w == ans_w ) ans_t = min( t, ans_t );
return;
} else {
for( int i = head[now] ; i != -1 ; i = edge[i].next ) if( !used[( i + 1 ) >> 1] ){
int son = edge[i].to, _t = edge[i].t, _w = edge[i].w;
used[( i + 1 ) >> 1] = 1;
dfs( son, t + _t, w + _w );
used[( i + 1 ) >> 1] = 0;
}
}
}
int main() {
memset( head, -1, sizeof( head ) );
memset( used, 0, sizeof( used ) );
N = read(), M = read(), __t__ = read(), v = read();
for( int i = 1 ; i <= M ; ++ i ) {
int u = read(), v = read(), t = read(), w = read();
ade( u, v, t, w );
ade( v, u, t, w );
}
dfs( 1, 0, 0 );
printf( "%d %d\n", ans_t, v - ans_w );
return 0;
}
--数据点-- | ---N--- | ---Q--- | max{A_x} |
---|---|---|---|
1 | 3 | 3 | 10 |
2 | 10 | 10 | 10000 |
3 | 10 | 10 | 10000 |
4 | 10 | 10000 | 10000 |
5 | 26 | 10000 | 100000000 |
6 | 26 | 10000 | 100000000 |
7 | 26 | 10000 | 1000000000000 |
8 | 26 | 10000 | 10000000000000000 |
9 | 26 | 50000 | 10000000000000000 |
10 | 26 | 100000 | 10000000000000000 |
JZOI1134 迷宫(maze)的更多相关文章
- 迷宫 maze
1 #include <stdlib.h> #include <stdio.h> #define stackinitsize 50 #define stackincrement ...
- 数据结构算法C语言实现(八)--- 3.2栈的应用举例:迷宫求解与表达式求值
一.简介 迷宫求解:类似图的DFS.具体的算法思路可以参考书上的50.51页,不过书上只说了粗略的算法,实现起来还是有很多细节需要注意.大多数只是给了个抽象的名字,甚至参数类型,返回值也没说的很清楚, ...
- golang 实现广度优先算法(走迷宫)
maze.go package main import ( "fmt" "os" ) /** * 广度优先算法 */ /** * 从文件中读取数据 */ fun ...
- php生成迷宫和迷宫寻址算法实例
较之前的终于有所改善.生成迷宫的算法和寻址算法其实是一样.只是一个用了遍历一个用了递归.参考了网上的Mike Gold的算法. <?php //zairwolf z@cot8.com heade ...
- 【noip 模拟赛curse,light,maze】 题解
2018.10.16 总结:考的不好 原因: 1.考的时候没状态,读题读不进去 2.考的时候不仔细,该得分没得到 T1:curse 1.咒语 (curse.pas/c/cpp) [题目描述] 亮亮梦到 ...
- maze writeup
maze writeup 攻防世界的一道迷宫题,第一次接触这样的题,个人感觉很有意思,收获也挺多,做一篇笔记记录一下. 程序分析 __int64 sub_4006B0() { signed __int ...
- [python 译] 基于面向对象的分析和设计
[python 译] 基于面向对象的分析和设计 // */ // ]]> [python 译] 基于面向对象的分析和设计 Table of Contents 1 原文地址 2 引言 2.1 ...
- 面向对象设计——抽象工厂(Abstract Factory)模式
定义 提供一个创建一系列相关或者相互依赖对象的接口,而无需指定它们具体的类.抽象工厂允许客户使用抽象的接口来创建一组相关的产品,而不需要知道或关心实际产出的具体产品是什么.这样一来,客户就能从具体的产 ...
- 设计模式之生成器(Builder)模式
意图 将一个复杂对象的构建与它的表示分离,使得同样的构建过程可以表示不同的表示. 适用性 当创建复杂对象的算法应该独立于该对象的组成部分以及它们的装配方式时. 当构造过程必须允许被构造的对象有不同的表 ...
随机推荐
- 第七周-scrum meeting
第一部分ScrumMeeting 每个人的工作:其他人:(请填写自己的任务) 成员 任务 ISSUE链接 本周已完成的工作 本周计划完成的工作 工作中遇到的困难 关玉娇 负责登录注册界面的设计与实现 ...
- 老板让我十分钟上手nx-admin
大体流程 参考资料: nx-admin项目地址 首先这里就不讲解vue和vuex之类的基础东西了 有兴趣的可以去官方文档了解.这里根据流程走向大概说说 路由配置 首先找到路由配置,路由配置放在了src ...
- setTag()与getTag()的使用介绍
转载博客:http://www.cnblogs.com/topcoderliu/archive/2011/06/07/2074419.html View中的setTag(Onbect)表示给View添 ...
- elementUI中input输入框,强制输入数字,并限制输入长度
<el-input v-model="item.userScore" onkeyup="this.value=this.value.replace(/[^\d.]/ ...
- leetcode上回溯法的使用
17 93 131 46(全排列) class Solution { public: vector<vector<int>> permute(vector<int> ...
- Spring系列.@EnableRedisHttpSession原理简析
在集群系统中,经常会需要将Session进行共享.不然会出现这样一个问题:用户在系统A上登陆以后,假如后续的一些操作被负载均衡到系统B上面,系统B发现本机上没有这个用户的Session,会强制让用户重 ...
- 基于C#的波形显示控件的实现[转]
编者记: 09年暑假正好在学院实验室呆了一段时间,做了个完整的上位机软件(具体实现:根据下位机的指令,实现通过串口来操纵下位机进行实验,并将采集的数据进行处理和保存,并以图形的方式显示),整个项目边学 ...
- JVM内存图
- haproxy附加
1.安装haproxy yum -y install haproxy 2.编写文件 vim /etc/haproxy/haproxy.cfg
- 安全服务——CVE中CVSS相关指标介绍
目录 CVSS相关指标 一.CVSS是什么 二.指标内容 1.Base指标 2.Temporal指标 3.Environmental指标 三.Base, Temporal, Environmental ...