提交记录 61756


用户 题目 状态 得分 用时 内存 语言 代码长度
saffah_dsh_v41_0919 noi17f. 【NOI2017】分身术 Time Limit Exceeded 20 3 s 12508 KB C++17 3.44 KB
提交时间 评测时间
2026-09-19 23:03:06 2026-09-19 23:04:01
// noi17f 【NOI2017】分身术  -- v1: rebuild-only-when-a-hull-vertex-dies
// n points, m steps; step deletes k points (ids adaptive: p_i=((S+c_i) mod n)+1),
// print 2*area(hull(alive)) each step.
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef unsigned long long u64;

static const int MAXN = 100005;
static int n, m;
static int px[MAXN], py[MAXN];
static int ord_[MAXN];
static unsigned char del_[MAXN], isHull[MAXN];
static int hull[MAXN];
static int curHull[MAXN];
static int curHsz = 0;
static ll curArea = 0;

static char *ib;
static inline int rd(char *&p) {
    while ((unsigned char)*p <= ' ') p++;
    int sgn = 1;
    if (*p == '-') { sgn = -1; p++; }
    int v = 0;
    while ((unsigned char)*p >= '0') { v = v * 10 + (*p - '0'); p++; }
    return v * sgn;
}

static inline ll cr(int a, int b, int c) {
    return (ll)(px[b] - px[a]) * (ll)(py[c] - py[a]) - (ll)(py[b] - py[a]) * (ll)(px[c] - px[a]);
}

static void rebuild() {
    for (int i = 0; i < curHsz; i++) isHull[curHull[i]] = 0;
    int hn = 0;
    for (int t = 0; t < n; t++) {
        int id = ord_[t];
        if (del_[id]) continue;
        while (hn >= 2 && cr(hull[hn - 2], hull[hn - 1], id) <= 0) hn--;
        hull[hn++] = id;
    }
    if (hn >= 2) {
        int lower = hn;
        for (int t = n - 2; t >= 0; t--) {
            int id = ord_[t];
            if (del_[id]) continue;
            while (hn >= lower + 1 && cr(hull[hn - 2], hull[hn - 1], id) <= 0) hn--;
            hull[hn++] = id;
        }
        hn--;
    }
    curHsz = hn;
    ll s = 0;
    if (hn >= 3) {
        for (int i = 0; i < hn; i++) {
            int a = hull[i], b = hull[i + 1 == hn ? 0 : i + 1];
            s += (ll)px[a] * py[b] - (ll)py[a] * px[b];
        }
        if (s < 0) s = -s;
    }
    curArea = s;
    for (int i = 0; i < hn; i++) { curHull[i] = hull[i]; isHull[hull[i]] = 1; }
}

static char ob[1 << 22];
static char *op = ob;
static inline void wnum(ll v) {
    char tmp[24];
    int l = 0;
    if (v == 0) tmp[l++] = '0';
    while (v) { tmp[l++] = char('0' + v % 10); v /= 10; }
    while (l) *op++ = tmp[--l];
    *op++ = '\n';
}

int main() {
    ib = (char *)malloc(64 << 20);
    size_t got = 0, r;
    while ((r = fread(ib + got, 1, (64u << 20) - got, stdin)) > 0) got += r;
    char *p = ib;
    n = rd(p); m = rd(p);
    for (int i = 0; i < n; i++) { px[i] = rd(p); py[i] = rd(p); ord_[i] = i; }
    sort(ord_, ord_ + n, [](int a, int b) {
        return px[a] != px[b] ? px[a] < px[b] : py[a] < py[b];
    });
    rebuild();
    // isHull now marks the vertices of hull(P); every query state is P \ D_t, so the
    // answer is area(H0) unless D_t removes one of those vertices.
    static unsigned char inH0[MAXN];
    memcpy(inH0, isHull, sizeof(inH0));
    ll h0Area = curArea;
    ll S = -1;
    int dl[128];
    for (int step = 0; step < m; step++) {
        int k = rd(p);
        int need = 0, cnt = 0;
        for (int j = 0; j < k; j++) {
            int c = rd(p);
            ll t = S + (ll)c;
            int id = (int)(((t % n) + n) % n);
            if (!del_[id]) { del_[id] = 1; dl[cnt++] = id; }
            if (inH0[id]) need = 1;
        }
        if (need) { rebuild(); } else { curArea = h0Area; }
        wnum(curArea);
        S = curArea;
        for (int j = 0; j < cnt; j++) del_[dl[j]] = 0;
        if (op - ob > (1 << 22) - 64) { fwrite(ob, 1, op - ob, stdout); op = ob; }
    }
    fwrite(ob, 1, op - ob, stdout);
    return 0;
}

CompilationN/AN/ACompile OKScore: N/A

Testcase #136.41 us152 KBAcceptedScore: 5

Testcase #210.527 ms280 KBAcceptedScore: 5

Testcase #310.627 ms280 KBAcceptedScore: 5

Testcase #410.463 ms280 KBAcceptedScore: 5

Testcase #53 s2 MB + 636 KBTime Limit ExceededScore: 0

Testcase #63 s2 MB + 968 KBTime Limit ExceededScore: 0

Testcase #73 s2 MB + 968 KBTime Limit ExceededScore: 0

Testcase #83 s3 MB + 276 KBTime Limit ExceededScore: 0

Testcase #93 s2 MB + 912 KBTime Limit ExceededScore: 0

Testcase #103 s3 MB + 208 KBTime Limit ExceededScore: 0

Testcase #113 s3 MB + 104 KBTime Limit ExceededScore: 0

Testcase #123 s3 MB + 780 KBTime Limit ExceededScore: 0

Testcase #133 s4 MB + 936 KBTime Limit ExceededScore: 0

Testcase #143 s5 MB + 964 KBTime Limit ExceededScore: 0

Testcase #153 s9 MB + 496 KBTime Limit ExceededScore: 0

Testcase #163 s11 MB + 644 KBTime Limit ExceededScore: 0

Testcase #173 s11 MB + 804 KBTime Limit ExceededScore: 0

Testcase #183 s11 MB + 980 KBTime Limit ExceededScore: 0

Testcase #193 s12 MB + 108 KBTime Limit ExceededScore: 0

Testcase #203 s12 MB + 220 KBTime Limit ExceededScore: 0


Judge Duck Online | 评测鸭在线
Server Time: 2026-11-06 15:15:45 | Loaded in 1 ms | Server Status
个人娱乐项目,仅供学习交流使用 | 捐赠