cf459E 这题说的是 给定一个n点m条边的带边权的有向图,从中找出一条路径(可以带环),该路径包含的边数最多,并且要求路径中的权值必须严格递增,然后对边进行排序完个后采用dp去解特殊判断一下边权值相等的时候就ok了

#include <iostream>
#include <string.h>
#include <cstdio>
#include <algorithm>
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
using namespace std;
const int maxn = *;
struct edg{
int a,b,w;
bool operator <(const edg A)const {
return w<A.w||( w == A.w &&a<A.a );
}
void read(int &a1,int &b1, int &w1 ){
a1 = a;
b1= b;
w1=w;
}
}E[maxn];
__int64 dp[][maxn];
int ma[][maxn];
int main(int argc, char *argv[]) {
int n,m;
while(scanf("%d%d",&n,&m)==){
for(int i = ; i< m; ++i)
scanf("%d%d%d",&E[i].a,&E[i].b,&E[i].w);
sort(E,E+m);
memset(dp,,sizeof(dp));
memset(ma,,sizeof(ma));
__int64 ans=;
for(int i =; i< m; ++i){
int a,b,w;
E[i].read(a,b,w);
if(w > ma[][a] && dp[][b] < dp[][a]+ ){
if(ma[][b] != w){
ma[][b] = ma[][b];
dp[][b] = dp[][b];
}
dp[][b]=dp[][a]+;
ma[][b]=w;
} else if(w>ma[][a]&&dp[][b]<dp[][a] +){
if(ma[][b] != w){
ma[][b] = ma[][b];
dp[][b] = dp[][b];
}
dp[][b]=dp[][a]+;
ma[][b]=w;
}
ans = ans> dp[][b]? ans : dp[][b];
}
printf("%I64d\n",ans);
}
return ;
}

de

cf 459E的更多相关文章

  1. CF 459A && 459B && 459C && 459D && 459E

    http://codeforces.com/contest/459 A题 Pashmak and Garden 化简化简水题,都告诉平行坐标轴了,数据还出了对角线,后面两个点坐标给的范围也不错 #in ...

  2. ORA-00494: enqueue [CF] held for too long (more than 900 seconds) by 'inst 1, osid 5166'

    凌晨收到同事电话,反馈应用程序访问Oracle数据库时报错,当时现场现象确认: 1. 应用程序访问不了数据库,使用SQL Developer测试发现访问不了数据库.报ORA-12570 TNS:pac ...

  3. codeforces 459E

    codeforces 459E E. Pashmak and Graph time limit per test 1 second memory limit per test 256 megabyte ...

  4. cf之路,1,Codeforces Round #345 (Div. 2)

     cf之路,1,Codeforces Round #345 (Div. 2) ps:昨天第一次参加cf比赛,比赛之前为了熟悉下cf比赛题目的难度.所以做了round#345连试试水的深浅.....   ...

  5. cf Round 613

    A.Peter and Snow Blower(计算几何) 给定一个点和一个多边形,求出这个多边形绕这个点旋转一圈后形成的面积.保证这个点不在多边形内. 画个图能明白 这个图形是一个圆环,那么就是这个 ...

  6. ARC下OC对象和CF对象之间的桥接(bridge)

    在开发iOS应用程序时我们有时会用到Core Foundation对象简称CF,例如Core Graphics.Core Text,并且我们可能需要将CF对象和OC对象进行互相转化,我们知道,ARC环 ...

  7. [Recommendation System] 推荐系统之协同过滤(CF)算法详解和实现

    1 集体智慧和协同过滤 1.1 什么是集体智慧(社会计算)? 集体智慧 (Collective Intelligence) 并不是 Web2.0 时代特有的,只是在 Web2.0 时代,大家在 Web ...

  8. CF memsql Start[c]UP 2.0 A

    CF memsql Start[c]UP 2.0 A A. Golden System time limit per test 1 second memory limit per test 256 m ...

  9. CF memsql Start[c]UP 2.0 B

    CF memsql Start[c]UP 2.0 B B. Distributed Join time limit per test 1 second memory limit per test 25 ...

随机推荐

  1. Unix/Linux 查看文件大小

    ls -l help.html-rw-r--r--  1 william  wheel  40960 Jul 18 00:59 development.sqlite3 40960 就是文件的大小. d ...

  2. Linux下使用 xrandr 命令设置屏幕分辨率

    最近在Linux下修改屏幕分辨率的时候,发现了一个非常有用的命令:xrandr 使用这个命令,可以方便的设置您显示器的的分辨率.尤其是当你使用了一些需要或者会自动改动您屏幕分辨率的程序以后. 您可以使 ...

  3. [SQL] SQL 日常检查脚本

    --sqlserver 日常检查脚本 print '----------------------------' print ' 0.sqlserver all information ' print ...

  4. [APP] Android 开发笔记 006-使用短信验证SDK进行短信验证

    1. 下载SDK (http://www.mob.com/#/download) SMS For Android Studio: http://www.mob.com/download/sms/and ...

  5. python pytest测试框架介绍三

    之前介绍了pytest以xUnit形式来写用例,下面来介绍pytest特有的方式来写用例 1.pytest fixture实例1 代码如下 from __future__ import print_f ...

  6. 阻止form表单提交的问题

    阻止form表单提交这种场景可能在生活中,我们经常碰到,而在我们第一印象里面可能我们用return false 去阻止表单默认行为. 但是,有中情况我们用return false 不能阻止表单提交 & ...

  7. jquery实践

    转:http://www.cnblogs.com/Wayou/p/jquery_best_prictise.html jQuery编程的最佳实践   好像是feedly订阅里看到的文章,读完后觉得非常 ...

  8. Shell for

    for循环一般格式为:for 变量 in 列表do command1 command2 ... commandNdone列表是一组值(数字.字符串等)组成的序列,每个值通过空格分隔.每循环一次,就将列 ...

  9. linux使用bin文件安装jdk

    jdk1.6.20文件为bin文件安装过程如下 添加执行权限 chmod +x jdk-6u20-linux-x64.bin 运行,出现提示需要输入yes ./jdk-6u20-linux-x64.b ...

  10. HDU 5512 - Pagodas - [gcd解决博弈]

    题目链接:http://acm.split.hdu.edu.cn/showproblem.php?pid=5512 Time Limit: 2000/1000 MS (Java/Others) Mem ...