QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#515444 | #2266. Colorful Rectangle | WorldFinalEscaped# | WA | 4496ms | 4832kb | C++17 | 1.8kb | 2024-08-11 17:51:55 | 2024-08-11 17:51:55 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
const int N = 100005;
const int LIM = 105;
struct node {
int x, y, c;
} a[N];
int ans = 1e9;
int qwq[N], len, n;
int calc(int L, int R) {
// printf("calc %d %d\n", L, R);
len = 0;
for (int i = L; i <= R; i++) {
qwq[++len] = a[i].y * 3 + a[i].c;
}
sort(qwq + 1, qwq + len + 1);
int las[3];
memset(las, -0x3f, sizeof(las));
int ret = 1e9;
for (int i = 1; i <= len; i++) {
int u = qwq[i];
las[u % 3] = u / 3;
int t = *min_element(las, las + 3);
ret = min(ret, u / 3 - t);
}
// printf("get result = %d\n", ret);
return ret;
}
void solve() {
sort(a + 1, a + n + 1, [&](node x, node y) { return x.x < y.x; });
int las[3];
memset(las, -0x3f, sizeof(las));
for (int i = 1; i <= n; i++) {
if (clock() / 1. / CLOCKS_PER_SEC > 4.50) {
printf("%d\n", ans);
exit(0);
}
las[a[i].c] = i;
int t = *min_element(las, las + 3);
if (t <= 0 || a[i].x - a[t].x >= ans || a[i].x == a[i + 1].x) continue;
int down = max(1, t - LIM);
for (int j = t; j >= down; j--) {
if (clock() / 1. / CLOCKS_PER_SEC > 4.50) {
printf("%d\n", ans);
exit(0);
}
if (a[i].x - a[j].x >= ans) break;
if (a[j].x == a[j - 1].x && j != down) continue;
ans = min(ans, a[i].x - a[j].x + calc(j, i));
}
}
}
int main() {
scanf("%d", &n);
for (int i = 1; i <= n; i++) {
scanf("%d%d", &a[i].x, &a[i].y);
scanf("%d", &a[i].c);
}
solve();
for (int i = 1; i <= n; i++)
swap(a[i].x, a[i].y);
solve();
printf("%d\n", 2 * ans);
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 4008kb
input:
10 9991473 83825681 1 26476526 51616963 1 50765942 43355004 0 53028333 5604344 2 57100206 5782798 0 80628150 92688632 2 82964896 73929713 2 85102330 11439534 1 86076990 82286008 0 89626190 52420216 0
output:
75818374
result:
ok single line: '75818374'
Test #2:
score: 0
Accepted
time: 1ms
memory: 4024kb
input:
150 90758267 21234402 1 21737107 45944411 2 71064827 33646685 1 15732041 80099984 2 59366384 89336101 1 23463874 1772178 1 63300491 91439944 2 55016570 76385018 2 68263153 41801574 2 87098378 47936087 1 52162678 88263752 2 33679612 20590713 2 75242487 92720661 1 1669174 61465572 2 99532428 10613104 ...
output:
29171440
result:
ok single line: '29171440'
Test #3:
score: 0
Accepted
time: 0ms
memory: 3864kb
input:
10 4093976 78512657 0 27609174 62042588 1 31354091 61870386 0 35151441 36807411 1 37547440 25518220 0 44055162 7821981 2 66673981 41182270 0 83484785 58963611 1 83713705 24676214 2 88603397 80197017 0
output:
75778302
result:
ok single line: '75778302'
Test #4:
score: 0
Accepted
time: 143ms
memory: 4136kb
input:
10000 12096 65562074 1 14562 60486739 1 20187 50242814 1 35859 51060918 0 50463 52231435 1 56216 44100657 2 68431 98864745 1 73973 62323865 1 74745 22912751 2 100382 29322594 2 106833 31933585 2 123956 66437573 2 124095 72164704 2 130151 80006173 1 149897 26940530 1 150544 42049736 2 154249 83266583...
output:
476190
result:
ok single line: '476190'
Test #5:
score: 0
Accepted
time: 41ms
memory: 3952kb
input:
600 46864911 65058066 1 43812689 67844083 1 47624523 65356242 1 65763113 65439718 2 66870643 65931362 0 100000000 43232094 2 99773659 8651677 1 66502329 65775578 0 67130062 61467562 2 41297284 85249873 0 45570122 61586875 1 68626502 64903738 2 44727214 64595373 1 69383055 64974526 2 50960869 6495575...
output:
29384768
result:
ok single line: '29384768'
Test #6:
score: 0
Accepted
time: 190ms
memory: 4060kb
input:
10000 2177 6599212 0 3313 13493229 1 8624 80455572 2 10635 33135945 0 13266 17210177 0 21252 67913127 0 25630 44096615 0 26868 61301695 0 35959 34225877 2 40034 86139028 1 49019 16335976 0 56879 37023369 1 58406 27475381 2 65029 74490416 1 76280 94487503 0 78480 69430131 0 79030 23340728 0 79320 803...
output:
529732
result:
ok single line: '529732'
Test #7:
score: -100
Wrong Answer
time: 4496ms
memory: 4832kb
input:
60000 56904392 34119842 0 56860702 34345199 0 56863596 34223670 0 56833507 34167094 0 69029799 88014623 1 56701555 34308096 0 56818682 34376693 0 56834926 34330417 0 56949550 34257853 0 56684748 34297211 0 56900683 34127043 0 69073935 88044683 1 57002769 34170885 0 56645259 34209545 0 56949514 34101...
output:
107283825
result:
wrong answer 1st lines differ - expected: '214547970', found: '107283825'