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 ...
随机推荐
- ACM学习历程—HDU5592 ZYB's Premutation(逆序数 && 树状数组 && 二分)(BestCoder Round #65 1003)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5592 题目大意就是给了每个[1, i]区间逆序对的个数,要求复原原序列. 比赛的时候2B了一发. 首先 ...
- RenderingPath 渲染路径
http://blog.csdn.net/lichaoguan/article/details/42554821 RenderingPath 渲染路径 Deferred Lighting 延时光照 延 ...
- 系列文章--AJAX技术系列总结
各种AJAX方法的使用比较 用ASP.NET写个SQLSERVER的小工具 写自己的ASP.NET MVC框架(下) 写自己的ASP.NET MVC框架(上) 用Asp.net写自己的服务框架 ...
- java静态方法(变量)、非静态方法(变量)区别
java静态方法.静态变量在调用时生成唯一标识,即在内存中给定一个静态位子,这样在调用时可以直接找到,而且会节省内存.但如果声明的静态方法.静态变量过多,会占用过多内存,有可能导致内存溢出. 非静态方 ...
- GSM/GPRS操作示例
A6(GPRS) 博文转自安信科技: http://wiki.ai-thinker.com/gprs/examples 1.电话接收 相关指令 ATDxxxxx;//xxx为电话号码 示例 打电话 ...
- 机器学习:从sklearn中加载数据
一.sklearn模块 sklearn模块下有很多子模块,常用的数据集在:sklearn.datasets模块下: 通过数据集中DESCR来查看数据集的文档: 从datasets中加载数据: impo ...
- 一 ThreadLocal
(1) Threadlocal定义: 当使用ThreadLocal维护变量时,ThreadLocal为每个使用该变量的线程提供独立的变量副本,所以每一个线程都可以独立地改变自己的副本,而不会影响其它 ...
- c++17 filesystem, regex 遍历目录
linux 遍历目录+文件(优化版本) c++17 FS 还是挺好用的, VS2017支持,但是linux g++7.3 还是不支持 filesystem #include<filesystem ...
- SQL 时间及字符串操作
都是一些很基础很常用的,在这里记录一下 获取年月日: year(时间) ---获取年,2014 month(时间) ----获取月,5 day(时间) -----获取天,6 如果月份或日期不足两位数, ...
- 16_点击事件第三种写法_activity实现接口
第一种写法是有名内部类,第二种写法是匿名内部类,第三种写法是MainActivity实现接口OnClickListener.直接让MainActivity实现了OnClickListener这个接口. ...