This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
int main(){
int N;
cin >> N;
vector<vector<int>> E(N);
for (int i = 0; i < N - 1; i++){
int X, Y;
cin >> X >> Y;
}
int M;
cin >> M;
vector<int> A(M), B(M);
for (int i = 0; i < M; i++){
int C;
cin >> A[i] >> B[i] >> C;
if (A[i] > B[i]){
swap(A[i], B[i]);
}
A[i]--;
}
vector<pair<int, int>> P(M);
for (int i = 0; i < M; i++){
P[i] = make_pair(B[i], A[i]);
}
sort(P.begin(), P.end());
int p = -1;
int ans = 0;
for (int i = 0; i < M; i++){
if (P[i].second >= p){
p = P[i].first;
ans++;
}
}
cout << ans << endl;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |