Submission #1097667

#TimeUsernameProblemLanguageResultExecution timeMemory
1097667WhisperGift Exchange (JOI24_ho_t4)C++17
50 / 100
165 ms11344 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...