QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#687597#9221. Missing BoundariesMomo_lightCompile Error//C++172.2kb2024-10-29 19:55:252024-10-29 19:55:26

Judging History

你现在查看的是最新测评结果

  • [2024-10-29 19:55:26]
  • 评测
  • [2024-10-29 19:55:25]
  • 提交

answer

#include<bits/stdc++.h>

using namespace std;

using i32 = int32_t;
using i64 = long long;
using i128 = __int128;

#define int i64

using vi = vector<int>;
using pii = pair<int, int>;

const int inf = INT_MAX / 2;

void solve() {
    int n, L;
    cin >> n >> L;
    vector<pii> seg, p;
    int cnt = 0;
    for (int i = 1, l, r; i <= n; i++) {
        cin >> l >> r;
        if (l != -1 and r != -1) seg.emplace_back(l, r);
        else if (l != -1) p.emplace_back(l, 0);
        else if (r != -1) p.emplace_back(r, 1);
        else cnt++;
    }
    ranges::sort(seg), ranges::sort(p);
    for (int i = 1; i < seg.size(); i++)
        if (seg[i - 1].second >= seg[i].first) {
            cout << "NIE\n";
            return;
        }
    for (int i = 1; i < p.size(); i++)
        if (p[i - 1].first == p[i].first) {
            cout << "NIE\n";
            return;
        }

    int i = 0, cntMax = 0, cntMin = 0;
    auto work = [&](int l, int r) -> bool {
        int lastI = i;
        while (i < p.size() and p[i].first <= r) {
            if (p[i].first < l) return false;
            i++;
        }
        cntMax += (r - l + 1) - (i - lastI);
        if (i == lastI) cntMin++;
        else {
            for (int j = lastI + 1; j < i; j++)
                if (p[j].first != p[j - 1].first + 1 and p[j].second == 0 and p[j - 1].second == 1) cntMin++;
            if (p[lastI].first != l and p[lastI].second == 0) cntMin++;
            if (p[i - 1].first != r and p[i - 1].second == 1) cntMin++;
        }
        return true;
    };

    int lst = 1;
    for (auto [l, r]: seg) {
        if (l > lst and not work(lst, l - 1)) {
            cout << "NIE\n";
            return;
        }
        lst = r + 1;
    }
    if (lst <= L and not work(lst, L)) {
        cout << "NIE\n";
        return;
    }

    if (i != p.size()) {
        cout << "NIE\n";
        return;
    }

    if (cntMin <= cnt and cnt <= cntMax) cout << "TAK\n";
    else cout << "NIE\n";
    return;
}


i32 main() {
    ios::sync_with_stdio(false), cin.tie(nullptr);
    int T;
    cin >> T;
    while (T--)
        solve();
    return 0;
}


Details

answer.code: In function ‘void solve()’:
answer.code:28:5: error: ‘ranges’ has not been declared
   28 |     ranges::sort(seg), ranges::sort(p);
      |     ^~~~~~
answer.code:28:24: error: ‘ranges’ has not been declared
   28 |     ranges::sort(seg), ranges::sort(p);
      |                        ^~~~~~