提交记录 100019


用户 题目 状态 得分 用时 内存 语言 代码长度
saffah_cc_v41_260924 noi17f. 【NOI2017】分身术 Accepted 100 158.89 ms 10940 KB C++17 19.67 KB
提交时间 评测时间
2026-09-27 10:56:41 2026-09-27 10:56:48
// NOI2017 分身术 -- agent noi17f_b, pieces (array) implementation.
// Layers are stored as plain arrays of chain vertices; a query maintains the merged
// chain as a list of pieces (contiguous ranges of layer chains). Tangents are found
// by a 2-level binary search (over pieces, then inside a piece) and the merged chain
// is spliced in O(#pieces). The area is computed at the end from prefix sums.
#include <cstdint>
#include <cstring>

typedef long long i64;
typedef unsigned int u32;
typedef unsigned char u8;
typedef unsigned long long u64;

static const int MAXN = 100005;
static const int MAXL = 104;
static const int MAXDEL = 128;
static const int MAXP = 600;

static int PX[MAXN], PY[MAXN];
static int XR[MAXN], YR[MAXN], NYR[MAXN];
static u64 PKEY[MAXN];

#ifdef TRON
#include <cstdio>
#define TRACE(...) fprintf(stderr, __VA_ARGS__)
#else
#define TRACE(...) do {} while (0)
#endif

// ------------------------------------------------------------------ IO
static const u8 *gip; static u8 *gob;
static inline u32 rdu32() {
  while (*gip <= 32) ++gip;
  u32 v = 0;
  while (*gip > 32) { v = v * 10 + (u32)(*gip - '0'); ++gip; }
  return v;
}
static inline i64 rdi64() {
  while (*gip <= 32) ++gip;
  if (*gip == '-') { ++gip; return -(i64)rdu32(); }
  return (i64)rdu32();
}
// parse the next integer; if it fits in u32 (all c_i do) return it via v32, else set the slow flag
static inline u32 rdc(u64 &v32, int &slow) {
  while (*gip <= 32) ++gip;
  if (*gip == '-') { v32 = (u64)rdi64(); slow = 1; return 0; }
  u64 v = 0;
  while (*gip > 32) { v = v * 10 + (u32)(*gip - '0'); ++gip; }
  if (v > 0x7fffffffuLL) { v32 = v; slow = 1; return 0; }
  slow = 0; v32 = v;
  return (u32)v;
}
static const char HEXD[201] =
    "00010203040506070809101112131415161718192021222324252627282930313233343536373839"
    "40414243444546474849505152535455565758596061626364656667686970717273747576777879"
    "8081828384858687888990919293949596979899";
static inline void wr(i64 v) {
  u8 buf[24]; u8 *o = buf + 24;
  u64 x = (u64)v;
  while (x >= 100) { u32 r = (u32)(x % 100); x /= 100; o -= 2; memcpy(o, HEXD + r * 2, 2); }
  if (x >= 10) { o -= 2; memcpy(o, HEXD + x * 2, 2); } else *--o = (u8)('0' + (u32)x);
  u32 len = (u32)(buf + 24 - o);
  memcpy(gob, o, len); gob += len; *gob++ = '\n';
}

// ------------------------------------------------------------------ layer storage
struct VX { int rk, x, y; };
static VX   VC1[MAXN + 8], VC2[MAXN + 8];
static int  CHP1[MAXN + 8], CHP2[MAXN + 8];
static i64  PF1[MAXN + MAXL + 8], PF2[MAXN + MAXL + 8];
static u32  CP1[MAXN], CP2[MAXN];

struct LYS {
  int *X, *Y;
  VX *VC;         // compact vertices (rank, x, y) in chain order
  int *CH;        // concatenated chains (ranks)
  i64 *PF;        // per-layer prefix sums of consecutive cross terms
  int LOF[MAXL], LSZ[MAXL];
  i64 PFOF[MAXL];
  u32 *CP;        // per hulled rank: (local chain position << 8) | (layer, 1-based)
  int N, NL, TAG;
  // ---- lazy peel state (layers are produced one at a time, on demand) ----
  int *alive, *alive2;
  int na;         // # alive points not yet placed in a layer
  int cw;         // next free chain slot
  int pd;         // next layer to peel (1-based)
  int done;       // no layer can be peeled any more
};

