QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#864338 | #3553. Hamburg Steak | _8_8_ | 0 | 18ms | 3840kb | C++23 | 2.1kb | 2025-01-20 14:58:11 | 2025-01-20 14:58:24 |
Judging History
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[2] != y[2]) {
return x[2] < y[2];
}
return x[3] < y[3];
}
if(x[0] != y[0]) {
return x[0] < y[0];
}
return x[1] < y[1];
}
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;
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();
}
}
詳細信息
Subtask #1:
score: 0
Memory Limit Exceeded
Test #1:
score: 0
Memory Limit Exceeded
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:
Subtask #2:
score: 0
Wrong Answer
Test #5:
score: 0
Wrong Answer
time: 4ms
memory: 3712kb
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:
50000404 495669410 55334445 533986178
result:
wrong answer steak L=257715250, D=61165602, R=852430884, U=888048968 not sticked by any skewer
Subtask #3:
score: 0
Memory Limit Exceeded
Test #9:
score: 0
Memory Limit Exceeded
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:
Subtask #4:
score: 0
Wrong Answer
Test #21:
score: 6
Accepted
time: 18ms
memory: 3840kb
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:
293219812 495168366 433009777 494344760 476653932 495357540 740481982 494444971
result:
ok all steak sticked
Test #22:
score: 0
Wrong Answer
time: 3ms
memory: 3712kb
input:
1913 4 447764235 131766500 662143128 594925961 175752030 143370745 850970381 604940594 315760617 440375785 908808188 914216196 111980814 70287311 781633529 646769135 18056623 198611867 512791707 850722100 131263504 97431361 865097956 701669444 262211923 224930035 533039033 706346045 107163409 354652...
output:
1424794 462492452 3066623 595055513 3066623 595055513 3066623 595055513
result:
wrong answer steak L=447764235, D=131766500, R=662143128, U=594925961 not sticked by any skewer
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%