# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
902895 | Tuanlinh123 | Jail (JOI22_jail) | C++17 | 5 ms | 468 KiB |
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>
#define ll long long
#define pll pair<ll, ll>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define ld long double
using namespace std;
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
ll t; cin >> t;
while (t--)
{
ll n; cin >> n;
for (ll i=1; i<n; i++)
{
ll u, v;
cin >> u >> v;
}
ll m; cin >> m;
vector <pll> range;
for (ll i=1; i<=m; i++)
{
ll l, r; cin >> l >> r;
if (l>r) swap(l, r);
range.pb({l, -r});
}
sort(range.begin(), range.end());
ll Max=0, ok=1;
for (pll i:range)
{
ll l=i.fi, r=-i.se;
if (Max>=r) {ok=0; break;}
Max=r;
}
if (ok) cout << "Yes\n";
else cout << "No\n";
}
}
Compilation message (stderr)
# | 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... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |