QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#342819#601. 李超树Xiaohuba#AC ✓870ms41604kbC++235.4kb2024-03-01 17:13:292024-03-01 17:13:37

Judging History

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

  • [2024-03-01 17:13:37]
  • 评测
  • 测评结果:AC
  • 用时:870ms
  • 内存:41604kb
  • [2024-03-01 17:13:29]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

// #define LOCK_GETCHAR
// #define USE_INT_128

#if __cplusplus < 201400
#warning "Please use c++14 or higher."
#define CONSTEXPR_FUNC
#define ENABLE_IF_INT
#else
#define CONSTEXPR_FUNC constexpr
#define ENABLE_IF_INT , enable_if_t<_is_integer<T>, int> = 0
template <class T> constexpr bool _is_integer = numeric_limits<T>::is_integer;
template <> constexpr bool _is_integer<bool> = false;
template <> constexpr bool _is_integer<char> = false;
#ifdef USE_INT_128
template <> constexpr bool _is_integer<__int128> = true;
template <> constexpr bool _is_integer<__uint128_t> = true;
#endif
template <class T ENABLE_IF_INT>
constexpr T INF = numeric_limits<T>::max() >> 1;
#endif

#if !defined(_WIN32) && !defined(LOCK_GETCHAR)
#define getchar getchar_unlocked
#endif

#define il inline
#define mkp make_pair
#define fi first
#define se second
#define For(i, j, k) for (decltype(j - k) i = (j); i <= (k); ++i)     // NOLINT
#define ForDown(i, j, k) for (decltype(j - k) i = (j); i >= (k); --i) // NOLINT
#define pb push_back
#define eb emplace_back
#ifndef ONLINE_JUDGE
#define FileIO(filename)                                                       \
  freopen(filename ".in", "r", stdin);                                         \
  freopen(filename ".out", "w", stdout)
#else
#define FileIO(filename) void(0)
#endif

using ll = long long;
using uint = unsigned int;
using ull = unsigned long long;
using db = double;
using ldb = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#ifdef USE_INT_128
using lll = __int128_t;
using ulll = __uint128_t;
#endif

// clang-format off
template<typename T> constexpr il T sq(const T & x){ return x * x; }
template<typename T> CONSTEXPR_FUNC il void cmin(T & x, const T &y){ x = min(x, y); }
template<typename T> CONSTEXPR_FUNC il void cmax(T & x, const T &y){ x = max(x, y);}
template<typename T> CONSTEXPR_FUNC il T qpow(T x, ull y, T mod){T ans = 1; x %= mod; while (y) { if(y & 1)(ans *= x) %= mod;(x *= x) %= mod; y >>= 1;} return ans;}
template<typename T> CONSTEXPR_FUNC il T qpow(T x, ull y){T ans = 1; while (y) {if(y & 1) ans *= x;x *= x;y >>= 1;} return ans;}
template<typename T ENABLE_IF_INT> il void read(T &x){ x = 0; int f = 1; int c = getchar(); while(!isdigit(c)) {if (c == '-') f = -1;c = getchar();} while(isdigit(c)) {x = x * 10 + c - '0';c = getchar();} x *= f;}
template<typename T, typename ... Args> il void read(T &x, Args &... y){ read(x); read(y...); }
// clang-format on

// File head end

namespace {
constexpr ll MAXN = 2e5 + 5;
int n, q;
bool tp[MAXN];
ll qry_pos[MAXN];
vector<ll> pool;
struct Line {
  ll L, R, k, b;
  ll operator()(int x) const {
    // if (x < L || x > R)
    //   cerr << pool[x - 1] << ' ' << L << ' ' << R << ' ' << k << ' ' << b
    //        << '\n';
    assert(x >= L && x <= R);
    return k * pool[x - 1] + b;
  }
} li[MAXN * 2];
struct Node {
  int l, r, id;
  Node() : l(0), r(0), id(0) {}
} T[MAXN << 3];
#define mid(p) ((T[p].l + T[p].r) >> 1)
#define lc(p) (mid(p) << 1)
#define rc(p) (mid(p) << 1 | 1)
void build(int p, int l, int r) {
  T[p].l = l, T[p].r = r;
  if (l == r)
    return;
  build(lc(p), l, mid(p)), build(rc(p), mid(p) + 1, r);
}
il void f(int p, int u) {
  int l = T[p].l, r = T[p].r, mid = (l + r) >> 1, &v = T[p].id;
  auto f1 = mkp(li[u](mid), u) < mkp(li[v](mid), v);
  if (f1)
    swap(u, v);
  if (mkp(li[u](l), u) < mkp(li[v](l), v))
    f(lc(p), u);
  if (mkp(li[u](r), u) < mkp(li[v](r), v))
    f(rc(p), u);
}
void ins(int p, int id) {
  int l = T[p].l, r = T[p].r, ql = li[id].L, qr = li[id].R;
  if (ql <= l && qr >= r)
    return f(p, id);
  int mid = (l + r) >> 1;
  if (ql <= mid)
    ins(lc(p), id);
  if (qr > mid)
    ins(rc(p), id);
}
ll qry(int p, int pos) {
  if (T[p].l == T[p].r)
    return li[T[p].id](pos);
  ll ans = li[T[p].id](pos);
  if (pos <= mid(p))
    cmin(ans, qry(lc(p), pos));
  else
    cmin(ans, qry(rc(p), pos));
  return ans;
}
il void Main() {
  read(n, q);
  li[0] = {-ll(1e9) - 5, ll(1e9) + 5, 0, ll(1e18)};
  For(i, 1, n) {
    read(li[q + i].L, li[q + i].R, li[q + i].k, li[q + i].b), li[q + i].R--;
    pool.eb(li[q + i].L), pool.eb(li[q + i].R);
  }
  For(i, 1, q) {
    int op;
    read(op), tp[i] = op;
    if (!op) {
      read(li[i].L, li[i].R, li[i].k, li[i].b), li[i].R--;
      pool.eb(li[i].L), pool.eb(li[i].R);
    } else {
      read(qry_pos[i]), pool.eb(qry_pos[i]);
    }
  }
  sort(pool.begin(), pool.end());
  pool.erase(unique(pool.begin(), pool.end()), pool.end());
  build(1, 1, pool.size());
  For(i, 1, n) {
    li[q + i].L =
        lower_bound(pool.begin(), pool.end(), li[q + i].L) - pool.begin() + 1;
    li[q + i].R =
        lower_bound(pool.begin(), pool.end(), li[q + i].R) - pool.begin() + 1;
    // cerr << li[q + i].L << ' ' << li[q + i].R << '\n';
    ins(1, q + i);
  }
  // cerr << "ok\n";
  For(i, 1, q) {
    if (!tp[i]) {
      li[i].L =
          lower_bound(pool.begin(), pool.end(), li[i].L) - pool.begin() + 1;
      li[i].R =
          lower_bound(pool.begin(), pool.end(), li[i].R) - pool.begin() + 1;
      ins(1, i);
    } else {
      qry_pos[i] =
          lower_bound(pool.begin(), pool.end(), qry_pos[i]) - pool.begin() + 1;
      ll ans = qry(1, qry_pos[i]);
      if (ans == ll(1e18))
        puts("NO");
      else
        printf("%lld\n", ans);
    }
  }
}
} // namespace

signed main() { return Main(), 0; }

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 353ms
memory: 37476kb

input:

200000 200000
-999998847 -564701 0 0
-999993210 -562917 1 573969
-999989880 -560888 2 1147938
-999978625 -556992 3 1721907
-999976497 -554201 4 2295876
-999970456 -549858 5 2869845
-999961708 -549366 6 3443814
-999955817 -540635 7 4017783
-999950965 -539043 8 4591752
-999948875 -537042 9 5165721
-99...

output:

NO
NO
-50183563496000
-42956317210716
-49932020483680
3156971371995
-4205699747460
-50012287547303
161201413663722
127620184662654
-38152414490346
-6875394617322
-49441462985560
-10483501086163
-46614758184768
-7756362089800
150282043411500
1349780114496
107332409877630
6247978807520
45244266232880
...

result:

ok 200000 lines

Test #2:

score: 0
Accepted
time: 846ms
memory: 41596kb

input:

200000 200000
-471243687 508625098 391807640 -342283806983648705
-340210383 47829053 -391880620 240209487116192693
-274545508 770445695 616772252 -144712167052367176
-880188114 -308896220 -693352586 -29355468444432145
381012675 658211153 -277370657 -223335522481190637
-695379495 -366915786 916546493...

output:

-1397453600647334843
-1029976041695367028
-1052910313176684616
-1818408630134327681
-1209457358134828750
-1718397108261908307
-1355662362476717627
-1314910767061006651
-1106268941848967229
-1898224683466047425
-1657509250418930516
-1221436786841522225
-1155460525928842979
-1903550645895237593
-14152...

result:

ok 100335 lines

Test #3:

score: 0
Accepted
time: 870ms
memory: 41576kb

input:

200000 200000
-735295803 194740970 -863012076 -698790457051536473
-561484685 878894370 -765835546 -885917094660675427
-28147679 -16062512 483876049 516657482726369446
-429018489 295071279 131635136 176429380546917807
227945873 812402553 -271742271 840365646909653826
-834426713 586084304 -547529179 9...

