| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1333392 | viettrung | Curtains (NOI23_curtains) | C++20 | 1331 ms | 13560 KiB |
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pll pair<ll, ll>
#define pb push_back
#define f(i, a, b) for(int i = a; i <= b; i++)
#define fi first
#define se second
#define mll map<ll, ll>
#define sll set<ll>
const ll du = 1e9 + 7;
const ll ars = 1e6 + 5;
int n, m, q;
pair<int, int> a[ars];
int f[ars];
void sub2(){
for(int i = 1; i <= m; i++)
cin >> a[i].fi >> a[i].se;
while(q--){
int s, e;
cin >> s >> e;
for(int i = s - 1; i <= e + 1; i++) f[i] = 0;
for(int i = 1; i <= m; i++){
if(a[i].fi < s || a[i].se > e) continue;
f[a[i].fi]++;
f[a[i].se + 1]--;
}
bool ok = true;
for(int i = s; i <= e; i++){
f[i] += f[i - 1];
if(f[i] == 0){
ok = false;
break;
}
}
cout << (ok ? "YES" : "NO") << '\n';
}
exit(0);
}
vector<int> pos[ars];
bool bp[2005][2005];
void sub3(){
for(int i = 1; i <= m; i++){
cin >> a[i].fi >> a[i].se;
pos[a[i].se].pb(a[i].fi);
}
for(int i = 1; i <= n; i++)
sort(pos[i].begin(), pos[i].end());
for(int i = 1; i <= n; i++){
int cur = i;
for(int j = i; j <= n; j++){
int it = lower_bound(pos[j].begin(), pos[j].end(), i) - pos[j].begin();
if(it == pos[j].size()) continue;
if(pos[j][it] > cur) continue;
cur = j + 1;
bp[i][j] = true;
}
}
while(q--){
int s, e;
cin >> s >> e;
cout << (bp[s][e] ? "YES" : "NO") << '\n';
}
exit(0);
}
int main() {
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define task "tenshi"
if (fopen(task".inp", "r")) {
freopen(task".inp", "r", stdin);
freopen(task".out", "w", stdout);
}
cin >> n >> m >> q;
sub3();
}
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... | ||||