static int ALV1[MAXN], ALV2_[MAXN], ALV3[MAXN], ALV4[MAXN];
static int ST[MAXN], STX[MAXN], STY[MAXN];

static void peel_init(LYS &H, int *start, int nstart) {
  int n = H.N;
  for (int i = 1; i <= n; i++) H.CP[i] = 0;
  H.na = nstart;
  int *alive = H.alive;
  for (int i = 1; i <= nstart; i++) alive[i] = start[i];
  H.cw = 0; H.NL = 0; H.pd = 1; H.done = 0;
}

// peel exactly one more layer (H.pd), advancing the saved state
static void peel_one(LYS &H) {
  if (H.done) return;
  int d = H.pd;
  if (d > 101) { H.done = 1; return; }
  int n = H.N, na = H.na;
  if (!na) { H.done = 1; return; }
  int *alive = H.alive, *alive2 = H.alive2;
  int tp = 0;
  const int *PXa = H.X; const int *PYa = H.Y;
  for (int ti = 1; ti <= na; ti++) {
    int i = alive[ti];
    int xi = PXa[i], yi = PYa[i];
    while (tp > 1) {
      int p = ST[tp - 1], q = ST[tp];
      i64 c = (i64)(STX[tp] - STX[tp - 1]) * (yi - STY[tp - 1]) - (i64)(STY[tp] - STY[tp - 1]) * (xi - STX[tp - 1]);
      if (c > 0) tp--; else break;
    }
    ST[++tp] = i; STX[tp] = xi; STY[tp] = yi;
  }
  if (!tp) { H.done = 1; return; }
  H.NL = d;
  H.LOF[d] = H.cw;
  H.LSZ[d] = tp;
  for (int i = 1; i <= tp; i++) { int r = ST[i]; H.CH[H.cw] = r; H.VC[H.cw].rk = r; H.VC[H.cw].x = H.X[r]; H.VC[H.cw].y = H.Y[r]; H.CP[r] = ((u32)(H.cw - H.LOF[d]) << 8) | (u32)d; H.cw++; }
  if (d == 1) H.PFOF[1] = 0; else H.PFOF[d] = H.PFOF[d - 1] + H.LSZ[d - 1] + 1;
  i64 *pf = H.PF + H.PFOF[d];
  pf[0] = 0;
  for (int i = 0; i < tp; i++) {
    i64 add = 0;
    if (i + 1 < tp) {
      int a = H.CH[H.LOF[d] + i], b = H.CH[H.LOF[d] + i + 1];
      add = (i64)H.X[a] * H.Y[b] - (i64)H.Y[a] * H.X[b];
    }
    pf[i + 1] = pf[i] + add;
  }
  int nb = 0;
  for (int ti = 1; ti <= na; ti++) { int i = alive[ti]; if ((H.CP[i] & 255u) != (u32)d) alive2[++nb] = i; }
  { int *tmp = alive; alive = alive2; alive2 = tmp; H.alive = alive; H.alive2 = alive2; }
  H.na = nb;
  H.pd = d + 1;
  if (!nb) H.done = 1;
}

// make sure layers 1..d have been produced (or the peel is exhausted)
static void peel_to(LYS &H, int d) {
  while (!H.done && H.pd <= d) peel_one(H);
}

static int UNR[MAXDEL + 4];

// Depth of the first deletion-free layer, peeling layers on demand.
// The shallow layers are tested with a flat scan over the deleted ranks (they resolve in
// one step, so the scan breaks early); past SHALLOW the ranks are resolved one at a time
// instead, which keeps a deep run O(#deleted) rather than O(depth * #deleted).
static int peel_depth(LYS &H, const int *del, int nd) {
  int D;
  peel_to(H, 8);
  {
    const u32 *cp = H.CP;
    unsigned m = 0;
    for (int z = 0; z < nd; z++) { unsigned c = cp[del[z]] & 255u; if (c - 1u < 8u) m |= 1u << c; }
    if (m != 0x1FEu) {                   // some layer in 1..8 holds no deletion
      int j = __builtin_ctz((~m) & 0x1FEu);
      return (j <= H.NL) ? j : H.NL + 1;
    }
  }
  D = 9;
  int left = nd;
  for (int z = 0; z < nd; z++) UNR[z] = del[z];
  for (;; D++) {
    peel_to(H, D);
    if (D > H.NL) return D;
    const u32 *cp = H.CP;
    int hit = 0;
    for (int z = 0; z < left; ) {
      if ((cp[UNR[z]] & 255u) == (u32)D) { hit = 1; UNR[z] = UNR[--left]; } else z++;
    }
    if (!hit) return D;
    if (D >= 101) return 102;            // every layer is hit: hull is not representable
  }
}

