QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#218003#6733. Moniphant SleepCharlieVinnieRE 0ms0kbC++173.3kb2023-10-17 17:09:522023-10-17 17:09:53

Judging History

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

  • [2023-10-17 17:09:53]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:0kb
  • [2023-10-17 17:09:52]
  • 提交

answer

#include "bits/stdc++.h"
#ifdef DEBUG
#include "PrettyDebug.hpp"
#else
#define debug(...) [](auto...){}(__VA_ARGS__)
#endif
#define For(i,a,b) for(int i=a;i<=b;i++)
#define Rev(i,a,b) for(int i=a;i>=b;i--)
#define Fin(file) freopen(file,"r",stdin)
#define Fout(file) freopen(file,"w",stdout)
#define assume(expr) ((!!(expr))||(exit((fprintf(stderr,"Assumption Failed: %s on Line %d\n",#expr,__LINE__),-1)),false))
#define range basic_string_view
using namespace std; typedef long long ll;
struct Node{
    int x{int(-1e9)},p{0},y{0},d{0},type{0};
    Node& operator+= (const Node& O){
        if(type==0&&O.type==0){
            if(x>=O.p) x+=O.y,y+=O.y;
            else x=O.x,p=max(p,O.p-y),y+=O.y;
            d+=O.d;
        }
        else if(type==0&&O.type==1){
            if(x>=O.p) x=d-x+O.y,y=d-y+O.y;
            else x=d+O.x,p=max(p,O.p-y),y=d-y+O.y;
            d=O.d; type=1;
        }
        else if(type==1&&O.type==0){
            if(d>=O.p) d+=O.y; else d=O.x;
            x+=O.d; y+=O.d;
        }
        else if(type==1&&O.type==1){
            if(d>=O.p) x+=O.y-d,y+=O.y-d; else x+=O.x,y+=O.x;
            d=O.d;
        }
        return *this;
    }
    friend ostream& operator<< (ostream& os,Node O){
        os<<O.x<<' '<<O.p<<' '<<O.y<<' '<<O.d<<' '<<O.type<<'\n'; return os;
    }
};
class STree{
    int n; vector<Node> a;
    #define k1 k<<1
    #define k2 k<<1|1
    void pushdown(int k) { a[k1]+=a[k]; a[k2]+=a[k]; a[k]=Node(); }
    void add(int k,int l,int r,int ql,int qr,Node O){
        if(ql<=l&&r<=qr) return a[k]+=O,void();
        int mid=(l+r)>>1; pushdown(k); if(ql<=mid) add(k1,l,mid,ql,qr,O);; if(mid+1<=qr) add(k2,mid+1,r,ql,qr,O);
    }
    int query(int k,int l,int r,int x){
        if(l==r) return a[k].type==0?a[k].d:a[k].x;; int mid=(l+r)>>1; pushdown(k); return x<=mid?query(k1,l,mid,x):query(k2,mid+1,r,x);
    }
public:
    STree(int _n) { n=_n; a.resize((n<<2)+1); }
    void add(int l,int r,Node O) { add(1,1,n,l,r,O); }
    int query(int x) { return query(1,1,n,x); }
    Node root() { return a[1]; }
};
signed main(){
    atexit([](){cerr<<"Time = "<<clock()<<" ms"<<endl;}); ios::sync_with_stdio(0); cin.tie(0);
    int n,Q; cin>>n>>Q; STree T(n);
    while(Q--){
        int op,l,r; cin>>op>>l>>r;
        if(op==1) T.add(l,r,Node{int(-1e9),0,1,1,0});
        else if(op==2) T.add(l,r,Node{int(-1e9),1,-1,-1,0});
        else if(op==3) T.add(l,r,Node{0,0,0,0,0});
        else if(op==4) T.add(l,r,Node{0,0,0,int(-1e9),1});
        else cout<<500000+T.query(l)<<'\n';
        debug(T.query(1),T.root());
    }
    this_thread::sleep_for(chrono::milliseconds(450));
    return 0;
}

// START TYPING IF YOU DON'T KNOW WHAT TO DO
// STOP TYPING IF YOU DON'T KNOW WHAT YOU'RE DOING
// CONTINUE, NON-STOPPING, FOR CHARLIEVINNIE

// Started Coding On: October 17 Tue, 15 : 19 : 01

// struct Node{
//     int x{-1e9},p{0},y{0};
//     void add() { y++; if(x!=-1e9) x++; }
//     void sub() { y--; if(p+y<0) p++;;  if(x<=0) x=-1e9; else x--; }
//     void set0() { if(x==-1e9) x=0; }
// };
// struct Res{
//     int x{0},p{1e9},y{0};
//     void add() { x++; y++; }
//     void sub() { x--; y--; }
//     void upt(Node O) { assert(p==1e9); p=O.p; x-=O.x; y-=O.y; }
//     int eval(int o) { return o<=p?x:y-o; }
// };

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Dangerous Syscalls

input:

1 9
1 1 1
1 1 1
1 1 1
3 1 1
2 1 1
1 1 1
1 1 1
4 1 1
5 1 1

output:


result: