#pragma GCC target("avx2") //#pragma GCC target("avx") //#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") #pragma GCC optimize("O3") //#pragma GCC optimize("Ofast") //#pragma GCC optimize("unroll-loops") // #include // #include #include // #include // #include #include #include #include // #include #include #include #include #include #include #include #include #include // #include // #include // #include // #include // #include // #include // #include // #include // #include // #include // #include // #include // #include // #include // #include // #include // #include // #include // #include // #include // #include // #include // #include // #include // #include // #include // #include // #include // #include // #include // #include // #include // #include // #include // #include // #include // #include // #include // #include // #include // #include // #include // #include // #include // #include #include // #include // #include // #include // #include // #include // #include // #include // #include using namespace std; #include using namespace atcoder; #define STRINGIFY(n) #n #define TOSTRING(n) STRINGIFY(n) using ll = long long; using ull = unsigned long long; template using maxque = priority_queue; template using minque = priority_queue,greater>; #define int ll #define endl "\n" #define unless(cond) if(!(cond)) #define until(cond) while(!(cond)) #define rep(i,s,e) for(ll i = (s); i < (e); ++i) #define repR(i,s,e) for(ll i = (e)-1; (s) <= i; --i) #define repE(i,s,e) for(ll i = (s); i <= (e); ++i) #define repER(i,s,e) for(ll i = (e); (s) <= i; --i) #define repSubsetR(set,super) for(ll _super=super,set = _super; 0 <= set; --set)if(set &= _super, true) #define ALL(xs) begin(xs), end(xs) #define ALLR(xs) rbegin(xs), rend(xs) #define ALLC(xs) cbegin(xs), cend(xs) #define ALLCR(xs) crbegin(xs), crend(xs) template void uniq(C &xs){ xs.erase(unique(ALL(xs)), xs.end()); } template constexpr ll len(C &&xs){ return size(forward(xs)); } ll BIT(ll n){ return 1LL< "; } template void debug_(const X &x, const Xs&... xs){ cerr << x; (void)initializer_list{ (cerr << ", " << xs,0)... };cerr << endl; }void debug_(){ cerr << endl; } #define ASSERT(pred,...) (static_cast(pred) ? void(0) : (debug_h(__FILE__, __LINE__, "ASSERT FAIL! " #pred "; " #__VA_ARGS__),debug_(__VA_ARGS__),exit(1))) template X &&dbg_(X &&x){ cerr<(x); } #ifdef DEBUG #define dbg(x) (debug_h(__FILE__, __LINE__, "" #x),dbg_(x)) #define debug(...) (debug_h(__FILE__, __LINE__, "" #__VA_ARGS__),debug_(__VA_ARGS__)) #define clk(...) (cerr << __VA_ARGS__ " @ " << (clock()-clock0) < decltype(*this); using SELF_ = decltype(((self_fn_*)nullptr)()); DEF_ORD(==) DEF_ORD(!=) DEF_ORD(<) DEF_ORD(>) DEF_ORD(<=) DEF_ORD(>=) template auto operator<<(ostream &out, const C &xs) -> enable_if_t, char*> && !is_same_v, string>, decltype(begin(xs),out)&> { out<<"[ "; for(auto&&x:xs)out< auto operator>>(istream &in, C &xs) -> enable_if_t, char*> && !is_same_v, string>, decltype(begin(xs),in)&> { for(auto&x:xs)in>>x; return in; } template void print_tuple_(ostream &out, Tuple const &xs, std::index_sequence){ out << "("; (void)initializer_list{ (out << (I==0?"":", ") << std::get(xs),0)... }; out << ")"; } template ostream &operator<<(ostream &out, tuple const &xs){ print_tuple_(out, xs, make_index_sequence()); return out; } template void read_tuple_(istream &in, Tuple &xs, std::index_sequence){ (void)initializer_list{ (in >> std::get(xs),0)... }; } template istream &operator>>(istream &in, tuple &xs){ read_tuple_(in, xs, make_index_sequence()); return in; } template ostream &operator<<(ostream &out, pair const &p){ return out << "(" << p.first << ", " << p.second << ")"; } template istream &operator>>(istream &in, pair &p){ return in >> p.first >> p.second; } template> ostream &operator<<(ostream &out, MINT x){ return out << x.val(); } template> istream &operator>>(istream &in, MINT &x){ ll a; in>>a; x = a; return in; } template struct Fix : F { template Fix(G &&g) : F{forward(g)} {} template decltype(auto) operator()(Xs&&... xs)const{ return F::operator()(*this, forward(xs)...); } }; template Fix(F&&) -> Fix>; template bool chmin(T &a, U b){ if(a <= b)return false; a = b; return true; } template bool chmax(T &a, U b){ if(a >= b)return false; a = b; return true; } //const signed MOD = 998244353; const signed MOD = 1000000007; // 10^9+7 using mint = static_modint; // using mint = dynamic_modint<-1>; // mint::set_mod(mod); // using mint0 = dynamic_modint<0>; // mint0::set_mod(mod); const ll INF = BIT(60); struct xor128 { uint32_t x = 123456789; uint32_t y = 362436069; uint32_t z = 521288629; uint32_t w = 88675123; uint32_t next(){ auto t = x ^ (x << 11); x = y; y = z; z = w; return w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)); } } rnd; struct Treap{ Treap *ch[2] = {}; ll pri; ll k; ll v; ll q; Treap(ll k, ll v):pri(rnd.next()),k(k),v(v),q(v){} void update(){ q = max({ query_(ch[0]), v, query_(ch[1]) }); } Treap *rotate(int b){ auto tmp = ch[1-b]; ch[1-b] = tmp->ch[b]; tmp->ch[b] = this; update(); tmp->update(); return tmp; } friend void set_(Treap *&x, ll k, ll v){ unless(x){ x = new Treap(k, v); return; } if(k==x->k){ chmax(x->v, v); x->update(); }else{ ll b = x->k < k; set_(x->ch[b], k, v); x->update(); if(x->pri > x->ch[b]->pri) x = x->rotate(1-b); } } friend ll query_(Treap *x) { return x ? x->q : -1; } friend ll query_(Treap *x, ll k){ unless(x) return -1; ll ret = query_(x->ch[0]); if(k < x->k) return ret; chmax(ret, x->v); if(k==x->k) return ret; chmax(ret, query_(x->ch[1], k));return ret; } friend Treap *clone(Treap const *x){ unless(x) return nullptr; auto ret = new Treap(x->k, x->v); ret->pri = x->pri; ret->q = x->q; rep(i,0,2) ret->ch[i] = clone(x->ch[i]); return ret; } }; struct Seg2D { struct Node{ Treap *trp; Node *ch[2] = {}; }; Node *root = nullptr; ll root_ye=1; void set(ll x, ll y, ll v) { if(root == nullptr){ root = new Node(); until(y < root_ye) root_ye <<= 1; }else{ until(y < root_ye) { root_ye <<= 1; auto old = root; root = new Node(); root->trp = clone(old->trp); root->ch[0] = old; } } Fix impl = [&](auto impl, Node *node, ll ys, ll ye){ set_(node->trp, x, v); if(ys+1 == ye) return; ll ym = (ys+ye)>>1; ll c = ym <= y; if(node->ch[c] == nullptr) node->ch[c] = new Node(); if(c == 0){ impl(node->ch[c], ys, ym); }else{ impl(node->ch[c], ym, ye); } }; impl(root, 0, root_ye); } ll query(ll r, ll t, ll b){ Fix impl = [&](auto impl, Node *node, ll ys, ll ye)->ll{ if(node == nullptr || b <= ys || ye <= t) return -1; if(t <= ys && ye <= b) return query_(node->trp, r-1); ll ym = (ys+ye)>>1; return max( impl(node->ch[0], ys, ym), impl(node->ch[1], ym, ye) ); }; return impl(root, 0, root_ye); } void print(ostream &out){ Fix impl = [&](auto impl, Node *node, ll ys, ll ye, ll lv){ if(node == nullptr) return; rep(foo,0,lv) out << " "; out << "y: ["<trp.print(out, lv+2); ll ym = (ys+ye)>>1; impl(node->ch[0], ys, ym, lv+1); impl(node->ch[1], ym, ye, lv+1); }; impl(root, 0, root_ye, 0); } }; struct Tri{ ll l,r,s2; }; Tri readTri(){ ll a,b,c,d,e,f;cin>>a>>b>>c>>d>>e>>f; ll l = min({a,c,e});l=-l; ll r = max({a,c,e}); c -= a; d -= b; e -= a; f -= b; ll s2 = abs(c*f-d*e); return {l,r,s2}; }; template struct compress{ vector xs; size_t size()const{ return xs.size()+1; } void add(T const&x){ xs.push_back(x); } void prepare(){ sort(ALL(xs)); xs.erase(unique(ALL(xs)), xs.end()); } ll operator[](T const& x){ ll i = lower_bound(ALL(xs), x) - begin(xs); return i+1; } }; ll solve(){ ll n,q;cin>>n>>q; vector tris; rep(i,0,n) tris.push_back(readTri()); vector> queries(q); compress zl,zr; rep(i,0,q){ signed t;cin>>t; if(t == 1){ queries[i] = {t,0,0}; tris.push_back(readTri()); }else{ signed l,r;cin>>l>>r;l=-l; queries[i] = {t,l,r}; zl.add(l); zr.add(r); } } zl.prepare();zr.prepare(); Seg2D trp; rep(i,0,n){ auto tri = tris[i]; trp.set(zl[tri.l], zr[tri.r], tri.s2); } ll i = n; for(auto [t,l,r]:queries){ if(t==1){ auto tri = tris[i++]; trp.set(zl[tri.l], zr[tri.r], tri.s2); continue; } cout << trp.query(zl[l]+1, 0, zr[r]+1) << endl; } exit(0); } signed main(){ cin.tie(nullptr);ios_base::sync_with_stdio(false); cout << fixed << setprecision(15); try{ cout << solve() << endl;/* cout << (solve()?"Yes":"No") << endl; // */ return 0; }catch(exception& e){ cerr << e.what() << endl; }catch(char *s){ cerr << s << endl; } return 1; }