QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#515459#2266. Colorful RectangleWorldFinalEscaped#WA 0ms3864kbC++172.0kb2024-08-11 17:55:552024-08-11 17:55:56

Judging History

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

  • [2024-08-11 17:55:56]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3864kb
  • [2024-08-11 17:55:55]
  • 提交

answer

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

const int N = 100005;
const int LIM = 305;

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; });
    
    static int back[N];
    for (int i = 1; i <= n; i++) {
        if (a[i].x == a[i - 1].x) back[i] = back[i - 1];
        else back[i] = i; 
    } 
    
    int las[3];
    memset(las, -0x3f, sizeof(las)); 
    for (int i = 1; i <= n; i++) {
        if (clock() / 1. / CLOCKS_PER_SEC > 4.90) {
            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); 
        int times = LIM, j = t; 
        while (times-- && j > down) {
            if (clock() / 1. / CLOCKS_PER_SEC > 4.90) {
                printf("%d\n", ans);
                exit(0); 
            } 
            if (a[i].x - a[j].x >= ans) break;
            j = back[j]; 
            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; 
} 

詳細信息

Test #1:

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

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:

138302946

result:

wrong answer 1st lines differ - expected: '75818374', found: '138302946'