#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
template<class T>
bool minimize(T &a, const T &b) {
if (a > b) return a = b, true;
return false;
}
template<class T>
bool maximize(T &a, const T &b) {
if (a < b) return a = b, true;
return false;
}
#define FOR(i,a,b) for(int i=(a); i<=(b); ++i)
#define FORD(i,a,b) for(int i=(a); i>=(int)b; i--)
#define MASK(i) (1LL << (i))
#define BIT(S, i) (((S) >> (i)) & 1)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define all(x) x.begin(), x.end()
const int MOD = 1e9 + 7;
const int oo = 1e9 + 29032008;
const ll inf = 1e18 + 29032008;
const int N = 1e6 + 5;
int n, q;
int a[N], b[N];
void init(void) {
cin >> n;
FOR(i, 1, n) cin >> a[i];
FOR(i, 1, n) cin >> b[i];
cin >> q;
}
// Hint : chuyển [bi, ai] thành [L ... R] rồi tìm cách nối
namespace sub1 {
void solve() {
FOR(i, 1, q) {
int l, r; cin >> l >> r;
vector <pair <int, int>> sweeps;
FOR(j, l, r) {
sweeps.push_back(make_pair(a[j], - j));
sweeps.push_back(make_pair(b[j], j));
}
sort(all(sweeps));
int cnt = 0;
bool have_ans = true;
FOR(j, 0, (int)sweeps.size() - 1) {
cnt+= (sweeps[j].se < 0 ? - 1 : 1);
if (cnt == 0 && sweeps[j - 1].se == - sweeps[j].se) {
have_ans = false;
break;
}
}
cout << (have_ans ? "Yes" : "No") << "\n";
}
}
}
void process(void) {
sub1 :: solve();
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
#define task "kieuoanh"
if (fopen(task".inp", "r")) {
freopen(task".inp", "r", stdin);
freopen(task".out", "w", stdout);
}
int tc = 1;
// cin >> tc;
while (tc--) {
init();
process();
}
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
Main.cpp: In function 'int main()':
Main.cpp:81:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
81 | freopen(task".inp", "r", stdin);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:82:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
82 | freopen(task".out", "w", stdout);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
# | 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... |