이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define Loop(x,l,r) for (ll x = (l); x < (ll)(r); ++x)
#define LoopR(x,l,r) for (ll x = (r)-1; x >= (ll)(l); --x)
typedef long long ll;
typedef std::pair<int, int> pii;
typedef std::pair<ll , ll > pll;
using namespace std;
const int N = 200'010;
tuple<int,int,int> a[N];
int n, m;
void init()
{
cin >> n;
Loop (i,1,n) {
int v, u;
cin >> v >> u;
}
cin >> m;
Loop (i,0,m) {
int x, y;
cin >> x >> y;
if (x < y)
a[i] = {x, y, 0};
else
a[i] = {y, x, 1};
}
}
void solve()
{
init();
sort(a, a+m);
int lst = -1, d = 0;
Loop (i,0,m) {
auto [x, y, d2] = a[i];
if (x > lst) {
lst = y;
d = d2;
} else {
if (y <= lst || d != d2) {
cout << "No\n";
return;
}
lst = y;
}
}
cout << "Yes\n";
}
int main()
{
cin.tie(0) -> sync_with_stdio(false);
int q;
cin >> q;
while (q--)
solve();
}
# | 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... |