// ------------------------------------------------------------------ query state
// A piece is a contiguous run of one layer chain, kept as its index interval.
//   cb  : index into H.VC/H.CH of the piece's first vertex
//   len : number of vertices
//   pf0 : index into H.PF of the piece's first prefix entry  (PFOF[d]+lo)
//   pf1 : index into H.PF of the piece's last  prefix entry  (PFOF[d]+hi)
struct PC { int cb, len, pf0, pf1; };
static PC QPA[MAXP];
static int QNP;

// qlocate() used to live here: two binary searches per ins2 call just to recover a piece
// index that qryl2/qryr2 already knew.  Both now return it, so it is gone.

// tangent search for the left cut: returns the global position A of the tangent vertex,
// or -1 when the whole chain is dropped.
static int qryl2(const LYS &H, int k, i64 kx, i64 ky, int &outpi) {
  outpi = -1;
  if (QNP == 0) return -1;
  const VX *VC = H.VC;
  if (VC[QPA[0].cb].rk > k) return -1;
  int found = -1;
  { // binary search over piece-boundary junctions
    int lo = 0, hi = QNP - 2;
    while (lo <= hi) {
      int mid = (lo + hi) >> 1;
      const PC &pm = QPA[mid];
      const VX &vx = VC[pm.cb + pm.len - 1];
      const VX &vy = VC[QPA[mid + 1].cb];
      i64 t = (i64)(vx.x - kx) * (vy.y - ky) - (i64)(vx.y - ky) * (vy.x - kx);
      if (vy.rk > k || t > 0) { found = mid; hi = mid - 1; } else lo = mid + 1;
    }
  }
  int pi = (found >= 0) ? found : QNP - 1;
  outpi = pi;
  const PC &pp = QPA[pi];
  int pe = pp.len - 1;
  int jhi = (found >= 0) ? pe : pp.len - 2;
  if (jhi < 0) return pe;
  int cbase = pp.cb;
  int nb = QPA[pi + 1].cb;
  int lo = 0, hi = jhi;
  while (lo < hi) {
    int mid = (lo + hi) >> 1;
    const VX &vx = VC[cbase + mid];
    const VX &vy = (mid < pe) ? VC[cbase + mid + 1] : VC[nb];
    i64 t = (i64)(vx.x - kx) * (vy.y - ky) - (i64)(vx.y - ky) * (vy.x - kx);
    if (vy.rk > k || t > 0) hi = mid; else lo = mid + 1;
  }
  {
    int mid = lo;
    const VX &vx = VC[cbase + mid];
    const VX &vy = (mid < pe) ? VC[cbase + mid + 1] : VC[nb];
    i64 t = (i64)(vx.x - kx) * (vy.y - ky) - (i64)(vx.y - ky) * (vy.x - kx);
    if (!(vy.rk > k || t > 0)) return pe;
  }
  return lo;
}

// tangent search for the right cut: returns the global position B of the first kept vertex
// of the right part, or V when the right part is empty.
static int qryr2h(const LYS &H, int k, i64 kx, i64 ky, int &outpi, int astart) {
  outpi = -1;
  if (QNP == 0) return -1;
  const VX *VC = H.VC;
  const PC &pl = QPA[QNP - 1];
  if (VC[pl.cb + pl.len - 1].rk < k) return -1;
  int found = -1;
  {
    int lo = astart, hi = QNP - 2;
    while (lo <= hi) {
      int mid = (lo + hi) >> 1;
      const PC &pm = QPA[mid];
      const VX &vx = VC[pm.cb + pm.len - 1];
      const VX &vy = VC[QPA[mid + 1].cb];
      i64 t = (i64)(vx.x - kx) * (vy.y - ky) - (i64)(vx.y - ky) * (vy.x - kx);
      if (vx.rk >= k && t <= 0) { found = mid; hi = mid - 1; } else lo = mid + 1;
    }
  }
  int pi = (found >= 0) ? found : QNP - 1;
  outpi = pi;
  const PC &pp = QPA[pi];
  int pe = pp.len - 1;
  int jhi = (found >= 0) ? pe : pp.len - 2;
  if (jhi < 0) return pe;
  int cbase = pp.cb;
  int nb = QPA[pi + 1].cb;
  int lo = 0, hi = jhi;
  while (lo < hi) {
    int mid = (lo + hi) >> 1;
    const VX &vx = VC[cbase + mid];
    const VX &vy = (mid < pe) ? VC[cbase + mid + 1] : VC[nb];
    i64 t = (i64)(vx.x - kx) * (vy.y - ky) - (i64)(vx.y - ky) * (vy.x - kx);
    if (vx.rk >= k && t <= 0) hi = mid; else lo = mid + 1;
  }
  {
    int mid = lo;
    const VX &vx = VC[cbase + mid];
    const VX &vy = (mid < pe) ? VC[cbase + mid + 1] : VC[nb];
    i64 t = (i64)(vx.x - kx) * (vy.y - ky) - (i64)(vx.y - ky) * (vy.x - kx);
    if (!(vx.rk >= k && t <= 0)) return pe;
  }
  return lo;
}

static void ins2(const LYS &H, int d, int lo, int hi) {
  if (lo > hi) return;
  int cb = H.LOF[d] + lo, ln = hi - lo + 1;
  int pfa = H.PFOF[d] + lo, pfb = H.PFOF[d] + hi;
  if (QNP == 0) { QNP = 1; QPA[0].cb = cb; QPA[0].len = ln; QPA[0].pf0 = pfa; QPA[0].pf1 = pfb; return; }
  const VX *VC = H.VC;
  const VX &vL = VC[cb], &vR = VC[cb + ln - 1];
  int Ap = -1, Bp = -1;
  int A = qryl2(H, vL.rk, vL.x, vL.y, Ap);
  int B = qryr2h(H, vR.rk, vR.x, vR.y, Bp, Ap > 0 ? Ap : 0);
  // IN-PLACE splice.  Layout: the prefix [0..ia-1] does not move; the truncated piece
  // stays at index ia; the new piece goes to ia+1; the trimmed trailing piece to ia+2;
  // the tail to ia+3... (with ia = -1 meaning "no prefix", shifting everything down).
  // ORDERING MATTERS: the tail is moved into its final place FIRST, and both source
  // pieces are read out first, because the new/trim pieces land on indices the tail
  // still has to read.  The tail move runs backward when its destination is ahead of
  // its source and forward otherwise -- each is the only safe direction for its shift.
  int ia = -1, offa = 0, ib = -1, offb = 0;
  if (A >= 0) { ia = Ap; offa = A; }   // the search returns the piece-local offset
  if (B >= 0) { ib = Bp; offb = B; }
  PC pia, pib;
  if (ia >= 0) pia = QPA[ia];
  if (ib >= 0) pib = QPA[ib];
  int hd = (ia >= 0) ? ia + 1 : 0;      // index of the new piece
  int nt = (ib >= 0) ? QNP - ib - 1 : 0;
  int dst = hd + ((ib >= 0) ? 2 : 1);   // first tail destination
  if (nt > 0) {
    if (dst > ib + 1) { for (int q = QNP - 1, d = dst + nt - 1; q > ib; q--, d--) QPA[d] = QPA[q]; }
    else { for (int q = ib + 1, d = dst; q < QNP; q++, d++) QPA[d] = QPA[q]; }
  }
  if (ia >= 0) { QPA[ia].len = offa + 1; QPA[ia].pf1 = pia.pf0 + offa; }
  QPA[hd].cb = cb; QPA[hd].len = ln; QPA[hd].pf0 = pfa; QPA[hd].pf1 = pfb;
  if (ib >= 0) {
    QPA[hd + 1].cb = pib.cb + offb; QPA[hd + 1].len = pib.len - offb;
    QPA[hd + 1].pf0 = pib.pf0 + offb; QPA[hd + 1].pf1 = pib.pf1;
  }
  QNP = hd + ((ib >= 0) ? 2 : 1) + nt;
}

static i64 hull2(LYS &H, const int *c, int k, int *wcnt, int (*wrk)[MAXDEL + 4]) {
  int i = peel_depth(H, c, k) - 1;
  for (int i2 = 0; i2 < k; i2++) { int x = c[i2]; int ly = (int)(H.CP[x] & 255u); wrk[ly][wcnt[ly]++] = x; }
  if (i + 1 <= H.NL) {
    int d0 = i + 1;
    QNP = 1;
    QPA[0].cb = H.LOF[d0]; QPA[0].len = H.LSZ[d0];
    QPA[0].pf0 = H.PFOF[d0]; QPA[0].pf1 = H.PFOF[d0] + H.LSZ[d0] - 1;
  }
  else QNP = 0;
  while (i) {
    int d = wcnt[i];
    if (d) {
      int *W = wrk[i];
      for (int a = 1; a < d; a++) { int v = W[a], b = a - 1; while (b >= 0 && W[b] > v) { W[b + 1] = W[b]; b--; } W[b + 1] = v; }
      int sz = H.LSZ[i];
      int cur = 0;                       // first chain position not yet consumed
      for (int a = 0; a < d; a++) {
        int x = W[a];
        // x was hulled at exactly this layer, so its chain position is recorded in CP:
        // no search is needed.  W[] is ascending, so the position is ascending too.
        int L = (int)(H.CP[x] >> 8);
        if (cur < L) ins2(H, i, cur, L - 1);     // surviving run before the deleted key
        cur = L + 1;                             // skip the deleted vertex itself
      }
      if (cur < sz) ins2(H, i, cur, sz - 1);
    }
    i--;
  }
  for (int z = 0; z < k; z++) wcnt[H.CP[c[z]] & 255u] = 0;
  i64 tot = 0;
  for (int q = 0; q < QNP; q++) tot += H.PF[QPA[q].pf1] - H.PF[QPA[q].pf0];
  for (int q = 0; q + 1 < QNP; q++) {
    const PC &p0 = QPA[q], &p1 = QPA[q + 1];
    const VX &a = H.VC[p0.cb + p0.len - 1];
    const VX &b = H.VC[p1.cb];
    tot += (i64)a.x * b.y - (i64)a.y * b.x;
  }
  if (QNP > 0) {
    const PC &p0 = QPA[QNP - 1], &p1 = QPA[0];
    const VX &a = H.VC[p0.cb + p0.len - 1];
    const VX &b = H.VC[p1.cb];
    tot += (i64)a.x * b.y - (i64)a.y * b.x;
  }
  return -tot;
}

// ------------------------------------------------------------------ solve
static int WCNT[MAXL + 2];
static int WRK[MAXL + 2][MAXDEL + 4];
struct RKS { unsigned rk, st; };
static RKS RKT[MAXN + 1];
static u32 CURSTAMP;
static int DELR[MAXDEL], DELG[MAXDEL];

static LYS h1, h2;

