#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;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
130 ms |
4188 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |