题目传送门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的更多相关文章

  1. Divide by Zero 2018 and Codeforces Round #474 (Div. 1 + Div. 2, combined)

    思路:把边看成点,然后每条边只能从下面的边转移过来,我们将边按照u为第一关键字,w为第二关键字排序,这样就能用线段树维护啦. #include<bits/stdc++.h> #define ...

  2. Divide by Zero 2018 and Codeforces Round #474 (Div. 1 + Div. 2, combined)G - Bandit Blues

    题意:求满足条件的排列,1:从左往右会遇到a个比当前数大的数,(每次遇到更大的数会更换当前数)2.从右往左会遇到b个比当前数大的数. 题解:1-n的排列,n肯定是从左往右和从右往左的最后一个数. 考虑 ...

  3. 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 ...

  4. Codeforces Round #354 (Div. 2) ABCD

    Codeforces Round #354 (Div. 2) Problems     # Name     A Nicholas and Permutation standard input/out ...

  5. Codeforces Round #368 (Div. 2)

    直达–>Codeforces Round #368 (Div. 2) A Brain’s Photos 给你一个NxM的矩阵,一个字母代表一种颜色,如果有”C”,”M”,”Y”三种中任意一种就输 ...

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

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

  7. Codeforces Round #279 (Div. 2) ABCDE

    Codeforces Round #279 (Div. 2) 做得我都变绿了! Problems     # Name     A Team Olympiad standard input/outpu ...

  8. 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 ...

  9. 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 ...

随机推荐

  1. Hihocoder1662 : 查找三阶幻方([Offer收割]编程练习赛40)(暴力)

    时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 给定一个N x M的矩阵,请你数一数其中有多少个3 x 3的子矩阵可以构成三阶幻方? 如果3 x 3的矩阵中每一行.每一列 ...

  2. 1068 Find More Coins (30)(30 分)

    Eva loves to collect coins from all over the universe, including some other planets like Mars. One d ...

  3. LOJ2719 「NOI2018」冒泡排序

    「NOI2018」冒泡排序 题目描述 最近,小S 对冒泡排序产生了浓厚的兴趣.为了问题简单,小 S 只研究对 1 到n 的排列的冒泡排序. 下面是对冒泡排序的算法描述. 输入:一个长度为n 的排列p[ ...

  4. bzoj 3572: [Hnoi2014]世界树 虚树

    题目: Description 世界树是一棵无比巨大的树,它伸出的枝干构成了整个世界.在这里,生存着各种各样的种族和生灵,他们共同信奉着绝对公正公平的女神艾莉森,在他们的信条里,公平是使世界树能够生生 ...

  5. windows7下c++11环境搭建

    1.安装codeblocks 13.12 2.下载安装tdm-gcc-4.8.1-3 3.配置coldblocks的编译器(settings->compiler->compiler set ...

  6. 【转】 Pro Android学习笔记(五七):Preferences(1):ListPreference

    目录(?)[-] 例子1ListPreference小例子 定义一个preferences XML文件 继承PreferenceActivity 用户定制偏好的读取 第一次运行时设置缺省值 设置Cat ...

  7. 第 七 课 go的运算符

    http://www.runoob.com/go/go-operators.html 算术运算符 关系运算符 逻辑运算符 位运算符 赋值运算符 其他运算符 返回变量存储地址: & 指针变量:  ...

  8. paramiko使用1

  9. numpy.ones_like(a, dtype=None, order='K', subok=True)返回和原矩阵一样形状的1矩阵

    Return an array of ones with the same shape and type as a given array. Parameters: a : array_like Th ...

  10. 任务调度TimerTask&Quartz的 Java 实现方法与比较

    文章引自--https://www.ibm.com/developerworks/cn/java/j-lo-taskschedule/ 前言 任务调度是指基于给定时间点,给定时间间隔或者给定执行次数自 ...