QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#711530#8949. 赫露艾斯塔xlpg07130 1494ms185788kbC++234.3kb2024-11-05 11:52:162024-11-05 11:52:16

Judging History

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

  • [2024-11-05 11:52:16]
  • 评测
  • 测评结果:0
  • 用时:1494ms
  • 内存:185788kb
  • [2024-11-05 11:52:16]
  • 提交

answer

#include<iostream>
#include<random>
#include<chrono>
#include<vector>
#include<algorithm>
#define pb push_back
const int N = 1e6 + 10;
std::mt19937 rn(std::chrono::system_clock::now().time_since_epoch().count());
namespace IO{
    char buf[70000000], *it = buf; void re(){it=buf;}
    template <typename T> inline void rd(T&x){
        for(x=0; !isdigit(*it); it++);
        for(; isdigit(*it); ) x=x*10+*it++-'0';
    }
    template <typename T> inline void wt(T x){
        static char st[20], *tp=st; if(!x) *it++='0';
        while(x) *++tp=char(x%10+'0'), x/=10;
        while(tp!=st) *it++=*tp--; *it++='\n';
    }
    void flush(){fwrite(buf, 1, it - buf, stdout);}
} using IO::rd, IO::wt, IO::re;
struct bst{
    struct nd{int ls, rs, v, x, y, sz, tx, ty;}t[N];
    nd&ls(int x){return t[t[x].ls];} nd&rs(int x){return t[t[x].rs];}
    void pu(int p){t[p].sz = ls(p).sz + rs(p).sz + 1;}
    void pt(int p,int x,int y){x?t[p].x=t[p].tx=x:0;y?t[p].y=t[p].ty=y:0;}
    void pd(int p){pt(t[p].ls,t[p].tx,t[p].ty),pt(t[p].rs,t[p].tx,t[p].ty);}
    void spx(int p, int k, int&l, int&r){
        if(!p) return l = r = 0, void(); pd(p);
        if(t[p].x <= k) l = p, spx(t[p].rs, k, t[p].rs, r);
        else r = p, spx(t[p].ls, k, l, t[p].ls); pu(p);
    }
    void spy(int p, int k, int&l, int&r){
        if(!p) return l = r = 0, void(); pd(p);
        if(t[p].y <= k) l = p, spy(t[p].rs, k, t[p].rs, r);
        else r = p, spy(t[p].ls, k, l, t[p].ls); pu(p);
    }
    void spv(int p, int k, int&l, int&r){
        if(!p) return l = r = 0, void(); pd(p);
        if(t[p].x-t[p].y <= k) l = p, spv(t[p].rs, k, t[p].rs, r);
        else r = p, spv(t[p].ls, k, l, t[p].ls); pu(p);
    }
    int mg(int l, int r){
        if(!l || !r) return l + r; pd(l), pd(r);
        if(t[l].v<t[r].v) return t[l].rs=mg(t[l].rs,r),pu(l),l;
        else return t[r].ls=mg(l,t[r].ls),pu(r),r;
    }
    int szx(int p, int k){ int rs=0; while(p) pd(p),
            t[p].x>k?p=t[p].ls:rs+=ls(p).sz+1,p=t[p].rs; return rs;
    }
    int szy(int p, int k){ int rs=0; while(p) pd(p),
            t[p].y<k?p=t[p].ls:rs+=ls(p).sz+1,p=t[p].rs; return rs;
    }
} T;
struct qu{int x, y, p;}; int n, m, ct, rt, x[N], y[N], rs[N];
int op[N], bx[N], by[N], qx[N], qy[N]; std::vector<int> vc[N];
template <class T, T(*op)(T, T), T(*e)()> struct bt{ T t[N];
    bt(){for(int i = 1; i <= 1e6; i++) t[i] = e();}
    void ad(int p, T x){while(p) t[p] = op(t[p], x), p -= p & -p;}
    T qr(int p){T r=e(); while(p <= 1e6) r = op(r, t[p]), p += p & -p; return r;}
};
bt<int, [](int a, int b){return std::min(a, b);}, [](){return (int)1e8;}> tmn;
bt<int, [](int a, int b){return a + b;}, [](){return 0;}> tx, ty, tm;
bt<int, [](int a, int b){return std::max(a, b);}, [](){return 0;}> tmx;
int main(){
    fread(IO::buf, 1, sizeof IO::buf, stdin);
    std::vector<qu> q; rd(n), rd(m); 
    for(int i = 1; i <= n; i++) rd(x[i]), rd(y[i]), q.pb({x[i], y[i], i});
    for(int i = 1; i <= m; i++) rd(op[i]), 
        rd(bx[i]), rd(by[i]), rd(qx[i]), rd(qy[i]), q.pb({bx[i], by[i], i + n}); 
    std::sort(q.begin(), q.end(), [&](qu a, qu b)
        {return a.x != b.x ? a.x > b.x : a.p > b.p;});
    for(auto [x, y, p] : q) p > n ? tmn.ad(y, p - n) : vc[tmn.qr(y)].pb(p);
    q.clear(); for(int i = 1; i <= n; i++) q.push_back({x[i], y[i], i});
    for(int i = 1; i <= m; i++) q.push_back({qx[i], qy[i], i + n});
    std::sort(q.begin(), q.end(), [&](qu a, qu b)
        {return a.x != b.x ? a.x > b.x : a.p > b.p;});   
    for(auto [x, y, p] : q) p > n ? rs[p - n] = tm.qr(y + 1) : (tm.ad(y, 1), 0);
    for(int i = 1; i <= n; i++) tx.ad(x[i], 1), ty.ad(y[i], 1); re();
    for(int i = 1, sz = n, u, l, r, p; i <= m; i++){
        T.spx(rt, bx[i], l, r), T.spy(l, by[i] + 1, p, u);
        op[i] == 1 ? T.pt(u, 0, by[i]) : T.pt(u, bx[i], 0);
        rt = T.mg(T.mg(p, u), r); for(auto v:vc[i]){
            tx.ad(x[v], -1), ty.ad(y[v], -1), --sz;
            op[i] == 1 ? y[v] = by[i] : x[v] = bx[i]; T.spv(rt, x[v] - y[v], l, r);
            T.t[v] = {0, 0, (int)rn(), x[v], y[v], 1, 0, 0}; rt = T.mg(T.mg(l, v), r);
        } tmx.ad(bx[i], by[i]); if(tmx.qr(qx[i] + 1)>qy[i]){wt(0);continue;}
        rs[i] += sz + T.szx(rt, qx[i]) - T.szy(rt, qy[i] + 1);
        rs[i] -= tx.qr(qx[i] + 1) + ty.qr(qy[i] + 1); wt(rs[i]);
    } IO::flush();
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 5ms
memory: 45512kb

input:

995 996
950 481
376 18
141 776
711 966
130 727
468 529
47 39
857 563
832 821
776 472
154 914
825 279
332 415
470 361
968 440
45 560
299 755
703 785
744 387
547 382
3 549
344 573
778 424
784 765
280 115
251 434
695 98
463 506
379 38
610 486
305 623
703 244
856 365
117 360
772 847
331 723
663 991
900 ...

output:

423
473
758
313
694
232
333
784
821
154
247
244
504
54
200
370
872
782
734
174
660
467
76
754
77
5
144
974
526
415
439
694
507
577
258
120
243
9
2
319
313
498
218
828
433
623
981
700
120
55
70
499
375
283
387
128
317
139
220
410
22
547
3
385
430
168
36
0
178
625
677
561
488
672
577
64
144
537
235
62...

result:

wrong answer 26th numbers differ - expected: '3', found: '5'

Subtask #2:

score: 0
Runtime Error

Test #9:

score: 0
Runtime Error

input:

999996 999996
921339 140126
955508 363759
958698 342406
280137 955674
907511 75721
189876 946586
152058 168837
541857 557702
84498 865987
185574 809224
704828 701026
815379 548000
989515 518951
335439 336866
745570 790616
766723 212893
926629 859003
51261 40866
592510 556235
324926 700261
320946 798...

output:


result:


Subtask #3:

score: 0
Wrong Answer

Test #17:

score: 0
Wrong Answer
time: 1494ms
memory: 185788kb

input:

999995 999997
261379 334440
985281 986034
549380 718157
670003 253925
533027 437989
326806 983213
965935 756259
229069 686789
331338 684961
957559 390618
937820 959719
338153 779814
582581 965418
634156 421264
308778 938878
913059 390904
481477 431492
739774 793015
901442 934600
256704 991485
366691...

output:

160635
633545
123521
313579
450015
383638
574188
2378
203701
326075
117994
567277
652826
199783
380319
380379
105882
373861
788346
703180
609805
648165
367068
497984
57987
478851
745058
75945
543070
251847
769828
436497
480976
235845
509633
757192
763494
396852
262687
2250
267186
165795
558973
16525...

result:

wrong answer 2nd numbers differ - expected: '633543', found: '633545'

Subtask #4:

score: 0
Skipped

Dependency #1:

0%

Subtask #5:

score: 0
Skipped

Dependency #1:

0%