제출 #1333395

#제출 시각아이디문제언어결과실행 시간메모리
1333395viettrungCurtains (NOI23_curtains)C++20
44 / 100
203 ms13604 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);
}

bool bp2[ars];
int mn[ars];
void sub4(){
    for(int i = 1; i <= n; i++)
        mn[i] = n + 1;
    for(int i = 1; i <= m; i++){
        cin >> a[i].fi >> a[i].se;
        mn[a[i].se] = min(mn[a[i].se], a[i].fi);
    }
    int cur = 1;
    for(int i = 1; i <= n; i++){
        if(mn[i] <= cur){
            cur = i + 1;
            bp2[i] = true;
        }
    }
    while(q--){
        int s, e;
        cin >> s >> e;
        cout << (bp2[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;
    if(n <= 2000) sub3();
    sub4();
}

컴파일 시 표준 에러 (stderr) 메시지

curtains.cpp: In function 'int main()':
curtains.cpp:98:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   98 |         freopen(task".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
curtains.cpp:99:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   99 |         freopen(task".out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
#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...