Skip to content

Commit 7774b11

Browse files
authored
Create 960F.cpp
1 parent 2149a5c commit 7774b11

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

cf/960F.cpp

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#include <bits/stdc++.h>
2+
using namespace std;
3+
const int N = 100005;
4+
5+
map<pair<int,int>,int > s;
6+
7+
inline void insert(int u,int pos,const int &val) {
8+
for (;pos<N;pos+=pos&-pos)
9+
s[{u,pos}]=max(s[{u,pos}],val);
10+
}
11+
12+
inline int get(int u, int id) {
13+
int res=0;
14+
for(;id;id-=id&-id)
15+
if(s.count({u,id}))
16+
res=max(res,s[{u,id}]);
17+
return res;
18+
}
19+
20+
int main() {
21+
#ifdef Wavator
22+
freopen("test.in", "r", stdin);
23+
#endif
24+
int n,m;
25+
scanf("%d%d",&n,&m);
26+
int ans=0;
27+
for(int u,v,w;m--;) {
28+
scanf("%d%d%d",&u,&v,&w);
29+
int len=1+get(u,w);
30+
insert(v,w+1,len);
31+
ans=max(ans,len);
32+
}
33+
cout<<ans<<endl;
34+
return 0;
35+
}

0 commit comments

Comments
 (0)