QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#864344#3553. Hamburg Steak_8_8_Compile Error//C++232.1kb2025-01-20 15:02:362025-01-20 15:02:36

Judging History

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

  • [2025-01-20 15:02:36]
  • 评测
  • [2025-01-20 15:02:36]
  • 提交

answer

#include <bits/stdc++.h>
    
using namespace std;
    
typedef long long ll;

const int N = (int)1e6 + 12, MOD = 998244353, inf = (int)1e9 + 1;

int n, k;
array<int, 4> a[N];
bool cmp(array<int, 4> x, array<int, 4> y) {
    if(make_pair(x[0], x[1]) == make_pair(y[0], y[1])) {
        if(x[3] != y[3]) {
            return x[3] < y[3];
        }
        return x[2] < y[2];
    }
    if(x[1] != y[1]) {
        return x[1] < y[1];
    }
    return x[] < y[0];
}
vector<array<int, 4>> ans;
bool can(int l, int r, bool v) {
    if(l > r) return true;
    int mn = inf, mx = -inf;
    for(int i = l; i <= r; i++) {
        mn = min(mn, a[i][1]);
        mx = max(mx, a[i][0]);
    }
    array<int, 4> res;
    if(mx > mn) return 0;
    res[0] = mx;
    res[1] = mn;
    mx = -inf, mn = inf;
    for(int i = l; i <= r; i++) {
        mn = min(mn, a[i][3]);
        mx = max(mx, a[i][2]);
    }
    if(mx > mn) return 0;
    res[2] = mx;
    res[3] = mn;
    if(v) {
        ans.push_back(res);
    }
    return true;
}
bool check(int l, int r, bool v) {
    if(l > r) return true;
    for(int i = l; i <= r; i++) {
        if(can(l, i, 0) && can(i + 1, r, 0))  {
            if(v) {
                can(l, i, 1);
                can(i + 1, r, 1);
            }
            return true;
        } 
    }
    return false;
}
void test() {
    cin >> n >> k;
    if(k != 2) return;
    for(int i = 1; i <= n; ++i) {
        cin >> a[i][0] >> a[i][2] >> a[i][1] >> a[i][3];
    }
    sort(a + 1, a + n + 1, cmp);
    int l = 1, r = n + 1;
    while(r - l > 1) {
        int mid = (l + r) >> 1;
        if(check(1, mid, 0)) {
            l = mid;
        } else {
            r = mid;
        }
    }
    assert(l == n);
    check(1, l, 1);
    check(l + 1, n, 1);
    while((int)ans.size() < k) {
        ans.push_back(ans.back());
    }
    for(auto [l, r, u, d] : ans) {
        cout << l << ' ' << u << '\n';
    }
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    int t = 1;
    // cin >> t;

    while(t--) {
        test();
    }
}

详细

answer.code: In function ‘bool cmp(std::array<int, 4>, std::array<int, 4>)’:
answer.code:21:14: error: no match for call to ‘std::array<int, 4>::operator[] ()’
   21 |     return x[] < y[0];
      |              ^
In file included from /usr/include/c++/14/functional:65,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:53,
                 from answer.code:1:
/usr/include/c++/14/array:206:7: note: candidate: ‘constexpr std::array<_Tp, _Nm>::value_type& std::array<_Tp, _Nm>::operator[](size_type) [with _Tp = int; long unsigned int _Nm = 4; reference = int&; size_type = long unsigned int]’
  206 |       operator[](size_type __n) noexcept
      |       ^~~~~~~~
/usr/include/c++/14/array:206:7: note:   candidate expects 1 argument, 0 provided
/usr/include/c++/14/array:214:7: note: candidate: ‘constexpr const std::array<_Tp, _Nm>::value_type& std::array<_Tp, _Nm>::operator[](size_type) const [with _Tp = int; long unsigned int _Nm = 4; const_reference = const int&; size_type = long unsigned int]’
  214 |       operator[](size_type __n) const noexcept
      |       ^~~~~~~~
/usr/include/c++/14/array:214:7: note:   candidate expects 1 argument, 0 provided