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了一组数据 后来发现如果 ...
随机推荐
- sql2008 计划自动创建数据库分区【转】
本文转自:http://jingyan.baidu.com/article/6b97984d9a26ec1ca3b0bf77.html sql2008 计划自动创建数据库分区 固定增量的数据,自动创建 ...
- Netty4.x中文教程系列(三) ChannelHandler
Netty4.x中文教程系列(四) ChannelHandler 上一篇文章详细解释了Hello World示例的代码.里面涉及了一些Netty框架的基础. 这篇文章用以解释ChannelHandl ...
- Codeforces Round #327 (Div. 2) E. Three States
题目链接: 题目 E. Three States time limit per test:5 seconds memory limit per test:512 megabytes 问题描述 The ...
- 如何将jsp中<input>设为只读
将一个input变为只读,可以使用 readonly 属性 和 disabled 属性. 用disabled 属性时,文字显示为灰色. 下面的两种方法都是可以的: <input id =&q ...
- 【WCF--初入江湖】13 实战
13 实战 在线升级 using System; using System.Collections.Generic; using System.ComponentModel; using System ...
- 你应该了解的jquery 验证框架
Jquery validate 验证 具体查看附件中demo 主要是几种使用形式: 1.写在js中: $("#signupForm").validate({ rules: { fi ...
- 在 tornado 中异步无阻塞的执行耗时任务
在 tornado 中异步无阻塞的执行耗时任务 在 linux 上 tornado 是基于 epoll 的事件驱动框架,在网络事件上是无阻塞的.但是因为 tornado 自身是单线程的,所以如果我们在 ...
- uniqueidentifier 数据类型(转)
想要产生这种唯一标识的格式的数据: 6F9619FF-8B86-D011-B42D-00C04FC964FF 应该怎么做呢?答: uniqueidentifier 数据类型可存储 16 字节的二进制 ...
- POJ2480 Longge's problem gcd&&phi
题意简洁明了.做这题主要是温习一下phi的求法.令gcd(i,n)=k,实际上我们只需要求出有多少个i使得gcd(i,n)=k就可以了,然后就转化成了求phi(n/k)的和,但是n很大,我们不可能预处 ...
- node.js 安装、图文详解
网上的教程很多,有些模糊不清,有些版本太旧,有些是.exe安装,本文讲述windows系统下简单nodejs .msi环境配置.最新版是Current version: v0.10.26.官网下载地址 ...