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;
template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl
using ll = long long;
const ll mod = 1e9+7;
const int maxn = 1e5 + 5;
int n, x[maxn], y[maxn];
int m;
int a[maxn], b[maxn], c[maxn];
int main() {
ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
cin>>n;
for (int i=0; i<n-1; i++) {
cin>>x[i]>>y[i];
assert(x[i]==i+1);
assert(y[i]==i+1+1);
}
cin>>m;
for (int i=0; i<m; i++) {
cin>>a[i]>>b[i]>>c[i];
if (a[i]>b[i]) swap(a[i],b[i]);
}
// assume subtask 2
vector<pair<int,int>> v;
for (int i=0; i<m; i++) {
v.push_back({b[i],a[i]});
}
int hi = -1;
int res = 0;
sort(v.begin(),v.end());
for (auto p: v) {
int l = p.second;
int r = p.first;
if (l>hi) {
res++;
//cout<<l<<","<<r<<endl;
hi = max(hi, r);
}
}
cout<<res<<endl;
return 0;
}
# | 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... |