QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#106385 | #3553. Hamburg Steak | bashkort# | 1 | 148ms | 251368kb | C++20 | 2.5kb | 2023-05-17 16:09:15 | 2024-05-31 13:40:00 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
struct Rect {
int x1, y1, x2, y2;
bool in(int x, int y) {
return x1 <= x && x <= x2 && y1 <= y && y <= y2;
}
};
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n, k;
cin >> n >> k;
vector<Rect> r(n);
vector<int> yy, xx;
for (auto &[x1, y1, x2, y2] : r) {
cin >> x1 >> y1 >> x2 >> y2;
yy.push_back(y1), yy.push_back(y2);
xx.push_back(x1), xx.push_back(x2);
}
sort(xx.begin(), xx.end());
sort(yy.begin(), yy.end());
xx.resize(unique(xx.begin(), xx.end()) - xx.begin());
yy.resize(unique(yy.begin(), yy.end()) - yy.begin());
for (auto &[x1, y1, x2, y2] : r) {
x1 = lower_bound(xx.begin(), xx.end(), x1) - xx.begin();
x2 = lower_bound(xx.begin(), xx.end(), x2) - xx.begin();
y1 = lower_bound(yy.begin(), yy.end(), y1) - yy.begin();
y2 = lower_bound(yy.begin(), yy.end(), y2) - yy.begin();
}
int sx = size(xx), sy = size(yy);
auto dfs = [&](auto self, vector<Rect> p, int cnt) -> void {
if (cnt == 0) {
if (!p.empty()) {
exit(0);
}
assert(p.empty());
return;
} else if (p.empty()) {
cout << "1 1\n";
self(self, p, cnt - 1);
return;
}
vector f(sx + 1, vector<int>(sy + 1));
for (auto [x1, y1, x2, y2] : p) {
f[x1][y1] += 1;
f[x1][y2 + 1] -= 1;
f[x2 + 1][y1] -= 1;
f[x2 + 1][y2 + 1] += 1;
}
int mx = -1, x = 0, y = 0;
for (int i = 0; i < size(f); ++i) {
for (int j = 0; j < size(f[i]); ++j) {
if (i > 0) {
f[i][j] += f[i - 1][j];
}
if (j > 0) {
f[i][j] += f[i][j - 1];
}
if (i > 0 && j > 0) {
f[i][j] -= f[i - 1][j - 1];
}
if (f[i][j] > mx) {
mx = f[i][j];
x = i, y = j;
}
}
}
vector<Rect> nxt;
cout << xx[x] << " " << yy[y] << '\n';
for (int j = 0; j < size(p); ++j) {
if (!p[j].in(x, y)) {
nxt.push_back(p[j]);
}
}
self(self, nxt, cnt - 1);
};
dfs(dfs, r, k);
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 1
Accepted
Test #1:
score: 1
Accepted
time: 36ms
memory: 62004kb
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:
500095467 495713566
result:
ok all steak sticked
Test #2:
score: 1
Accepted
time: 35ms
memory: 60968kb
input:
1918 1 101495422 186906933 732615030 881441564 458968315 389772762 517376914 972253676 310129691 156509236 593443672 871966220 91341901 261855863 618682147 864249047 98953032 286357489 522693657 556560771 364790412 127843696 903079225 858654564 329423949 270896020 835948130 589093351 409677593 11179...
output:
508672104 489724537
result:
ok all steak sticked
Test #3:
score: 1
Accepted
time: 33ms
memory: 61936kb
input:
1934 1 149390016 218273120 829091825 943957108 465523240 256616763 562611479 561076814 346779336 19349510 498782244 682919444 355187765 473117629 640518942 857154270 428523527 118919644 980443851 505620423 466172753 4854201 565577102 807575992 63057309 306335591 995966133 973208230 277575294 4065971...
output:
484482652 483569842
result:
ok all steak sticked
Test #4:
score: 1
Accepted
time: 32ms
memory: 62536kb
input:
1943 1 447209427 299197697 579958454 975073773 487022253 6405471 553460639 504906460 483616875 87124408 626036564 533315255 33872888 223251549 940210689 985284538 357235178 224597124 537290418 632810537 45568075 166890122 737266711 881843529 465884824 148626173 976612493 608624682 90616486 330697147...
output:
499714107 499094214
result:
ok all steak sticked
Subtask #2:
score: 0
Wrong Answer
Test #5:
score: 0
Wrong Answer
time: 70ms
memory: 120276kb
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:
550316226 497710845 376616176 496147660
result:
wrong answer steak L=137665267, D=519033356, R=555988733, U=954169685 not sticked by any skewer
Subtask #3:
score: 0
Wrong Answer
Test #9:
score: 3
Accepted
time: 106ms
memory: 187824kb
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:
437786479 497455773 816253792 497245559 274745882 496362979
result:
ok all steak sticked
Test #10:
score: 0
Wrong Answer
time: 108ms
memory: 188020kb
input:
1979 3 166188766 501732855 696148516 858594442 448642394 649848030 826585058 892841834 227996253 41181673 597994927 735947663 496120536 146174371 797127295 937876819 142223416 54620669 692019448 761376043 155423015 310182182 964649015 766725969 149600215 175625826 795416544 456728413 409645085 19620...
output:
502336852 416271263 502180777 779897623 488715392 172082222
result:
wrong answer steak L=464995431, D=416569289, R=716024969, U=660412998 not sticked by any skewer
Subtask #4:
score: 0
Wrong Answer
Test #21:
score: 6
Accepted
time: 148ms
memory: 251368kb
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:
479055748 495357540 740481982 494444971 293219812 487377130 417434611 494344760
result:
ok all steak sticked
Test #22:
score: 0
Wrong Answer
time: 141ms
memory: 233324kb
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:
506925439 595341446 507482141 239896323 497915216 463762505 490302399 600026992
result:
wrong answer steak L=281243046, D=115040592, R=791153518, U=233410717 not sticked by any skewer
Subtask #5:
score: 0
Time Limit Exceeded
Dependency #1:
100%
Accepted
Test #79:
score: 0
Time Limit Exceeded
input:
199927 1 438629555 351412894 521316748 962909150 4328400 108580550 683171263 836435313 256786425 198212822 578214653 567880535 256673124 384187605 616347107 546662355 17067286 405399036 782995564 759479522 41592585 336223869 779372332 767950897 144763906 27980775 808755799 769950439 190038989 499607...
output:
result:
Subtask #6:
score: 0
Skipped
Dependency #2:
0%
Subtask #7:
score: 0
Skipped
Dependency #3:
0%
Subtask #8:
score: 0
Skipped
Dependency #4:
0%