QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#864343#3553. Hamburg Steak_8_8_0 3ms3840kbC++232.1kb2025-01-20 15:01:302025-01-20 15:01:39

Judging History

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

  • [2025-01-20 15:01:39]
  • 评测
  • 测评结果:0
  • 用时:3ms
  • 内存:3840kb
  • [2025-01-20 15:01:30]
  • 提交

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[0] < 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;
        }
    }
    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();
    }
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3584kb

input:

1936 1
275634612 269663887 525116613 936487725
97408668 7442476 814869170 687312206
436819238 107950642 958111100 591552952
7518596 205530980 782566587 854412425
496572510 309198877 998274921 764947740
205948014 311140816 696959672 600779117
332275583 5172242 984611829 780400859
404519140 226954535 ...

output:


result:

wrong output format Unexpected end of file - int32 expected

Subtask #2:

score: 0
Wrong Answer

Test #5:

score: 0
Wrong Answer
time: 3ms
memory: 3840kb

input:

1928 2
257715250 61165602 852430884 888048968
291121137 322570367 570606015 908598504
418176729 319924920 611676731 632485660
33180758 215166338 468783003 795212414
441068331 188624227 750676748 613482091
344172819 322492096 940801573 568738370
246507550 338324125 785514636 678843646
100885653 12352...

output:

376616176 496147660
503713267 519033356

result:

wrong answer steak L=508761036, D=224368690, R=645652354, U=564372198 not sticked by any skewer

Subtask #3:

score: 0
Wrong Answer

Test #9:

score: 0
Wrong Answer
time: 0ms
memory: 3584kb

input:

1980 3
580358104 434053443 986861108 684634218
125969708 5379869 593299091 644204766
366688051 54873592 662708561 602035535
211630750 166795940 981075947 676159693
524950613 414516203 951984898 573261034
10925143 210994662 543601795 609644115
82102881 63393894 401995062 922075556
245641393 276511435...

output:


result:

wrong output format Unexpected end of file - int32 expected

Subtask #4:

score: 0
Wrong Answer

Test #21:

score: 0
Wrong Answer
time: 0ms
memory: 3584kb

input:

1989 4
20688201 462820019 870557654 779905491
299122723 258293216 630017062 521792413
430322558 33567880 691187720 757852374
104994597 262388698 979697437 904439328
237383344 375297588 673858769 638443621
715773360 364818076 896724313 888051478
235043050 422124296 833892854 936850257
434942952 25412...

output:


result:

wrong output format Unexpected end of file - int32 expected

Subtask #5:

score: 0
Skipped

Dependency #1:

0%

Subtask #6:

score: 0
Skipped

Dependency #2:

0%

Subtask #7:

score: 0
Skipped

Dependency #3:

0%

Subtask #8:

score: 0
Skipped

Dependency #4:

0%