1741. Communication Fiend(dp)
刷个简单的DP缓缓心情
1A

#include <iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<stdlib.h>
#include<vector>
using namespace std;
#define N 10010
vector<int>q[N];
#define LL __int64
#define INF 1e10
LL dp[N][];
int o[N];
struct node
{
int x,y,d;
char s[];
}p[N];
int main()
{
int i,j,n,m;
scanf("%d%d",&n,&m);
for(i = ; i <= m ; i++)
{
scanf("%d%d%d%s",&p[i].x,&p[i].y,&p[i].d,p[i].s);
q[p[i].y].push_back(i);
}
dp[i][] = ;
dp[i][] = INF;
dp[i][] = INF;
for(i = ; i <= n ; i++)
{
dp[i][] = dp[i][] = dp[i][] = INF;
for(j = ; j < (int)q[i].size() ; j++)
{
int v = q[i][j],k,x = p[v].x,w = p[v].d;
if(strcmp(p[v].s,"Licensed")==)
k = ;
else if(strcmp(p[v].s,"Cracked")==)
k = ;
else k = ;
if(k==)
{
dp[i][] = min(dp[i][],min(dp[x][]+w,dp[x][]+w));
}
else if(k==)
{
dp[i][] = min(dp[i][],min(dp[x][]+w,dp[x][]+w));
dp[i][] = min(dp[i][],dp[x][]+w);
}
else
{
dp[i][] = min(dp[i][],dp[x][]+w);
dp[i][] = min(dp[i][],dp[x][]+w);
dp[i][] = min(dp[i][],dp[x][]+w);
}
}
}
LL ans = INF;
for(i = ; i <= ; i++)
ans = min(ans,dp[n][i]);
if(ans==INF)
puts("Offline");
else
{
puts("Online");
printf("%I64d\n",ans);
}
return ;
}
1741. Communication Fiend(dp)的更多相关文章
- URAL 1741 Communication Fiend(最短路径)
Description Kolya has returned from a summer camp and now he's a real communication fiend. He spends ...
- Ural 1741 Communication Fiend(隐式图+虚拟节点最短路)
1741. Communication Fiend Time limit: 1.0 second Memory limit: 64 MB Kolya has returned from a summe ...
- DP/最短路 URAL 1741 Communication Fiend
题目传送门 /* 题意:程序从1到n版本升级,正版+正版->正版,正版+盗版->盗版,盗版+盗版->盗版 正版+破解版->正版,盗版+破解版->盗版 DP:每种情况考虑一 ...
- POJ 1018 Communication System(贪心)
Description We have received an order from Pizoor Communications Inc. for a special communication sy ...
- POJ 1018 Communication System (动态规划)
We have received an order from Pizoor Communications Inc. for a special communication system. The sy ...
- Communication System(动态规划)
个人心得:百度推荐的简单DP题,自己做了下发现真得水,看了题解发现他们的思维真得比我好太多太多, 这是一段漫长的锻炼路呀. 关于这道题,我最开始用DP的思路,找子状态,发现自己根本就不会找DP状态数组 ...
- TCSRM 593 div2(1000)(dp)
Problem Statement The pony Rainbow Dash wants to choose her pet. There are N animals who want t ...
- 1346. Intervals of Monotonicity(dp)
1346 简单dp #include <iostream> #include<cstdio> #include<cstring> #include<algor ...
- TCSRM 591 div2(1000)(dp)
挺好的dp 因为有一点限制 必须任意去除一个数 总和就会小于另一个总和 换句话来说就是去除最小的满足 那么就都满足 所以是限制最小值的背包 刚开始从小到大定住最小值来背 TLE了一组数据 后来发现如果 ...
随机推荐
- 构件图 Component Diagram
构件图是显示代码自身结构的实现级别的图表.构件图由诸如源代码文件.二进制代码文件.可执行文件或动态链接库 (DLL) 这样的构件构成,并通过依赖关系相连接 下面这张图介绍了构件图的基本内容: 下面这张 ...
- div 布局2
转:http://www.kwstu.com/ArticleView/divcss_2013929173533658 关于DIV+CSS布局中用到的CSS必备知识请看:http://www.kwstu ...
- linux 下安装 nginx
安装nginx版本为1.7.5 一.下载nginx 官方地址:http://www.nginx.org/ 下载地址:http://nginx.org/download/ Nginx官网提供了三个类型的 ...
- WCF 基础
ServiceModel 配置元素 Binding 配置元素: 客户端Web.config: <?xml version="1.0" encoding="utf-8 ...
- linux杀掉80端口线程命令
80端口被其他程序占用, fuser -k -n tcp 80
- Iptables DDOS/CC 自动屏蔽脚本
Iptables DDOS/CC 自动屏蔽脚本 May 20, 2013 最近不停地被 CC (DDOS的一种)频繁干扰,分享一个 iptables 屏蔽 DDOS 的脚本.让 crond 每分钟运行 ...
- linux源码阅读笔记 move_to_user_mode()解析
在linux 0.11版本源代码中,在文件linux/include/asm/system.h中有一个宏定义 move_to_user_mode() 1 #define move_to_user_m ...
- SDUT2142数据结构实验之图论二:基于邻接表的广度优先搜索遍历
http://acm.sdut.edu.cn/sdutoj/showproblem.php?pid=2142&cid=1186 题目描述 给定一个无向连通图,顶点编号从0到n-1,用广度优先搜 ...
- Spring 3.0: Unable to locate Spring NamespaceHandler for XML schema namespace
被这个问题折磨着很久:参考: http://have23.iteye.com/blog/1340777 (cfx 与 spring 整合的时候出现的问题: org.springframework.be ...
- 最长不下降子序列//序列dp
最长不下降子序列 时间: 1000ms / 空间: 131072KiB / Java类名: Main 描述 求最长不下降子序列的长度 输入格式 第一行为n,表示n个数第二行n个数 输出格式 最长不下降 ...