QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#687580#9223. Data DeterminationMomo_lightCompile Error//C++172.2kb2024-10-29 19:51:082024-10-29 19:51:08

Judging History

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

  • [2024-10-29 19:51:08]
  • 评测
  • [2024-10-29 19:51:08]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

using i32 = int32_t;
using i64 = long long;
using ldb = long double;

const i32 inf = INT_MAX / 2;
const i64 INF = LLONG_MAX / 2;

using vi = vector<int>;

void solve() {
    int n, k, m;
    cin >> n >> k >> m;
    vi a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    ranges::sort(a);
    if (k & 1) {
        k /= 2;
        int cntM = ranges::upper_bound(a, m) - ranges::lower_bound(a, m);
        if (cntM == 0) {
            cout << "NIE\n";
            return;
        }
        cntM -= 1;
        int x = a.end() - ranges::upper_bound(a, m);
        int y = ranges::lower_bound(a, m) - a.begin();
        cntM -= max(0, k - x) + max(0, k - y);
        if (cntM >= 0) cout << "TAK\n";
        else cout << "NIE\n";
    } else {
        k = k / 2 - 1;
        for (int r; auto l: a) {
            r = 2ll * m - l;
            if (r < l) break;
            if (l == r) {
                int cntM = ranges::upper_bound(a, m) - ranges::lower_bound(a, m);
                if (cntM == 0) continue;
                cntM -= 2;

                int x = a.end() - ranges::upper_bound(a, m);
                int y = ranges::lower_bound(a, m) - a.begin();
                cntM -= max(0, k - x) + max(0, k - y);
                if (cntM >= 0) {
                    cout << "TAK\n";
                    return;
                }
            } else {
                int cntL = ranges::upper_bound(a, l) - ranges::lower_bound(a, l);
                int cntR = ranges::upper_bound(a, r) - ranges::lower_bound(a, r);
                if (cntL == 0 or cntR == 0) continue;
                cntL--, cntR--;
                int x = a.end() - ranges::upper_bound(a, r);
                int y = ranges::lower_bound(a, l) - a.begin();
                cntR -= max(0, k - x), cntL -= max(0, k - y);
                if (cntR >= 0 and cntL >= 0) {
                    cout << "TAK\n";
                    return;
                }
            }
        }
        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:21:5: error: ‘ranges’ has not been declared
   21 |     ranges::sort(a);
      |     ^~~~~~
answer.code:24:20: error: ‘ranges’ has not been declared
   24 |         int cntM = ranges::upper_bound(a, m) - ranges::lower_bound(a, m);
      |                    ^~~~~~
answer.code:24:48: error: ‘ranges’ has not been declared
   24 |         int cntM = ranges::upper_bound(a, m) - ranges::lower_bound(a, m);
      |                                                ^~~~~~
answer.code:30:27: error: ‘ranges’ has not been declared
   30 |         int x = a.end() - ranges::upper_bound(a, m);
      |                           ^~~~~~
answer.code:31:17: error: ‘ranges’ has not been declared
   31 |         int y = ranges::lower_bound(a, m) - a.begin();
      |                 ^~~~~~
answer.code:37:21: warning: range-based ‘for’ loops with initializer only available with ‘-std=c++20’ or ‘-std=gnu++20’ [-Wc++20-extensions]
   37 |         for (int r; auto l: a) {
      |                     ^~~~
answer.code:41:28: error: ‘ranges’ has not been declared
   41 |                 int cntM = ranges::upper_bound(a, m) - ranges::lower_bound(a, m);
      |                            ^~~~~~
answer.code:41:56: error: ‘ranges’ has not been declared
   41 |                 int cntM = ranges::upper_bound(a, m) - ranges::lower_bound(a, m);
      |                                                        ^~~~~~
answer.code:45:35: error: ‘ranges’ has not been declared
   45 |                 int x = a.end() - ranges::upper_bound(a, m);
      |                                   ^~~~~~
answer.code:46:25: error: ‘ranges’ has not been declared
   46 |                 int y = ranges::lower_bound(a, m) - a.begin();
      |                         ^~~~~~
answer.code:53:28: error: ‘ranges’ has not been declared
   53 |                 int cntL = ranges::upper_bound(a, l) - ranges::lower_bound(a, l);
      |                            ^~~~~~
answer.code:53:56: error: ‘ranges’ has not been declared
   53 |                 int cntL = ranges::upper_bound(a, l) - ranges::lower_bound(a, l);
      |                                                        ^~~~~~
answer.code:54:28: error: ‘ranges’ has not been declared
   54 |                 int cntR = ranges::upper_bound(a, r) - ranges::lower_bound(a, r);
      |                            ^~~~~~
answer.code:54:56: error: ‘ranges’ has not been declared
   54 |                 int cntR = ranges::upper_bound(a, r) - ranges::lower_bound(a, r);
      |                                                        ^~~~~~
answer.code:57:35: error: ‘ranges’ has not been declared
   57 |                 int x = a.end() - ranges::upper_bound(a, r);
      |                                   ^~~~~~
answer.code:58:25: error: ‘ranges’ has not been declared
   58 |                 int y = ranges::lower_bound(a, l) - a.begin();
      |                         ^~~~~~