이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define int long long
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORD(i, a, b) for (int i = (b); i >= (a); i --)
#define REP(i, a) for (int i = 0; i < (a); ++i)
#define REPD(i, a) for (int i = (a) - 1; i >= 0; --i)
#define MASK(i) (1LL << (i))
#define BIT(x, i) (((x) >> (i)) & 1)
constexpr ll LINF = (1ll << 60);
constexpr int INF = (1ll << 30);
constexpr int Mod = 1e9 + 7;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
/*
Phu Trong from Nguyen Tat Thanh High School for gifted student
*/
template <class X, class Y>
bool minimize(X &x, const Y &y){
X eps = 1e-9;
if (x > y + eps) {x = y; return 1;}
return 0;
}
template <class X, class Y>
bool maximize(X &x, const Y &y){
X eps = 1e-9;
if (x + eps < y) {x = y; return 1;}
return 0;
}
#define MAX 500005
int A[MAX], B[MAX];
int nArr, numQuery;
struct Queries{
int l, r, id;
Queries(){}
Queries(int _l, int _r, int _id): l(_l), r(_r), id(_id){}
} Q[MAX];
namespace SUBTASK_4{
bool check(void){
return nArr <= 100000 && numQuery <= 10;
}
void main(void){
auto solve = [&](int l, int r){
vector<pair<int, int>> events;
FOR(i, l, r){
events.emplace_back(B[i], i);
events.emplace_back(A[i], -i);
}
sort(events.begin(), events.end());
int curLine = 0;
for (int i = 0; i < (int)events.size(); ++i){
if(events[i].second < 0) --curLine;
else ++curLine;
if(i > 0 && curLine == 0){
if(events[i].second == -events[i - 1].second) return false;
}
}
return true;
};
for (int i = 1; i <= numQuery; ++i){
cout << (solve(Q[i].l, Q[i].r) ? "Yes\n" : "No\n");
}
}
}
void process(void){
cin >> nArr;
for (int i = 1; i <= nArr; ++i) cin >> A[i];
for (int i = 1; i <= nArr; ++i) cin >> B[i];
cin >> numQuery;
for (int i = 1; i <= numQuery; ++i){
cin >> Q[i].l >> Q[i].r;
Q[i].id = i;
}
if(SUBTASK_4 :: check()) {
SUBTASK_4 :: main();
return;
}
}
signed main(){
#define name "Whisper"
cin.tie(nullptr) -> sync_with_stdio(false);
//freopen(name".inp", "r", stdin);
//freopen(name".out", "w", stdout);
process();
return (0 ^ 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... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |