题目传送门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. 基于DirectShow和FFmpeg的USB摄像头监控软件-转

    第一个版本 ### 软件版本及实现功能 0.0.1 1. USB摄像头枚举和设备信息获取2. 实时视频观看3. 24小时不间断录像,录像文件支持暴风影音播放 ### 软件说明: 软件基于 Direct ...

  2. Java 处理批量数据提交

    在Java web开发过程中,处理表单数据是很重要一部分,常见的是form post处理单条数据的,但也会遇到一次提交多条数据到服务器的,如下:

  3. log4net初探

    /// <summary> /// Static constructor that initializes logging by reading /// settings from the ...

  4. 标准模板库(STL)学习指南之priority_queue优先队列

    转载自CSDN博客:http://blog.csdn.net/suwei19870312/article/details/5294016 priority_queue 调用 STL里面的 make_h ...

  5. Cloudera运维

    1. 增加一个节点 1. 拷贝cm的jar包到该节点 2. 设置hostname(hostnamectl set-hostname XXX),然后修改hosts文件 3. 所有的节点添加该hostna ...

  6. Poj 2017 Speed Limit(水题)

    一.Description Bill and Ted are taking a road trip. But the odometer in their car is broken, so they ...

  7. 报错之-Cannot set property 'onclick' of null

    当js文件放在head里面时,如果绑定了onclick或者onmouseover事件,就会出现如下图类似的错误,是因为浏览器的加载你写的html文档的顺序是从上往下,加载完按钮节点才执行的js,所以当 ...

  8. 【java并发编程艺术学习】(五)第二章 java并发机制的底层实现原理 学习记录(三) 原子操作的实现原理学习

    章节介绍 主要包括 术语定义.处理器如何实现原子操作.Java如何实现原子操作: 原子(atomic)本意是 不能再进一步分割的最小粒子,“原子操作” 意为 不可被中断的一个或一系列操作. 术语定义 ...

  9. Math(2)

    Math(2) public static void main(String[] args) { System.out.println(Math.floor(-32.8)); //常数 System. ...

  10. [poj1390]Blocks(方块消除)

    题目大意:给定一序列,可点击某一位置消除与其相邻且相同的方块,得分为$len*len$,求最大得分. 解题关键:关键是状态的构造,首先离散化一下,令$dp[i][j][k]$表示序列$i-j$且后面有 ...