output:

-1664569700711813373
-1053333531588024159
-1000491242308628672
-1733677560351050737
-1609398765293517656
-1328984616378576478
-1129160009603686487
-1588136817928450256
-1060123157746468129
-1738321946600932313
-1778468400542602960
-1436283563532364758
-1569612247881992970
-1086963267195631293
-13664...

result:

ok 99748 lines

Test #4:

score: 0
Accepted
time: 865ms
memory: 41604kb

input:

200000 200000
-317847977 525536138 -997971963 128013476466794548
-548036883 337160985 -145974075 -195700861334636300
-724867754 -641003610 -760696431 -359739374654262877
-601681719 -64013647 216235416 -9458860324088657
-869002669 -536458711 -879969477 -267325832619409885
-887381150 -769771700 -32115...

output:

-1791119671831542466
-1562381666739252256
-1454944338598593191
-1100019661714702943
-1358372216736681172
-1196772147857670480
-1031894514403881624
-1446980382657653744
-1184499370667032484
-1123815059406541220
-1444259966996486892
-1076651931585643352
-1429556580885548952
-1910634429451024811
-12333...

result:

ok 100148 lines

Test #5:

score: 0
Accepted
time: 526ms
memory: 35860kb

input:

127669 148779
-471243687 508625098 391807640 -342283806983648705
-340210383 47829053 -391880620 240209487116192693
-274545508 770445695 616772252 -144712167052367176
-880188114 -308896220 -693352586 -29355468444432145
381012675 658211153 -277370657 -223335522481190637
-695379495 -366915786 916546493...

output:

-1116303818668273275
-1122282748919053950
-1833076145009619469
-1735834163503511299
-1154226917746696725
-1201176061522101225
-1419810711107983900
-1001069231171665854
-1865049592010438359
-1784695455689716511
-1902466130932019738
-1644603386432638268
-1213091162572113800
-1640076278676242796
-14316...

result:

ok 74399 lines

Test #6:

score: 0
Accepted
time: 675ms
memory: 40912kb

input:

150763 148757
-16062512 483876049 742203046 65718231886186737
-114582987 468042711 -913913563 484150211974036615
-448333502 614182218 6577596 -769509849750146393
-710428914 -12354532 497635710 -832906464305757785
-535251031 179614260 -876417353 -806315550178417183
273278837 819733107 -16863556 -7702...

output:

-1134246418002297778
-1465564391209986828
-1088160987472810573
-1570526469596326480
-1599782607445546091
-1391396854062745537
-1094227098401654868
-1732581002225039158
-1419213672956631064
-1945542854966153034
-1606933085452044102
-1304099061249812329
-1905766620229885408
-1578925235477621434
-16365...

result:

ok 74372 lines

Test #7:

score: 0
Accepted
time: 263ms
memory: 31808kb

input:

53336 120203
-997971963 362716733 185423412 -591863682353019904
-548036883 337160985 -145974075 -195700861334636300
-724867754 -641003610 -760696431 -359739374654262877
-601681719 -64013647 216235416 -9458860324088657
-869002669 -536458711 -879969477 -267325832619409885
-887381150 -769771700 -321150...

output:

-1345717484828710015
-1726377225131443611
-1277221842319302387
-1007424626087587316
-1071450544923448652
-1817571882869709507
-1343270791876712432
-1185495743769574829
-1602645704311705269
-1894895849331568810
-1200016566648933802
-1737725631579439522
-1882471460149418657
-1648128295693233892
-17306...

result:

ok 60105 lines

Test #8:

score: 0
Accepted
time: 0ms
memory: 22352kb

input:

11 1
-735559617 -340210383 47829053 240209487116192693
-274545508 770445695 616772252 -144712167052367176
-880188114 -308896220 -693352586 -29355468444432145
381012675 658211153 -277370657 -223335522481190637
-695379495 -366915786 916546493 655754885105439646
-992781513 -138210814 218118434 -3668951...

output:


result:

ok 0 lines

Test #9:

score: 0
Accepted
time: 4ms
memory: 22492kb

input:

6 11
-863012076 114022823 -561484685 -657406391247853790
-765835546 202841757 -28147679 -46121383578455600
483876049 742203046 648085233 -186557943001226187
-429018489 295071279 131635136 176429380546917807
227945873 812402553 -271742271 840365646909653826
-834426713 586084304 -547529179 97833598029...

output:

-637969271526783450
205210645209839855
-51177108112758140
754353035458004034
212402477421334639
-841298371968942545
-911432331322952525
204584401844401007
203868492836643311
-679313538246707630

result:

ok 10 lines

Extra Test:

score: 0
Extra Test Passed