codeforces round 474 pathwalks
题目传送门http://codeforces.com/contest/960/problem/F
4月25号期中考,答应过年级组长要考年排前3的,所以25号以前我就不搞竞赛了,期中考要考好。
有很多大佬写了主席树(初二的弱菜并不会)。但初二的会树状数组和map呀哈哈哈哈。
做法很简单,开n个树状数组,对于每条边,我们维护走到它最多步数,也就是在它之前出现的边-1然后边权比它小的dp值的最大值+1
树状数组如果不用map会mle
上代码(dp数组就是wxy数组,至于为什么吗,看我另一篇博客就知道了~~)
#include <bits/stdc++.h>
using namespace std;
+;
int n,m,fr[N],to[N],we[N];
int lowbit(int x){return x&-x;}
struct treearr{
map<int,int>c;
void motify(int x,int d){while(x<=N){c[x]=max(c[x],d);x+=lowbit(x);}}
;while(x){res=max(res,c[x]);x-=lowbit(x);}return res;}
}wxy[N];
int main(){
scanf("%d%d",&n,&m);
int i;
;i<=m;++i){
int u,v,len;scanf("%d%d%d",&u,&v,&len);++len;fr[i]=u;to[i]=v;we[i]=len;
wxy[v].motify(len,wxy[u].qry(len)+);
}
;
;i<=n;++i)ans=max(ans,wxy[i].qry(+));
printf("%d",ans);
}
codeforces round 474 pathwalks的更多相关文章
- Divide by Zero 2018 and Codeforces Round #474 (Div. 1 + Div. 2, combined)
思路:把边看成点,然后每条边只能从下面的边转移过来,我们将边按照u为第一关键字,w为第二关键字排序,这样就能用线段树维护啦. #include<bits/stdc++.h> #define ...
- Divide by Zero 2018 and Codeforces Round #474 (Div. 1 + Div. 2, combined)G - Bandit Blues
题意:求满足条件的排列,1:从左往右会遇到a个比当前数大的数,(每次遇到更大的数会更换当前数)2.从右往左会遇到b个比当前数大的数. 题解:1-n的排列,n肯定是从左往右和从右往左的最后一个数. 考虑 ...
- Codeforces Round #366 (Div. 2) ABC
Codeforces Round #366 (Div. 2) A I hate that I love that I hate it水题 #I hate that I love that I hate ...
- Codeforces Round #354 (Div. 2) ABCD
Codeforces Round #354 (Div. 2) Problems # Name A Nicholas and Permutation standard input/out ...
- Codeforces Round #368 (Div. 2)
直达–>Codeforces Round #368 (Div. 2) A Brain’s Photos 给你一个NxM的矩阵,一个字母代表一种颜色,如果有”C”,”M”,”Y”三种中任意一种就输 ...
- cf之路,1,Codeforces Round #345 (Div. 2)
cf之路,1,Codeforces Round #345 (Div. 2) ps:昨天第一次参加cf比赛,比赛之前为了熟悉下cf比赛题目的难度.所以做了round#345连试试水的深浅..... ...
- Codeforces Round #279 (Div. 2) ABCDE
Codeforces Round #279 (Div. 2) 做得我都变绿了! Problems # Name A Team Olympiad standard input/outpu ...
- Codeforces Round #262 (Div. 2) 1003
Codeforces Round #262 (Div. 2) 1003 C. Present time limit per test 2 seconds memory limit per test 2 ...
- Codeforces Round #262 (Div. 2) 1004
Codeforces Round #262 (Div. 2) 1004 D. Little Victor and Set time limit per test 1 second memory lim ...
随机推荐
- elasticsearch监控平台cerebro-0.8.3 相关操作
上面这个平台是cerebro-0.8.3 在github上找就有了 #################### GET /hnscan_source_o_comm_drv_bad_bhv_occur/ ...
- 三种 Failover 之 Client-Side Connect time Failover、Client-Side TAF、Service-Side TAF
三种 Failover 之 Client-Side Connect time Failover.Client-Side TAF.Service-Side TAF 理论背景 Oracle RAC 同时 ...
- Poj 1742 Coins(多重背包)
一.Description People in Silverland use coins.They have coins of value A1,A2,A3...An Silverland dolla ...
- HDU1026(延时迷宫:BFS+优先队列)
Ignatius and the Princess I Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (J ...
- /* font-awesome-4.7.0的应用*/
<!DOCTYPE html> /* font-awesome-4.7.0的应用*/ <html lang="en"> <head> <m ...
- CentOS 7 配置 http 服务器
一.http单域名访问 1.安装软件: yum -y install httpd 2.启动服务:systemctl start httpd 3.设置开机启动: systemctl enable ht ...
- SpringSecurity04 利用JPA和SpringSecurity实现前后端分离的认证和授权
1 环境搭建 1.1 环境说明 JDK:1.8 MAVEN:3.5 SpringBoot:2.0.4 SpringSecurity:5.0.7 IDEA:2017.02旗舰版 1.2 环境搭建 创建一 ...
- SQL标量值函数:小写金额转大写
我们日常开发业务系统中,作为统计报表中,特别是财务报表,显示中文金额经常遇到. 转换大小写的方法有很多,以下是从数据库函数方面解决这一问题. 效果如图: 调用:SELECT dbo.[Fn_Conve ...
- Learning Python 012 函数式编程 1 高阶函数
Python 函数式编程 1 高阶函数 高阶函数 Q:什么是高阶函数? A:一个函数接收另一个函数作为参数,这种函数就称之为高阶函数. 简单举个例子: def add(x, y, f): return ...
- Entity Framework Code-First(4):Simple Code First Example
Simple Code First Example: Let's assume that we want to create a simple application for XYZ School. ...