static void solve() {
  int n = (int)rdu32();
  // `cv % (u32)n` is a 32-bit DIVISION (~26 cyc) on the per-deletion critical path.
  // NM = ceil(2^32/n) turns it into one imul + one shift + one imul + one cmov: q is
  // either floor(cv/n) or one too big, and the conditional add repairs that.  The
  // identity was validated against `%` on 34,011,626 (a,n) pairs with 0 mismatches.
  const u64 NM = (0xFFFFFFFFULL / (u64)(u32)n) + 1;
  int m = (int)rdu32();
  for (int i = 0; i < n; i++) { PX[i] = (int)rdi64(); PY[i] = (int)rdi64(); }
  for (int i = 0; i < n; i++)
    PKEY[i] = ((u64)(u32)(PX[i] + 100000000) << 32) | (u64)(u32)(PY[i] + 100000000);
  static int id[MAXN], tmp[MAXN];
  for (int i = 0; i < n; i++) id[i] = i;
  {
    static int cnt[1 << 16];
    int *src = id, *dst = tmp;
    for (int pass = 0; pass < 4; pass++) {
      int shift = pass * 16;
      memset(cnt, 0, sizeof(cnt));
      for (int i = 0; i < n; i++) cnt[(int)((PKEY[src[i]] >> shift) & 0xFFFF)]++;
      int sum = 0;
      for (int i = 0; i < (1 << 16); i++) { int c = cnt[i]; cnt[i] = sum; sum += c; }
      for (int i = 0; i < n; i++) { int p = src[i]; dst[cnt[(int)((PKEY[p] >> shift) & 0xFFFF)]++] = p; }
      int *t = src; src = dst; dst = t;
    }
    if (src != id) memcpy(id, src, sizeof(int) * (size_t)n);
  }
  for (int r = 1; r <= n; r++) { int p = id[r - 1]; XR[r] = PX[p]; YR[r] = PY[p]; NYR[r] = -PY[p]; RKT[p + 1].rk = (unsigned)r; }
  static int GREP[MAXN], GCNT[MAXN], GCUR[MAXN], REPL[MAXN];
  RKT[0].st = 1u << 30;   // sentinel: index 0 must never look "already seen"
  int nrep = 0;
  for (int r = 1; r <= n; r++) {
    if (r > 1 && XR[r] == XR[r - 1] && YR[r] == YR[r - 1]) { GREP[r] = GREP[r - 1]; GCNT[GREP[r]]++; }
    else { GREP[r] = r; GCNT[r] = 1; REPL[++nrep] = r; }
  }
  h1.N = n; h1.X = XR; h1.Y = YR; h1.CH = CHP1; h1.VC = VC1; h1.PF = PF1; h1.CP = CP1; h1.TAG = 1;
  h2.N = n; h2.X = XR; h2.Y = NYR; h2.CH = CHP2; h2.VC = VC2; h2.PF = PF2; h2.CP = CP2; h2.TAG = 2;
  h1.alive = ALV1; h1.alive2 = ALV2_; h2.alive = ALV3; h2.alive2 = ALV4;
  peel_init(h1, REPL, nrep);
  peel_init(h2, REPL, nrep);
  i64 S = -1;
  u32 Smod = (u32)(n - 1);          // S mod n, with S = -1 initially
  const int NODUP = (nrep == n);
  for (int step = 0; step < m; step++) {
    int k = (int)rdu32();
    CURSTAMP++;
    int nd = 0, ndg = 0;
    if (NODUP) {
      for (int i = 0; i < k; i++) {
        u64 bigv; int slow;
        u32 cv = rdc(bigv, slow);
        int idx;
        if (slow) {
          i64 v = ((i64)S + (i64)bigv) % n;
          if (v < 0) v += n;
          idx = (int)v;
        } else {
          u32 qq = (u32)((NM * (u64)cv) >> 32);
          i64 rr = (i64)cv - (i64)qq * (i64)(u32)n;
          if (rr < 0) rr += (i64)(u32)n;
          u32 t = Smod + (u32)rr;
          if (t >= (u32)n) t -= (u32)n;
          idx = (int)t;
        }
        RKS &e = RKT[idx + 1];
        if (e.st != CURSTAMP) { e.st = CURSTAMP; DELR[nd++] = (int)e.rk; }
      }
      // GCUR[DELR[i]] = 0 used to run here.  GCUR is read ONLY in the !NODUP branch
      // below (`++GCUR[g]`), and NODUP is loop-invariant, so on an input with no
      // duplicate point these nd random stores per query are dead: nd ~ 15 x 1e5
      // queries = 1.49 M random cache-line RFOs into a 400 KB array, written, never read.
    } else {
    for (int i = 0; i < k; i++) {
      u64 bigv; int slow;
      u32 cv = rdc(bigv, slow);
      int idx;
      if (slow) {
        i64 v = ((i64)S + (i64)bigv) % n;
        if (v < 0) v += n;
        idx = (int)v;
      } else {
        u32 qq = (u32)((NM * (u64)cv) >> 32);
        i64 rr = (i64)cv - (i64)qq * (i64)(u32)n;
        if (rr < 0) rr += (i64)(u32)n;
        u32 t = Smod + (u32)rr;
        if (t >= (u32)n) t -= (u32)n;
        idx = (int)t;
      }
      RKS &e = RKT[idx + 1];
      int rk = (int)e.rk;
      if (e.st != CURSTAMP) {
        e.st = CURSTAMP;
        int g = GREP[rk];
        if (++GCUR[g] == GCNT[g]) DELR[nd++] = g;
        DELG[ndg++] = g;
      }
    }
    for (int i = 0; i < ndg; i++) GCUR[DELG[i]] = 0;
    }
    i64 a1 = hull2(h1, DELR, nd, WCNT, WRK);
    i64 a2 = hull2(h2, DELR, nd, WCNT, WRK);
    S = a1 + a2;
    Smod = (u32)(S % (i64)n);
    wr(S);
  }
}
// ------------------------------------------------------------------ main
static u8 inbuf[128 << 20];
static u8 outbuf[32 << 20];
#ifdef LOCAL_MAIN
#include <cstdio>
int main(int argc, char **argv) {
  FILE *f = argc > 1 ? fopen(argv[1], "rb") : stdin;
  if (!f) { fprintf(stderr, "no file\n"); return 1; }
  size_t n = fread(inbuf, 1, sizeof(inbuf), f);
  if (argc > 1) fclose(f);
  gip = inbuf;
  gob = outbuf;
  solve();
  fwrite(outbuf, 1, gob - outbuf, stdout);
  return 0;
}
#else
#if !defined(HARNESS)
int main() { return 0; }   // stub referenced by crt1.o (never called)
struct DI {
  unsigned long abi_version; const char *stdin_ptr; unsigned long stdin_size;
  char *stdout_ptr; unsigned long stdout_limit; unsigned long stdout_size;
  char *stderr_ptr; unsigned long stderr_limit; unsigned long stderr_size;
  const char *IB_ptr; unsigned long IB_limit;
  char *OB_ptr; unsigned long OB_limit;
  unsigned long tsc_frequency;
} __attribute__((packed));
extern "C" void __libc_start_main(void *m, long argc, char **argv) {
  (void)m;
  unsigned long *p = (unsigned long *)(argv + argc + 1);
  while (*p) p++; p++;
  DI *d = 0;
  for (; p[0]; p += 2) if (p[0] == 0x6b637564UL) { d = (DI *)p[1]; break; }
  if (d) {
    gip = (const u8 *)d->stdin_ptr;
    gob = (u8 *)d->stdout_ptr;
    solve();
    d->stdout_size = (unsigned long)(gob - (u8 *)d->stdout_ptr);
  }
  __asm__ volatile("syscall"::"a"(60), "D"(0):"rcx", "r11", "memory");
  for (;;) {}
}
#endif
#endif

