Submission #1114665

# Submission time Handle Problem Language Result Execution time Memory
1114665 2024-11-19T10:35:32 Z NotLinux Vinjete (COI22_vinjete) C++17
0 / 100
2 ms 592 KB
// Author : FatihCihan
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin() , v.end()
#define sz(a) (int)a.size()
const int inf = 1e9 + 7;
void solve(){
	int n,m;
	cin >> n >> m;
	vector < vector < int > > tree[n];
	for(int i = 1;i<n;i++){
		int a,b,c,d;
		cin >> a >> b >> c >> d;
		a-- , b--;
		tree[a].push_back({b,c,d});
		tree[b].push_back({a,c,d});
	}
	pair < int , int > pai[n];
	function<void(int,int)> dfs = [&](int node , int par){
		for(auto itr : tree[node]){
			if(itr[0] == par)continue;
			pai[itr[0]] = {min(pai[node].first , itr[1]) , max(pai[node].second , itr[2])};
			dfs(itr[0] , node);
		}
	};
	pai[0] = {inf , -inf};
	dfs(0 , 0);
	for(int i = 1;i<n;i++){
		cout << pai[i].second - pai[i].first + 1 << '\n';
	}
	cout << endl;
}
signed main(){
	ios_base::sync_with_stdio(0);cin.tie(0);
	int testcase = 1;//cin >> testcase;
	while(testcase--)solve();
	cerr << 1000.0 * clock() / CLOCKS_PER_SEC << " ms" << endl;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 592 KB Output is correct
2 Correct 2 ms 592 KB Output is correct
3 Incorrect 2 ms 592 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 592 KB Output is correct
2 Correct 2 ms 592 KB Output is correct
3 Incorrect 2 ms 592 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 592 KB Output is correct
2 Correct 2 ms 592 KB Output is correct
3 Incorrect 2 ms 592 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 592 KB Output is correct
2 Correct 2 ms 592 KB Output is correct
3 Incorrect 2 ms 592 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 592 KB Output is correct
2 Correct 2 ms 592 KB Output is correct
3 Incorrect 2 ms 592 KB Output isn't correct
4 Halted 0 ms 0 KB -