#include <bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define ppb pop_back
#define ep insert
#define endl '\n'
#define elif else if
#define pow pwr
#define sqrt sqrtt
//#define int long long
typedef unsigned long long ull;
using namespace std;
struct edge{
int x,l,r;
};
const int N=1e5+5;
int n,m,ans[N];
vector<edge> adj[N];
bitset<N> bs[N];
void dfs(int node,int p){
bs[node].count();
for (auto u:adj[node]){
if (p==u.x) continue;
bs[u.x]=bs[node];
for (int i=u.l;i<=u.r;i++) bs[u.x][i]=1;
dfs(u.x,node);
}return;
}
int32_t main(){
ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
cin>>n>>m;
for (int i=1;i<n;i++){
int x,y,l,r;
cin>>x>>y>>l>>r;
adj[x].pb({y,l,r});
adj[y].pb({x,l,r});
}dfs(1,0);
for (int i=2;i<=n;i++) cout<<bs[i].count()<<endl;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
15704 KB |
Output is correct |
2 |
Correct |
8 ms |
15708 KB |
Output is correct |
3 |
Correct |
7 ms |
15708 KB |
Output is correct |
4 |
Correct |
7 ms |
15708 KB |
Output is correct |
5 |
Correct |
7 ms |
15772 KB |
Output is correct |
6 |
Correct |
8 ms |
15708 KB |
Output is correct |
7 |
Correct |
2 ms |
5212 KB |
Output is correct |
8 |
Correct |
2 ms |
5212 KB |
Output is correct |
9 |
Correct |
8 ms |
15708 KB |
Output is correct |
10 |
Correct |
8 ms |
15604 KB |
Output is correct |
11 |
Correct |
7 ms |
15704 KB |
Output is correct |
12 |
Correct |
7 ms |
15712 KB |
Output is correct |
13 |
Correct |
7 ms |
15708 KB |
Output is correct |
14 |
Correct |
6 ms |
15704 KB |
Output is correct |
15 |
Correct |
1 ms |
5212 KB |
Output is correct |
16 |
Correct |
2 ms |
5212 KB |
Output is correct |
17 |
Correct |
8 ms |
15452 KB |
Output is correct |
18 |
Correct |
8 ms |
15708 KB |
Output is correct |
19 |
Correct |
9 ms |
15704 KB |
Output is correct |
20 |
Correct |
7 ms |
15708 KB |
Output is correct |
21 |
Correct |
6 ms |
15448 KB |
Output is correct |
22 |
Correct |
9 ms |
15540 KB |
Output is correct |
23 |
Correct |
1 ms |
5212 KB |
Output is correct |
24 |
Correct |
2 ms |
5212 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
15704 KB |
Output is correct |
2 |
Correct |
8 ms |
15708 KB |
Output is correct |
3 |
Correct |
7 ms |
15708 KB |
Output is correct |
4 |
Correct |
7 ms |
15708 KB |
Output is correct |
5 |
Correct |
7 ms |
15772 KB |
Output is correct |
6 |
Correct |
8 ms |
15708 KB |
Output is correct |
7 |
Correct |
2 ms |
5212 KB |
Output is correct |
8 |
Correct |
2 ms |
5212 KB |
Output is correct |
9 |
Correct |
8 ms |
15708 KB |
Output is correct |
10 |
Correct |
8 ms |
15604 KB |
Output is correct |
11 |
Correct |
7 ms |
15704 KB |
Output is correct |
12 |
Correct |
7 ms |
15712 KB |
Output is correct |
13 |
Correct |
7 ms |
15708 KB |
Output is correct |
14 |
Correct |
6 ms |
15704 KB |
Output is correct |
15 |
Correct |
1 ms |
5212 KB |
Output is correct |
16 |
Correct |
2 ms |
5212 KB |
Output is correct |
17 |
Correct |
8 ms |
15452 KB |
Output is correct |
18 |
Correct |
8 ms |
15708 KB |
Output is correct |
19 |
Correct |
9 ms |
15704 KB |
Output is correct |
20 |
Correct |
7 ms |
15708 KB |
Output is correct |
21 |
Correct |
6 ms |
15448 KB |
Output is correct |
22 |
Correct |
9 ms |
15540 KB |
Output is correct |
23 |
Correct |
1 ms |
5212 KB |
Output is correct |
24 |
Correct |
2 ms |
5212 KB |
Output is correct |
25 |
Execution timed out |
3062 ms |
126372 KB |
Time limit exceeded |
26 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
15704 KB |
Output is correct |
2 |
Correct |
8 ms |
15708 KB |
Output is correct |
3 |
Correct |
7 ms |
15708 KB |
Output is correct |
4 |
Correct |
7 ms |
15708 KB |
Output is correct |
5 |
Correct |
7 ms |
15772 KB |
Output is correct |
6 |
Correct |
8 ms |
15708 KB |
Output is correct |
7 |
Correct |
2 ms |
5212 KB |
Output is correct |
8 |
Correct |
2 ms |
5212 KB |
Output is correct |
9 |
Correct |
8 ms |
15708 KB |
Output is correct |
10 |
Correct |
8 ms |
15604 KB |
Output is correct |
11 |
Correct |
7 ms |
15704 KB |
Output is correct |
12 |
Correct |
7 ms |
15712 KB |
Output is correct |
13 |
Correct |
7 ms |
15708 KB |
Output is correct |
14 |
Correct |
6 ms |
15704 KB |
Output is correct |
15 |
Correct |
1 ms |
5212 KB |
Output is correct |
16 |
Correct |
2 ms |
5212 KB |
Output is correct |
17 |
Correct |
8 ms |
15452 KB |
Output is correct |
18 |
Correct |
8 ms |
15708 KB |
Output is correct |
19 |
Correct |
9 ms |
15704 KB |
Output is correct |
20 |
Correct |
7 ms |
15708 KB |
Output is correct |
21 |
Correct |
6 ms |
15448 KB |
Output is correct |
22 |
Correct |
9 ms |
15540 KB |
Output is correct |
23 |
Correct |
1 ms |
5212 KB |
Output is correct |
24 |
Correct |
2 ms |
5212 KB |
Output is correct |
25 |
Correct |
2736 ms |
498308 KB |
Output is correct |
26 |
Correct |
2678 ms |
498668 KB |
Output is correct |
27 |
Correct |
861 ms |
498260 KB |
Output is correct |
28 |
Correct |
842 ms |
498332 KB |
Output is correct |
29 |
Correct |
221 ms |
498260 KB |
Output is correct |
30 |
Correct |
213 ms |
498260 KB |
Output is correct |
31 |
Correct |
28 ms |
65436 KB |
Output is correct |
32 |
Correct |
28 ms |
65452 KB |
Output is correct |
33 |
Correct |
28 ms |
65372 KB |
Output is correct |
34 |
Correct |
28 ms |
65372 KB |
Output is correct |
35 |
Correct |
2782 ms |
496088 KB |
Output is correct |
36 |
Correct |
2708 ms |
496032 KB |
Output is correct |
37 |
Correct |
874 ms |
496032 KB |
Output is correct |
38 |
Correct |
879 ms |
496292 KB |
Output is correct |
39 |
Correct |
259 ms |
495956 KB |
Output is correct |
40 |
Correct |
251 ms |
495692 KB |
Output is correct |
41 |
Correct |
31 ms |
65116 KB |
Output is correct |
42 |
Correct |
32 ms |
65116 KB |
Output is correct |
43 |
Correct |
2724 ms |
495860 KB |
Output is correct |
44 |
Correct |
2727 ms |
495592 KB |
Output is correct |
45 |
Correct |
865 ms |
495664 KB |
Output is correct |
46 |
Correct |
886 ms |
495444 KB |
Output is correct |
47 |
Correct |
246 ms |
495444 KB |
Output is correct |
48 |
Correct |
250 ms |
495712 KB |
Output is correct |
49 |
Correct |
32 ms |
65112 KB |
Output is correct |
50 |
Correct |
32 ms |
65116 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
15704 KB |
Output is correct |
2 |
Correct |
8 ms |
15708 KB |
Output is correct |
3 |
Correct |
7 ms |
15708 KB |
Output is correct |
4 |
Correct |
7 ms |
15708 KB |
Output is correct |
5 |
Correct |
7 ms |
15772 KB |
Output is correct |
6 |
Correct |
8 ms |
15708 KB |
Output is correct |
7 |
Correct |
2 ms |
5212 KB |
Output is correct |
8 |
Correct |
2 ms |
5212 KB |
Output is correct |
9 |
Correct |
8 ms |
15708 KB |
Output is correct |
10 |
Correct |
8 ms |
15604 KB |
Output is correct |
11 |
Correct |
7 ms |
15704 KB |
Output is correct |
12 |
Correct |
7 ms |
15712 KB |
Output is correct |
13 |
Correct |
7 ms |
15708 KB |
Output is correct |
14 |
Correct |
6 ms |
15704 KB |
Output is correct |
15 |
Correct |
1 ms |
5212 KB |
Output is correct |
16 |
Correct |
2 ms |
5212 KB |
Output is correct |
17 |
Correct |
8 ms |
15452 KB |
Output is correct |
18 |
Correct |
8 ms |
15708 KB |
Output is correct |
19 |
Correct |
9 ms |
15704 KB |
Output is correct |
20 |
Correct |
7 ms |
15708 KB |
Output is correct |
21 |
Correct |
6 ms |
15448 KB |
Output is correct |
22 |
Correct |
9 ms |
15540 KB |
Output is correct |
23 |
Correct |
1 ms |
5212 KB |
Output is correct |
24 |
Correct |
2 ms |
5212 KB |
Output is correct |
25 |
Correct |
2736 ms |
498308 KB |
Output is correct |
26 |
Correct |
2678 ms |
498668 KB |
Output is correct |
27 |
Correct |
861 ms |
498260 KB |
Output is correct |
28 |
Correct |
842 ms |
498332 KB |
Output is correct |
29 |
Correct |
221 ms |
498260 KB |
Output is correct |
30 |
Correct |
213 ms |
498260 KB |
Output is correct |
31 |
Correct |
28 ms |
65436 KB |
Output is correct |
32 |
Correct |
28 ms |
65452 KB |
Output is correct |
33 |
Correct |
28 ms |
65372 KB |
Output is correct |
34 |
Correct |
28 ms |
65372 KB |
Output is correct |
35 |
Correct |
2782 ms |
496088 KB |
Output is correct |
36 |
Correct |
2708 ms |
496032 KB |
Output is correct |
37 |
Correct |
874 ms |
496032 KB |
Output is correct |
38 |
Correct |
879 ms |
496292 KB |
Output is correct |
39 |
Correct |
259 ms |
495956 KB |
Output is correct |
40 |
Correct |
251 ms |
495692 KB |
Output is correct |
41 |
Correct |
31 ms |
65116 KB |
Output is correct |
42 |
Correct |
32 ms |
65116 KB |
Output is correct |
43 |
Correct |
2724 ms |
495860 KB |
Output is correct |
44 |
Correct |
2727 ms |
495592 KB |
Output is correct |
45 |
Correct |
865 ms |
495664 KB |
Output is correct |
46 |
Correct |
886 ms |
495444 KB |
Output is correct |
47 |
Correct |
246 ms |
495444 KB |
Output is correct |
48 |
Correct |
250 ms |
495712 KB |
Output is correct |
49 |
Correct |
32 ms |
65112 KB |
Output is correct |
50 |
Correct |
32 ms |
65116 KB |
Output is correct |
51 |
Execution timed out |
3068 ms |
248872 KB |
Time limit exceeded |
52 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
15704 KB |
Output is correct |
2 |
Correct |
8 ms |
15708 KB |
Output is correct |
3 |
Correct |
7 ms |
15708 KB |
Output is correct |
4 |
Correct |
7 ms |
15708 KB |
Output is correct |
5 |
Correct |
7 ms |
15772 KB |
Output is correct |
6 |
Correct |
8 ms |
15708 KB |
Output is correct |
7 |
Correct |
2 ms |
5212 KB |
Output is correct |
8 |
Correct |
2 ms |
5212 KB |
Output is correct |
9 |
Correct |
8 ms |
15708 KB |
Output is correct |
10 |
Correct |
8 ms |
15604 KB |
Output is correct |
11 |
Correct |
7 ms |
15704 KB |
Output is correct |
12 |
Correct |
7 ms |
15712 KB |
Output is correct |
13 |
Correct |
7 ms |
15708 KB |
Output is correct |
14 |
Correct |
6 ms |
15704 KB |
Output is correct |
15 |
Correct |
1 ms |
5212 KB |
Output is correct |
16 |
Correct |
2 ms |
5212 KB |
Output is correct |
17 |
Correct |
8 ms |
15452 KB |
Output is correct |
18 |
Correct |
8 ms |
15708 KB |
Output is correct |
19 |
Correct |
9 ms |
15704 KB |
Output is correct |
20 |
Correct |
7 ms |
15708 KB |
Output is correct |
21 |
Correct |
6 ms |
15448 KB |
Output is correct |
22 |
Correct |
9 ms |
15540 KB |
Output is correct |
23 |
Correct |
1 ms |
5212 KB |
Output is correct |
24 |
Correct |
2 ms |
5212 KB |
Output is correct |
25 |
Execution timed out |
3062 ms |
126372 KB |
Time limit exceeded |
26 |
Halted |
0 ms |
0 KB |
- |