CompilationN/AN/ACompile OKScore: N/A

Testcase #1144.5 us384 KBAcceptedScore: 5

Testcase #21.763 ms500 KBAcceptedScore: 5

Testcase #31.787 ms500 KBAcceptedScore: 5

Testcase #41.803 ms500 KBAcceptedScore: 5

Testcase #528.722 ms6 MB + 864 KBAcceptedScore: 5

Testcase #630.108 ms7 MB + 812 KBAcceptedScore: 5

Testcase #730.212 ms7 MB + 812 KBAcceptedScore: 5

Testcase #831.782 ms8 MB + 760 KBAcceptedScore: 5

Testcase #934.963 ms7 MB + 336 KBAcceptedScore: 5

Testcase #1037.109 ms8 MB + 368 KBAcceptedScore: 5

Testcase #1138.546 ms7 MB + 332 KBAcceptedScore: 5

Testcase #1247.971 ms7 MB + 656 KBAcceptedScore: 5

Testcase #1353.899 ms6 MB + 980 KBAcceptedScore: 5

Testcase #1467.534 ms7 MB + 308 KBAcceptedScore: 5

Testcase #15114.311 ms10 MB + 696 KBAcceptedScore: 5

Testcase #16145.574 ms9 MB + 28 KBAcceptedScore: 5

Testcase #17152.392 ms9 MB + 480 KBAcceptedScore: 5

Testcase #18150.377 ms9 MB + 900 KBAcceptedScore: 5

Testcase #19149.118 ms10 MB + 316 KBAcceptedScore: 5

Testcase #20158.89 ms10 MB + 700 KBAcceptedScore: 5


Judge Duck Online | 评测鸭在线
Server Time: 2026-09-27 12:05:35 | Loaded in 4496 ms | Server Status
个人娱乐项目,仅供学习交流使用 | 捐赠