output
stringlengths
52
181k
instruction
stringlengths
296
182k
#include "bits/stdc++.h" using namespace std; typedef long long ll; #define INF INT_MAX #define LINF 1LL<<60 struct SegTree { int N; ll init_v = INF; vector<ll> node, lazy; SegTree(int _N) { N = 1; while (N < _N) N *= 2; node.resize(2 * N - 1, init_v); lazy.resize(2 * N - 1, -1); } void lazy_evaluate(i...
### Prompt Please create a solution in cpp to the following problem: Write a program which manipulates a sequence A = {a0, a1, . . . , an−1} with the following operations: * update(s, t, x): change as, as+1, ..., at to x. * find(i): output the value of ai. Note that the initial values of ai (i = 0, 1, . . . , n−1...
#include <bits/stdc++.h> using namespace std; typedef long long ll; template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; } template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; } #define rep(i, N) for(ll i=0; i<(N); ++i) //sqrtN -> 最大値のみに対応できればいいので,そ...
### Prompt Please create a solution in cpp to the following problem: Write a program which manipulates a sequence A = {a0, a1, . . . , an−1} with the following operations: * update(s, t, x): change as, as+1, ..., at to x. * find(i): output the value of ai. Note that the initial values of ai (i = 0, 1, . . . , n−1...
#include<bits/stdc++.h> using namespace std; #define inf INT_MAX #define INF LLONG_MAX #define ll long long #define ull unsigned long long #define M (int)(1e9+7) #define P pair<int,int> #define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++) #define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--) #define rep(i,n) FOR(i,0,n) #d...
### Prompt Develop a solution in CPP to the problem described below: Write a program which manipulates a sequence A = {a0, a1, . . . , an−1} with the following operations: * update(s, t, x): change as, as+1, ..., at to x. * find(i): output the value of ai. Note that the initial values of ai (i = 0, 1, . . . , n−1...
#include <bits/stdc++.h> using namespace std; int N,Q; const int INF=INT_MAX; struct LazySegmentTree{ private: int n; vector<int> node,lazy; vector<bool> lazyFlag; public: LazySegmentTree(vector<int> v){ int sz=(int)v.size(); n=1; while(n<sz)n*=2; node.resize(2*n-1); lazy.resize(2*n-1,IN...
### Prompt Generate a Cpp solution to the following problem: Write a program which manipulates a sequence A = {a0, a1, . . . , an−1} with the following operations: * update(s, t, x): change as, as+1, ..., at to x. * find(i): output the value of ai. Note that the initial values of ai (i = 0, 1, . . . , n−1) are 23...
#include <bits/stdc++.h> using namespace std; typedef pair<int,int> P; #define FOR(I,A,B) for(int I=int(A);I<int(B);++I) struct RUQ{//平方分割 0-index int n,rn,bn,Q=0; vector<int> a,b,at,bt; RUQ(int n_){ n = n_; rn = sqrt(n); bn = ceil((double)n/rn); a.resize(n,2147483647);at.resize(n,0); b.resize(bn,2147483647)...
### Prompt Generate a cpp solution to the following problem: Write a program which manipulates a sequence A = {a0, a1, . . . , an−1} with the following operations: * update(s, t, x): change as, as+1, ..., at to x. * find(i): output the value of ai. Note that the initial values of ai (i = 0, 1, . . . , n−1) are 23...
#include <iostream> #include <algorithm> using namespace std; #define INF 2147483647 //static const double INF = (1 << 31)-1; int n,q; double d[400000],lazy[400000]; double x; void lazy_evaluate(int k,int l,int r){ if(lazy[k] == INF)return; else{ d[k] = lazy[k]; if(r - l > 1){ lazy[2*k+1] = lazy[k]; lazy[...
### Prompt Please create a solution in Cpp to the following problem: Write a program which manipulates a sequence A = {a0, a1, . . . , an−1} with the following operations: * update(s, t, x): change as, as+1, ..., at to x. * find(i): output the value of ai. Note that the initial values of ai (i = 0, 1, . . . , n−1...
#include <bits/stdc++.h> using namespace std; #define rep(i,x,y) for(int i=(x);i<(y);++i) #define debug(x) #x << "=" << (x) #ifdef DEBUG #define _GLIBCXX_DEBUG #define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl #else #define print(x) #endif const int inf=1e9; const int64_t inf64=1e18; c...
### Prompt Your task is to create a cpp solution to the following problem: Write a program which manipulates a sequence A = {a0, a1, . . . , an−1} with the following operations: * update(s, t, x): change as, as+1, ..., at to x. * find(i): output the value of ai. Note that the initial values of ai (i = 0, 1, . . ....
#include <iostream> #include <vector> using namespace std; class SegTree{ private: int n; // 1-index (tree[0] is dummy), leaves are tree[n]-tree[2n-1] vector<int> tree; const int defVal = 2147483647; public: SegTree(int _n){ int t; t = 1; while (t<_n) t*=2; n = t; tree = vector<int>(2*n, ...
### Prompt Generate a CPP solution to the following problem: Write a program which manipulates a sequence A = {a0, a1, . . . , an−1} with the following operations: * update(s, t, x): change as, as+1, ..., at to x. * find(i): output the value of ai. Note that the initial values of ai (i = 0, 1, . . . , n−1) are 23...
#include<cstdio> #include<climits> using namespace std; static const int MAX_N = 100000; int n, q; int n_; int laz[4 * MAX_N]; void init(){ n_ = 1; while(n_ < n) n_ *= 2; for(int i = 0; i < 2 * n_ - 1; i++){ laz[i] = -1; } laz[0] = INT_MAX; } void prop(int len, int k){ if(laz[k] ==...
### Prompt In cpp, your task is to solve the following problem: Write a program which manipulates a sequence A = {a0, a1, . . . , an−1} with the following operations: * update(s, t, x): change as, as+1, ..., at to x. * find(i): output the value of ai. Note that the initial values of ai (i = 0, 1, . . . , n−1) are...
#include<bits/stdc++.h> using namespace std; const int N=1e5+10; typedef vector<int> vec; class RUQ { public: vec data; vec lazy; int n; RUQ(int _n) { data.resize(4*_n); lazy.resize(4*_n); for(n=1;n<_n;n<<=1); fill(data.begin(),data.end(),(1LL<<31)-1); fi...
### Prompt Your challenge is to write a Cpp solution to the following problem: Write a program which manipulates a sequence A = {a0, a1, . . . , an−1} with the following operations: * update(s, t, x): change as, as+1, ..., at to x. * find(i): output the value of ai. Note that the initial values of ai (i = 0, 1, ....
#include <bits/stdc++.h> using namespace std; #define REP(i, n) for(int i = 0; i < n; i++) #define REPR(i, n) for(int i = n - 1; i >= 0; i--) #define FOR(i, m, n) for(int i = m; i <= n; i++) #define FORR(i, m, n) for(int i = m; i >= n; i--) #define SORT(v, n) sort(v, v+n); #define VSORT(v) sort(v.begin(), v.end()); u...
### Prompt In Cpp, your task is to solve the following problem: Write a program which manipulates a sequence A = {a0, a1, . . . , an−1} with the following operations: * update(s, t, x): change as, as+1, ..., at to x. * find(i): output the value of ai. Note that the initial values of ai (i = 0, 1, . . . , n−1) are...
#include <iostream> #include <climits> #include <vector> #include <algorithm> using namespace std; int find(int x,int n,vector<int>& node) { x += n - 1; int ret = node[x]; while (x > 0) { x = (x - 1) / 2; ret = max(ret, node[x]); } return ret; } void update(int a, int b,int i, int k, int l, int r, vector<int...
### Prompt Create a solution in Cpp for the following problem: Write a program which manipulates a sequence A = {a0, a1, . . . , an−1} with the following operations: * update(s, t, x): change as, as+1, ..., at to x. * find(i): output the value of ai. Note that the initial values of ai (i = 0, 1, . . . , n−1) are ...
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { const int sqrtN = 512; const ll inf = (1LL<<31)-1; int n, q; cin >> n >> q; int bucket_sz = (n+sqrtN-1)/sqrtN; vector<ll> a(n, inf); vector<ll> bucketUp(bucket_sz, 0); vector<bool> bucketFlag(bucket_sz, false); auto pu...
### Prompt Construct a Cpp code solution to the problem outlined: Write a program which manipulates a sequence A = {a0, a1, . . . , an−1} with the following operations: * update(s, t, x): change as, as+1, ..., at to x. * find(i): output the value of ai. Note that the initial values of ai (i = 0, 1, . . . , n−1) a...
#include<iostream> #include<vector> #include<algorithm> using namespace std; #define INF 2147483647 vector<pair<int,int> > a(300000,pair<int,int>(INF,0)); int n,si; int find(int); void update(int,int,int,int,int,int,int); int main(){ int q,f; si=1; cin >> n >> q; for(int i=0;;i++){ si*=2; if(si>=n)brea...
### Prompt In Cpp, your task is to solve the following problem: Write a program which manipulates a sequence A = {a0, a1, . . . , an−1} with the following operations: * update(s, t, x): change as, as+1, ..., at to x. * find(i): output the value of ai. Note that the initial values of ai (i = 0, 1, . . . , n−1) are...
#include<iostream> #include<algorithm> #include<math.h> #include<queue> #include<vector> #include<climits> #include<map> #include<string> #include<functional> #include<iomanip> #include<deque> #include<random> #include<set> using namespace std; typedef long long ll; typedef double lldo; #define mp make_pair #define pu...
### Prompt Generate a Cpp solution to the following problem: Write a program which manipulates a sequence A = {a0, a1, . . . , an−1} with the following operations: * update(s, t, x): change as, as+1, ..., at to x. * find(i): output the value of ai. Note that the initial values of ai (i = 0, 1, . . . , n−1) are 23...
#include <bits/stdc++.h> using namespace std; // Range Update Query // ???[s, t) ???????´???? x ??????????????¨??? // ???i ?????????????´????????????????????????¨??? const int INF = (1LL << 31) - 1; const int sqrtN = 512; struct SqrtDecomposition { int N, K; vector<int> data; vector<bool> lazyFlag; vector<int>...
### Prompt Your challenge is to write a cpp solution to the following problem: Write a program which manipulates a sequence A = {a0, a1, . . . , an−1} with the following operations: * update(s, t, x): change as, as+1, ..., at to x. * find(i): output the value of ai. Note that the initial values of ai (i = 0, 1, ....
#include <bits/stdc++.h> using namespace std; int arr[100005 << 2], value[100005], n, q; void updata(int a, int b, int x, int k = 0, int l = 0, int r = (1 << 17)){ if (b <= l || r <= a)return; if (a <= l && r <= b){ arr[k] = max(arr[k], x); return; } int m = (l + r) / 2; updata(a, b, x, k * 2 + 1, l, m); up...
### Prompt In Cpp, your task is to solve the following problem: Write a program which manipulates a sequence A = {a0, a1, . . . , an−1} with the following operations: * update(s, t, x): change as, as+1, ..., at to x. * find(i): output the value of ai. Note that the initial values of ai (i = 0, 1, . . . , n−1) are...
#include <algorithm> #include <cstdio> #include <iostream> #include <map> #include <cmath> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <vector> #include <stdlib.h> #include <stdio.h> #include <bitset> #include <cstring> #include <deque> #include <iomanip> #include <lim...
### Prompt Generate a cpp solution to the following problem: Write a program which manipulates a sequence A = {a0, a1, . . . , an−1} with the following operations: * update(s, t, x): change as, as+1, ..., at to x. * find(i): output the value of ai. Note that the initial values of ai (i = 0, 1, . . . , n−1) are 23...
#include <bits/stdc++.h> using namespace std; #define rep(i,j,k) for(int i = (int)j;i <= (int)k;i ++) #define debug(x) cerr<<#x<<":"<<x<<endl const int maxn=(int)1e5+5; const int inf=(1ll<<31)-1; #define lson (rt<<1) #define rson (rt<<1|1) int tag[maxn*4];//标记打成-1,用~-1==0简化代码 void upd(int rt,int l,int r,int x,int y,in...
### Prompt Please provide a CPP coded solution to the problem described below: Write a program which manipulates a sequence A = {a0, a1, . . . , an−1} with the following operations: * update(s, t, x): change as, as+1, ..., at to x. * find(i): output the value of ai. Note that the initial values of ai (i = 0, 1, ....
#include<iostream> #include<climits> using namespace std; // 完成版。 int tree[(1 << 18)]; void Update(int s, int t, int m, int left = 0, int right = (1 << 17), int key = 0){ if(t < left || right <= s) return; if(s <= left && right - 1 <= t){ tree[key] = max(tree[key], m); return; } Update(s, t, m, left, (lef...
### Prompt Your challenge is to write a cpp solution to the following problem: Write a program which manipulates a sequence A = {a0, a1, . . . , an−1} with the following operations: * update(s, t, x): change as, as+1, ..., at to x. * find(i): output the value of ai. Note that the initial values of ai (i = 0, 1, ....
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define N (1<<18) ll ai[N*2]; ll value[N*2]; ll max_num = 1; int find(int k){ k += N-1; int ans = ai[k]; int v = value[k]; while(k > 0){ k = (k-1)/2; if(value[k] > v){ ans = ai[k]; v = value[k]...
### Prompt Create a solution in Cpp for the following problem: Write a program which manipulates a sequence A = {a0, a1, . . . , an−1} with the following operations: * update(s, t, x): change as, as+1, ..., at to x. * find(i): output the value of ai. Note that the initial values of ai (i = 0, 1, . . . , n−1) are ...
#include<bits/stdc++.h> using namespace std; #define MAX_N 1<<17 int n,dat[2*(MAX_N)-1]; int valu[2*(MAX_N)-1];//更新順 //INT_MAXで初期化 void init(int n_){ n=1; while(n<n_)n*=2; for(int i=0;i<2*n-1;i++){ dat[i]=INT_MAX; valu[i]=-1; } } //k番目の要素を返す int find(int k){ k+=n-1; int ans=dat[k]; int va=valu[k...
### Prompt Generate a cpp solution to the following problem: Write a program which manipulates a sequence A = {a0, a1, . . . , an−1} with the following operations: * update(s, t, x): change as, as+1, ..., at to x. * find(i): output the value of ai. Note that the initial values of ai (i = 0, 1, . . . , n−1) are 23...
#include <bits/stdc++.h> using namespace std; #define int long long const int INF = (1LL << 31) - 1; const int sqrtN = 512; struct SqrtDecomposition { int N, K; vector<int> data; vector<bool> lazyFlag; vector<int> lazyUpdate; SqrtDecomposition(int n) : N(n) { K = (N + sqrtN - 1) / sqrtN; data.assign...
### Prompt In CPP, your task is to solve the following problem: Write a program which manipulates a sequence A = {a0, a1, . . . , an−1} with the following operations: * update(s, t, x): change as, as+1, ..., at to x. * find(i): output the value of ai. Note that the initial values of ai (i = 0, 1, . . . , n−1) are...
#include <iostream> #include <vector> using namespace std; const int INF = 2147483647; struct SegmentTree { int n; vector<int> heap; SegmentTree(int n): n(n) { heap.assign(4 * n, INF); } void update(int nodeId, int l, int r, int ql, int qr, int v) { if (qr < l || ql > r)...
### Prompt Please provide a Cpp coded solution to the problem described below: Write a program which manipulates a sequence A = {a0, a1, . . . , an−1} with the following operations: * update(s, t, x): change as, as+1, ..., at to x. * find(i): output the value of ai. Note that the initial values of ai (i = 0, 1, ....
#line 1 "test/aoj/DSL2D.test.cpp" #define PROBLEM "http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DSL_2_D" #include <iostream> #line 1 "segment_tree/dual_segment_tree.hpp" #include <vector> #include <cstdint> //=== template<class Monoid> struct DualSegmentTree { using T = typename Monoid::value_type; ...
### Prompt Your task is to create a Cpp solution to the following problem: Write a program which manipulates a sequence A = {a0, a1, . . . , an−1} with the following operations: * update(s, t, x): change as, as+1, ..., at to x. * find(i): output the value of ai. Note that the initial values of ai (i = 0, 1, . . ....
#include<bits/stdc++.h> using namespace std; #define int long long typedef pair<int,int> P; struct RUP{ int n; vector<P> dat; RUP(){} RUP(int n_){init(n_);} void init(int n_){ n=1; while(n<n_) n*=2; dat.clear(); dat.resize(2*n-1); for(int i=0;i<2*n-1;i++) dat[i].first=-1,dat[i].second=INT_...
### Prompt Develop a solution in Cpp to the problem described below: Write a program which manipulates a sequence A = {a0, a1, . . . , an−1} with the following operations: * update(s, t, x): change as, as+1, ..., at to x. * find(i): output the value of ai. Note that the initial values of ai (i = 0, 1, . . . , n−1...
#include <iostream> #include <string> #include <cstring> #include <fstream> #include <random> #include <cmath> #include <iomanip> #include <climits> #include <cstdlib> #include <algorithm> #include <vector> #include <map> #include <deque> #include <map> #include <set> #include <unordered_set> #include <queue> #include ...
### Prompt Please create a solution in Cpp to the following problem: Write a program which manipulates a sequence A = {a0, a1, . . . , an−1} with the following operations: * update(s, t, x): change as, as+1, ..., at to x. * find(i): output the value of ai. Note that the initial values of ai (i = 0, 1, . . . , n−1...
#include <bits/stdc++.h> using namespace std; int N, Q; int const INF = INT_MAX; struct LazySegmentTree { private: int n; vector<int> node, lazy; vector<bool> lazyFlag; public: LazySegmentTree(vector<int> v) { int sz = (int)v.size(); n = 1; while(n < sz) n *= 2; node.resize(2*n...
### Prompt Please provide a cpp coded solution to the problem described below: Write a program which manipulates a sequence A = {a0, a1, . . . , an−1} with the following operations: * update(s, t, x): change as, as+1, ..., at to x. * find(i): output the value of ai. Note that the initial values of ai (i = 0, 1, ....
#include "bits/stdc++.h" using namespace std; #ifdef _DEBUG #include "dump.hpp" #else #define dump(...) #endif //#define int long long #define rep(i,a,b) for(int i=(a);i<(b);i++) #define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--) #define all(c) begin(c),end(c) const int INF = (1ll << 31) - 1; const int MOD = (int)(1e9) +...
### Prompt Please create a solution in cpp to the following problem: Write a program which manipulates a sequence A = {a0, a1, . . . , an−1} with the following operations: * update(s, t, x): change as, as+1, ..., at to x. * find(i): output the value of ai. Note that the initial values of ai (i = 0, 1, . . . , n−1...
#include <bits/stdc++.h> using namespace std; class lazy_segtree { public: int size; vector<int> node,lazy; lazy_segtree(int n_) { size=1; while (size<n_) size*=2; node.resize(2 * size, INT_MAX); lazy.resize(2 * size, -1); } v...
### Prompt Generate a Cpp solution to the following problem: Write a program which manipulates a sequence A = {a0, a1, . . . , an−1} with the following operations: * update(s, t, x): change as, as+1, ..., at to x. * find(i): output the value of ai. Note that the initial values of ai (i = 0, 1, . . . , n−1) are 23...
#include <iostream> #include <climits> #include <algorithm> #define lson l, m, o << 1 #define rson m + 1, r, o << 1 | 1 const int N = 1e5 + 1; int mn[N << 2]; int lazy[N << 2]; void up(int o) { mn[o] = std::min(mn[o << 1], mn[o << 1 | 1]); } void down(int o) { if (lazy[o] != -1) { mn[o << 1] = lazy[o]; ...
### Prompt Develop a solution in Cpp to the problem described below: Write a program which manipulates a sequence A = {a0, a1, . . . , an−1} with the following operations: * update(s, t, x): change as, as+1, ..., at to x. * find(i): output the value of ai. Note that the initial values of ai (i = 0, 1, . . . , n−1...
#include<iostream> #include<algorithm> #include <stdio.h> using namespace std; typedef pair<int,int> p; #define TREE_N (1<<17) int c,n; p tree[ TREE_N * 2 -1],ans; void update(int i,int x,int t){ i+=TREE_N-1; if(t==-1)tree[i]=p(-1,x); else ans=tree[i]; while(i>0){ i=(i-1)/2; if(t==-1)tree[i]=p(t,x); ...
### Prompt Generate a CPP solution to the following problem: Write a program which manipulates a sequence A = {a0, a1, . . . , an−1} with the following operations: * update(s, t, x): change as, as+1, ..., at to x. * find(i): output the value of ai. Note that the initial values of ai (i = 0, 1, . . . , n−1) are 23...
#include "bits/stdc++.h" using namespace std; #ifdef _DEBUG #include "dump.hpp" #else #define dump(...) #endif //#define int long long #define rep(i,a,b) for(int i=(a);i<(b);i++) #define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--) #define all(c) begin(c),end(c) const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f...
### Prompt Develop a solution in CPP to the problem described below: Write a program which manipulates a sequence A = {a0, a1, . . . , an−1} with the following operations: * update(s, t, x): change as, as+1, ..., at to x. * find(i): output the value of ai. Note that the initial values of ai (i = 0, 1, . . . , n−1...
#include<bits/stdc++.h> #define int long long using namespace std; template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; } template<class T>bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; } class SegmentTree { private: int n; vector<int> node; public: ...
### Prompt Generate a Cpp solution to the following problem: Write a program which manipulates a sequence A = {a0, a1, . . . , an−1} with the following operations: * update(s, t, x): change as, as+1, ..., at to x. * find(i): output the value of ai. Note that the initial values of ai (i = 0, 1, . . . , n−1) are 23...
#include <bits/stdc++.h> #define pb push_back using namespace std; typedef long long ll; const int maxn=400005; struct { ll mn=0x7fffffff,lazy=-1; } S[maxn]; int n,q; void update(int id,int ql,int qr,int v,int l,int r) { if (ql==l && qr==r) { S[id].lazy=v; return; } if (S[id].lazy!=-1) { S[id].mn=S[id].laz...
### Prompt Please provide a CPP coded solution to the problem described below: Write a program which manipulates a sequence A = {a0, a1, . . . , an−1} with the following operations: * update(s, t, x): change as, as+1, ..., at to x. * find(i): output the value of ai. Note that the initial values of ai (i = 0, 1, ....
#include <bits/stdc++.h> using namespace std; struct RU { using t1 = int; using t2 = int; static t2 id2() { return -1; } static t1 op2(const t1& l, const t2& r) { return r == id2() ? l : r; } static t2 op3(const t2& l, const t2& r) { return r == id2() ? l : r; } }; template <typename M> class lazy_segment_tree {...
### Prompt Please formulate a CPP solution to the following problem: Write a program which manipulates a sequence A = {a0, a1, . . . , an−1} with the following operations: * update(s, t, x): change as, as+1, ..., at to x. * find(i): output the value of ai. Note that the initial values of ai (i = 0, 1, . . . , n−1...
#include<bits/stdc++.h> using namespace std; const int MAX_N = 1<<18; typedef pair<int,int> P; int n_; P dat[2*MAX_N-1]; void init(int n) { n_=1; while (n>n_) { n_*=2; } for (int i=0; i<2*n_-1; i++) { dat[i].first=-1; dat[i].second=INT_MAX; } } int find(int i) { i+=n_-1; P p=dat[i]; while (...
### Prompt Please provide a Cpp coded solution to the problem described below: Write a program which manipulates a sequence A = {a0, a1, . . . , an−1} with the following operations: * update(s, t, x): change as, as+1, ..., at to x. * find(i): output the value of ai. Note that the initial values of ai (i = 0, 1, ....
#include<bits/stdc++.h> using namespace std; int A[300000],B[300000]; int flag[300000]; int n,q; void evaluate(int k){ if(flag[k]==0) return ; A[k*2+1]=A[k*2+2]=B[k]; B[k*2+1]=B[k*2+2]=B[k]; flag[k*2+1]=flag[k*2+2]=1; flag[k]=0; return ; } int update(int s,int t,int x,int k,int l,int r){ if(s>=r || l>=t) ...
### Prompt Create a solution in Cpp for the following problem: Write a program which manipulates a sequence A = {a0, a1, . . . , an−1} with the following operations: * update(s, t, x): change as, as+1, ..., at to x. * find(i): output the value of ai. Note that the initial values of ai (i = 0, 1, . . . , n−1) are ...
#include<bits/stdc++.h> #define rep(i,n)for(int i=0;i<(n);i++) using namespace std; #ifndef MAX #define MAX 400000 #endif //Range Update Query+Range Sum Query template<class T> class RUQ_RSQ { public: int n; T dat[MAX], lazy[MAX], ZERO, DEFAULT; void init(int n_, T d = INT_MAX, T t = 0) { DEFAULT = d; ZERO = T(...
### Prompt Your task is to create a Cpp solution to the following problem: Write a program which manipulates a sequence A = {a0, a1, . . . , an−1} with the following operations: * update(s, t, x): change as, as+1, ..., at to x. * find(i): output the value of ai. Note that the initial values of ai (i = 0, 1, . . ....
#include<cstdio> #include<vector> #include<algorithm> #include<utility> #include<numeric> #include<iostream> #include<array> #include<string> #include<sstream> #include<stack> #include<queue> #include<list> #include<functional> #define _USE_MATH_DEFINES #include<math.h> #include<map> #define SENTINEL 1000000001 #def...
### Prompt Please formulate a Cpp solution to the following problem: Write a program which manipulates a sequence A = {a0, a1, . . . , an−1} with the following operations: * update(s, t, x): change as, as+1, ..., at to x. * find(i): output the value of ai. Note that the initial values of ai (i = 0, 1, . . . , n−1...
#include "bits/stdc++.h" using namespace std; #ifdef _DEBUG #include "dump.hpp" #else #define dump(...) #endif //#define int long long #define rep(i,a,b) for(int i=(a);i<(b);i++) #define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--) #define all(c) begin(c),end(c) const int INF = (1ll << 31) - 1; const int MOD = (int)(1e9) +...
### Prompt Please formulate a Cpp solution to the following problem: Write a program which manipulates a sequence A = {a0, a1, . . . , an−1} with the following operations: * update(s, t, x): change as, as+1, ..., at to x. * find(i): output the value of ai. Note that the initial values of ai (i = 0, 1, . . . , n−1...
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 10; pair<int, int> operator-(pair<int, int> a, pair<int, int> b) { return pair<int, int>(a.first - b.first, a.second - b.second); } long long operator%(pair<int, int> a, pair<int, int> b) { return 1LL * a.first * b.second - 1LL * a.second * b.first; ...
### Prompt Please formulate a cpp solution to the following problem: After the war, the supersonic rocket became the most common public transportation. Each supersonic rocket consists of two "engines". Each engine is a set of "power sources". The first engine has n power sources, and the second one has m power sourc...
#include <bits/stdc++.h> using namespace std; struct vec2l { long x, y; }; string vec_to_str(const vec2l& val) { return "(" + to_string(val.x) + ", " + to_string(val.y) + ")"; } vector<vec2l> read_points(int n) { vector<vec2l> result; result.reserve(n); for (int i = 0; i < n; ++i) { vec2l p; scanf("%l...
### Prompt Please create a solution in cpp to the following problem: After the war, the supersonic rocket became the most common public transportation. Each supersonic rocket consists of two "engines". Each engine is a set of "power sources". The first engine has n power sources, and the second one has m power sourc...
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 2; const int INF = 1e9 + 7; const double EPS = 1e-10; struct Point { int x, y; Point() {} Point(int x, int y) : x(x), y(y) {} friend Point operator-(Point p1, Point p2) { return Point(p1.x - p2.x, p1.y - p2.y); } friend bool operator<(Poi...
### Prompt Generate a Cpp solution to the following problem: After the war, the supersonic rocket became the most common public transportation. Each supersonic rocket consists of two "engines". Each engine is a set of "power sources". The first engine has n power sources, and the second one has m power sources. A po...
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 5; struct tpoint { long long x, y; tpoint() {} tpoint(long long _x, long long _y) : x(_x), y(_y) {} } p1[N], hu1[N], p2[N], hu2[N]; tpoint operator-(tpoint a, tpoint b) { return tpoint(a.x - b.x, a.y - b.y); } long long cross(tpoint a, tpoint b) { ...
### Prompt Please provide a cpp coded solution to the problem described below: After the war, the supersonic rocket became the most common public transportation. Each supersonic rocket consists of two "engines". Each engine is a set of "power sources". The first engine has n power sources, and the second one has m p...
#include <bits/stdc++.h> using namespace std; const int max_n = 100111, inf = 1000111222; struct point { int x, y; point() { x = y = 0; } point(int x, int y) : x(x), y(y) {} void read() { scanf("%d%d", &x, &y); } void write(string s = "") { printf("%d %d%s", x, y, s.c_str()); } void write_point(string s = "...
### Prompt Construct a Cpp code solution to the problem outlined: After the war, the supersonic rocket became the most common public transportation. Each supersonic rocket consists of two "engines". Each engine is a set of "power sources". The first engine has n power sources, and the second one has m power sources....
#include <bits/stdc++.h> using namespace std; const int N = 600005; long long read() { long long x = 0; char ch = getchar(); while (!isdigit(ch)) ch = getchar(); while (isdigit(ch)) x = (x << 1) + (x << 3) + ch - 48, ch = getchar(); return x; } int n, m; struct Point { int x, y; } p1[N], p2[N], O; long long...
### Prompt Generate a cpp solution to the following problem: After the war, the supersonic rocket became the most common public transportation. Each supersonic rocket consists of two "engines". Each engine is a set of "power sources". The first engine has n power sources, and the second one has m power sources. A po...
#include <bits/stdc++.h> using namespace std; int N, M; vector<pair<signed long long, signed long long>> A, B; vector<pair<long double, long double>> C, D; const signed long long EPS = 0; template <class C> C veccross(pair<C, C> p1, pair<C, C> p2, pair<C, C> p3) { p3.first -= p1.first; p2.first -= p1.first; p3.se...
### Prompt Please create a solution in cpp to the following problem: After the war, the supersonic rocket became the most common public transportation. Each supersonic rocket consists of two "engines". Each engine is a set of "power sources". The first engine has n power sources, and the second one has m power sourc...
#include <bits/stdc++.h> using namespace std; const int MAXN = 500002; const long long MOD = 1500000001; const long long p = 239017; struct Point { long long x, y; Point() {} Point(const Point& p1, const Point& p2) : x(p2.x - p1.x), y(p2.y - p1.y) {} Point(long long x, long long y) : x(x), y(y) {} bool operat...
### Prompt Generate a Cpp solution to the following problem: After the war, the supersonic rocket became the most common public transportation. Each supersonic rocket consists of two "engines". Each engine is a set of "power sources". The first engine has n power sources, and the second one has m power sources. A po...
#include <bits/stdc++.h> using namespace std; const long long M = 998244353; const long long NMAX = 200011; const long long inf = 1E18; const long double eps = 1e-9; const long long base = 29; struct pt { long long x, y; pt(long long x, long long y) { this->x = x; this->y = y; } pt() {} }; pt a[NMAX]; p...
### Prompt Your challenge is to write a cpp solution to the following problem: After the war, the supersonic rocket became the most common public transportation. Each supersonic rocket consists of two "engines". Each engine is a set of "power sources". The first engine has n power sources, and the second one has m p...
#include <bits/stdc++.h> using namespace std; struct pt { long long x, y; pt(int x, int y) : x(x), y(y) {} }; bool cmp(pt a, pt b) { return a.x < b.x || (a.x == b.x && a.y < b.y); } long long cp(pt a, pt b, pt c) { return a.x * (b.y - c.y) + b.x * (c.y - a.y) + c.x * (a.y - b.y); } long long dist(pt a, pt b) { ...
### Prompt Create a solution in Cpp for the following problem: After the war, the supersonic rocket became the most common public transportation. Each supersonic rocket consists of two "engines". Each engine is a set of "power sources". The first engine has n power sources, and the second one has m power sources. A ...
#include <bits/stdc++.h> using namespace std; const double pi = acos(-1); struct Point { long long x, y; }; inline Point operator+(Point a, Point b) { return (Point){a.x + b.x, a.y + b.y}; } inline Point operator-(Point a, Point b) { return (Point){a.x - b.x, a.y - b.y}; } inline long long cross(Point a, Point b)...
### Prompt Develop a solution in Cpp to the problem described below: After the war, the supersonic rocket became the most common public transportation. Each supersonic rocket consists of two "engines". Each engine is a set of "power sources". The first engine has n power sources, and the second one has m power sourc...
#include <bits/stdc++.h> using namespace std; const double EPS = 1e-9; inline int comp(double A, double B = 0) { return (A <= B + EPS) ? (A + EPS < B) ? -1 : 0 : 1; } struct point { double x, y; point(double x = 0, double y = 0) : x(x), y(y) {} bool operator<(const point &other) const { if (!comp(x, other.x...
### Prompt Please formulate a cpp solution to the following problem: After the war, the supersonic rocket became the most common public transportation. Each supersonic rocket consists of two "engines". Each engine is a set of "power sources". The first engine has n power sources, and the second one has m power sourc...
#include <bits/stdc++.h> using namespace std; const long double INF = 1e100; const long double EPS = 1e-12; bool eq(long double a, long double b) { return abs(a - b) < EPS; } struct Pt { long double x, y; Pt() {} Pt(long double x, long double y) : x(x), y(y) {} Pt(const Pt &p) : x(p.x), y(p.y) {} Pt operator+...
### Prompt In Cpp, your task is to solve the following problem: After the war, the supersonic rocket became the most common public transportation. Each supersonic rocket consists of two "engines". Each engine is a set of "power sources". The first engine has n power sources, and the second one has m power sources. A...
#include <bits/stdc++.h> const int N = 100005; using namespace std; struct Point { double x, y; Point(double x = 0, double y = 0) : x(x), y(y) {} }; Point operator+(Point a, Point b) { return Point(a.x + b.x, a.y + b.y); } Point operator-(Point a, Point b) { return Point(a.x - b.x, a.y - b.y); } Point operator*(Poi...
### Prompt Develop a solution in CPP to the problem described below: After the war, the supersonic rocket became the most common public transportation. Each supersonic rocket consists of two "engines". Each engine is a set of "power sources". The first engine has n power sources, and the second one has m power sourc...
#include <bits/stdc++.h> using namespace std; const int INFTY = 20000000; const int MAX = 400100; const long long MOD = 1000000009; void coutTab(int* tab, int n) { for (int i = 0; i < n; i++) { cout << tab[i] << " "; } cout << "\n"; } struct Point { long long x, y; }; long long vecProd(Point p1, Point p2, P...
### Prompt Please create a solution in cpp to the following problem: After the war, the supersonic rocket became the most common public transportation. Each supersonic rocket consists of two "engines". Each engine is a set of "power sources". The first engine has n power sources, and the second one has m power sourc...
#include <bits/stdc++.h> using namespace std; long long N; long long M; struct point { long long x, y; point() {} point(long long x, long long y) : x(x), y(y) {} long long ilg() { return x * x + y * y; } }; point operator-(point a, point b) { return point(a.x - b.x, a.y - b.y); } long long cross(point a, point ...
### Prompt Please provide a cpp coded solution to the problem described below: After the war, the supersonic rocket became the most common public transportation. Each supersonic rocket consists of two "engines". Each engine is a set of "power sources". The first engine has n power sources, and the second one has m p...
#include <bits/stdc++.h> using namespace std; const int maxN = 200005; struct dot { long long x, y; dot() {} dot(long long _x, long long _y) { x = _x; y = _y; } void read() { int _x, _y; scanf("%d%d", &_x, &_y); x = _x; y = _y; } void output() { cout << x << " " << y << endl; } l...
### Prompt Your challenge is to write a cpp solution to the following problem: After the war, the supersonic rocket became the most common public transportation. Each supersonic rocket consists of two "engines". Each engine is a set of "power sources". The first engine has n power sources, and the second one has m p...
#include <bits/stdc++.h> using namespace std; const int MAXN = 101010; class Point { public: int x, y; Point(int x = 0, int y = 0) : x(x), y(y) {} Point operator-(const Point &b) { return Point(x - b.x, y - b.y); } long long len2() { return 1ll * x * x + 1ll * y * y; } } a[MAXN], b[MAXN], aa[MAXN], bb[MAXN]; b...
### Prompt Develop a solution in Cpp to the problem described below: After the war, the supersonic rocket became the most common public transportation. Each supersonic rocket consists of two "engines". Each engine is a set of "power sources". The first engine has n power sources, and the second one has m power sourc...
#include <bits/stdc++.h> using namespace std; const int MAXN = 100100; int N[2]; complex<long long> P[2][MAXN]; complex<long long> H[2][MAXN]; int csz[2]; long long A[2][2 * MAXN]; int M = 0; long long S[6 * MAXN]; int Z[6 * MAXN]; void Zalg() { int L = 0, R = 0; for (int i = 1; i < M; i++) { if (i > R) { ...
### Prompt Your challenge is to write a cpp solution to the following problem: After the war, the supersonic rocket became the most common public transportation. Each supersonic rocket consists of two "engines". Each engine is a set of "power sources". The first engine has n power sources, and the second one has m p...
#include <bits/stdc++.h> using namespace std; const long long INF = 1e18 + 100; vector<int> prefix_function(string s) { int n = (int)s.length(); vector<int> pi(n); for (int i = 0; i < n; ++i) for (int k = 0; k <= i; ++k) if (s.substr(0, k) == s.substr(i - k + 1, k)) pi[i] = k; return pi; } struct Poin...
### Prompt Your challenge is to write a CPP solution to the following problem: After the war, the supersonic rocket became the most common public transportation. Each supersonic rocket consists of two "engines". Each engine is a set of "power sources". The first engine has n power sources, and the second one has m p...
#include <bits/stdc++.h> using namespace std; const int MAXN = 200005, INF = 0x3f3f3f3f; struct Pt { long long x, y; Pt() {} Pt(int xx, int yy) { x = xx; y = yy; } Pt operator+(const Pt &o) { return Pt(x + o.x, y + o.y); } Pt operator-(const Pt &o) { return Pt(x - o.x, y - o.y); } long long operat...
### Prompt Please provide a CPP coded solution to the problem described below: After the war, the supersonic rocket became the most common public transportation. Each supersonic rocket consists of two "engines". Each engine is a set of "power sources". The first engine has n power sources, and the second one has m p...
#include <bits/stdc++.h> using namespace std; const double eps = 1e-12; int dcmp(double x) { if (x > eps) return 1; if (x < -eps) return -1; return 0; } struct point { double x, y; point() {} point(double _x, double _y) : x(_x), y(_y) {} void read() { scanf("%lf%lf", &x, &y); } friend point operator+(co...
### Prompt In cpp, your task is to solve the following problem: After the war, the supersonic rocket became the most common public transportation. Each supersonic rocket consists of two "engines". Each engine is a set of "power sources". The first engine has n power sources, and the second one has m power sources. A...
#include <bits/stdc++.h> using namespace std; const int MAXN = 1E5 + 10; pair<int64_t, int64_t> p1[MAXN], p2[MAXN], hull1[MAXN], hull2[MAXN], norm1[MAXN * 3], norm2[MAXN]; int z[MAXN]; int64_t dist(pair<int64_t, int64_t> a, pair<int64_t, int64_t> b) { return (a.first - b.first) * (a.first - b.first) + (a...
### Prompt Your challenge is to write a Cpp solution to the following problem: After the war, the supersonic rocket became the most common public transportation. Each supersonic rocket consists of two "engines". Each engine is a set of "power sources". The first engine has n power sources, and the second one has m p...
#include <bits/stdc++.h> using namespace std; vector<pair<int, int> > points; pair<int, int> pivot; vector<pair<int, int> > ch1, ch2; inline bool deq(const double &a, const double &b) { return fabs(a - b) < 1e-10; } bool cmp(const pair<int, int> &a, const pair<int, int> &b) { if (a.first == b.first) return a.second...
### Prompt Generate a cpp solution to the following problem: After the war, the supersonic rocket became the most common public transportation. Each supersonic rocket consists of two "engines". Each engine is a set of "power sources". The first engine has n power sources, and the second one has m power sources. A po...
#include <bits/stdc++.h> using namespace std; void ControlIO(); void TimerStart(); void TimerStop(); const long long mod = 1000000007; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); typedef int coord_t; typedef long long coord2_t; struct Point { coord_t x, y; bool operator<(const Point &p) con...
### Prompt Construct a Cpp code solution to the problem outlined: After the war, the supersonic rocket became the most common public transportation. Each supersonic rocket consists of two "engines". Each engine is a set of "power sources". The first engine has n power sources, and the second one has m power sources....
#include <bits/stdc++.h> using namespace std; const double eps = 1e-6, pi = acos(-1.0); inline int dcmp(double x) { if (fabs(x) < eps) return 0; return x < 0 ? -1 : 1; } inline double sqr(double x) { return x * x; } struct Point { double x, y; Point(double _x = 0, double _y = 0) : x(_x), y(_y){}; inline void ...
### Prompt Your task is to create a Cpp solution to the following problem: After the war, the supersonic rocket became the most common public transportation. Each supersonic rocket consists of two "engines". Each engine is a set of "power sources". The first engine has n power sources, and the second one has m power...
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 1; const int inf = 0x3f3f3f3f; const double pi = acos(-1); int read() { char c = getchar(); int res = 0; while (c < '0' || c > '9') c = getchar(); while (48 <= c && c <= 57) { res = res * 10 + c - '0'; c = getchar(); } return res; } b...
### Prompt Generate a Cpp solution to the following problem: After the war, the supersonic rocket became the most common public transportation. Each supersonic rocket consists of two "engines". Each engine is a set of "power sources". The first engine has n power sources, and the second one has m power sources. A po...
#include <bits/stdc++.h> using namespace std; const double PI = acos(-1.0); double fRand(double fMin, double fMax) { double f = (double)rand() / RAND_MAX; return fMin + f * (fMax - fMin); } template <class T> T min(T a, T b, T c) { return min(a, min(b, c)); } template <class T> T max(T a, T b, T c) { return max...
### Prompt Your task is to create a cpp solution to the following problem: After the war, the supersonic rocket became the most common public transportation. Each supersonic rocket consists of two "engines". Each engine is a set of "power sources". The first engine has n power sources, and the second one has m power...
#include <bits/stdc++.h> using namespace std; inline int inn() { int x, ch; while ((ch = getchar()) < '0' || ch > '9') ; x = ch ^ '0'; while ((ch = getchar()) >= '0' && ch <= '9') x = (x << 1) + (x << 3) + (ch ^ '0'); return x; } inline int sgn(long long x) { return (x < 0) ? -1 : (x > 0); } inline in...
### Prompt Please provide a CPP coded solution to the problem described below: After the war, the supersonic rocket became the most common public transportation. Each supersonic rocket consists of two "engines". Each engine is a set of "power sources". The first engine has n power sources, and the second one has m p...
#include <bits/stdc++.h> using namespace std; int myRnd() { return abs(((rand() << 14) ^ rand())); } int myRnd(int L, int R) { return abs(((rand() << 15) ^ rand())) % (R - L + 1) + L; } void Parr(int *arr, int L, int R) { for (int i = L; R >= i; i++) { printf("%d%c", arr[i], " \n"[i == R]); } } void Pvec(vect...
### Prompt In cpp, your task is to solve the following problem: After the war, the supersonic rocket became the most common public transportation. Each supersonic rocket consists of two "engines". Each engine is a set of "power sources". The first engine has n power sources, and the second one has m power sources. A...
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 10; typedef struct point { long long x, y; point(long long _x = 0, long long _y = 0) : x(_x), y(_y) {} bool operator<(const point &B) const { return x != B.x ? x < B.x : y < B.y; } point operator-(const point &B) const { return point(x - B.x, ...
### Prompt In Cpp, your task is to solve the following problem: After the war, the supersonic rocket became the most common public transportation. Each supersonic rocket consists of two "engines". Each engine is a set of "power sources". The first engine has n power sources, and the second one has m power sources. A...
#include <bits/stdc++.h> #pragma comment(linker, "/STACK:1024000000,1024000000") using namespace std; const int INF = 2147483647; const int mod = 1000000007; const int mod2 = 998244353; const double eps = 1e-9; const double pi = acos(-1.0); inline int rint() { int x; scanf("%d", &x); return x; } inline long long ...
### Prompt In Cpp, your task is to solve the following problem: After the war, the supersonic rocket became the most common public transportation. Each supersonic rocket consists of two "engines". Each engine is a set of "power sources". The first engine has n power sources, and the second one has m power sources. A...
#include <bits/stdc++.h> using namespace std; struct Pt { long long x, y; Pt() {} Pt(long long _x, long long _y) : x(_x), y(_y) {} Pt operator+(const Pt &p) const { return Pt(x + p.x, y + p.y); } Pt operator-(const Pt &p) const { return Pt(x - p.x, y - p.y); } Pt operator*(long long c) const { return Pt(x *...
### Prompt Create a solution in cpp for the following problem: After the war, the supersonic rocket became the most common public transportation. Each supersonic rocket consists of two "engines". Each engine is a set of "power sources". The first engine has n power sources, and the second one has m power sources. A ...
#include <bits/stdc++.h> using namespace std; const int Imx = 2147483647; const long long Lbig = 2e18; const int mod = 1e9 + 7; struct fastio { char s[100000]; int it, len; fastio() { it = len = 0; } inline char get() { if (it < len) return s[it++]; it = 0; len = fread(s, 1, 100000, stdin); if (...
### Prompt Please formulate a cpp solution to the following problem: After the war, the supersonic rocket became the most common public transportation. Each supersonic rocket consists of two "engines". Each engine is a set of "power sources". The first engine has n power sources, and the second one has m power sourc...
#include <bits/stdc++.h> using namespace std; const int maxn = int(1e5) + 100; bool cmp(pair<long long, long long> b, pair<long long, long long> c); long long det(pair<long long, long long> b, pair<long long, long long> c, pair<long long, long long> o); pair<long long, long long> tmp[maxn]; struct convex ...
### Prompt Generate a CPP solution to the following problem: After the war, the supersonic rocket became the most common public transportation. Each supersonic rocket consists of two "engines". Each engine is a set of "power sources". The first engine has n power sources, and the second one has m power sources. A po...
#include <bits/stdc++.h> using namespace std; const int MAXN = 1e5 + 10; const double eps = 1e-8; const double pi = acos(-1.0); const long long INF = 0x3f3f3f3f3f3f3f3f; int dcmp(double x) { if (fabs(x) < eps) return 0; return (x > 0 ? 1 : -1); } inline double sqr(double x) { return x * x; } struct Point { long l...
### Prompt Please provide a CPP coded solution to the problem described below: After the war, the supersonic rocket became the most common public transportation. Each supersonic rocket consists of two "engines". Each engine is a set of "power sources". The first engine has n power sources, and the second one has m p...
#include <bits/stdc++.h> using namespace std; inline int read() { int x = 0, f = 1; char ch = getchar(); while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); } while (ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); } return x * f; } namespace Mymath { long...
### Prompt In CPP, your task is to solve the following problem: After the war, the supersonic rocket became the most common public transportation. Each supersonic rocket consists of two "engines". Each engine is a set of "power sources". The first engine has n power sources, and the second one has m power sources. A...
#include <bits/stdc++.h> #pragma comment(linker, "/STACK:1024000000,1024000000") using namespace std; const int INF = 2147483647; const int mod = 1000000007; const int mod2 = 998244353; const double eps = 1e-9; const double pi = acos(-1.0); inline int rint() { int x; scanf("%d", &x); return x; } inline long long ...
### Prompt Generate a cpp solution to the following problem: After the war, the supersonic rocket became the most common public transportation. Each supersonic rocket consists of two "engines". Each engine is a set of "power sources". The first engine has n power sources, and the second one has m power sources. A po...
#include <bits/stdc++.h> using namespace std; struct vec { long long first, second; vec() {} vec(long long first, long long second) : first(first), second(second) {} vec operator+(const vec& T) const { return {first + T.first, second + T.second}; } vec operator-(const vec& T) const { return {first -...
### Prompt Your task is to create a cpp solution to the following problem: After the war, the supersonic rocket became the most common public transportation. Each supersonic rocket consists of two "engines". Each engine is a set of "power sources". The first engine has n power sources, and the second one has m power...
#include <bits/stdc++.h> using namespace std; int nr, N, M, pi[200009], ap[200009], st[200009]; long long pat[200009]; vector<long long> v, g, h; long long det(pair<int, int> a, pair<int, int> b, pair<int, int> c) { return 1LL * a.first * b.second + 1LL * b.first * c.second + 1LL * c.first * a.second - 1LL *...
### Prompt Your task is to create a cpp solution to the following problem: After the war, the supersonic rocket became the most common public transportation. Each supersonic rocket consists of two "engines". Each engine is a set of "power sources". The first engine has n power sources, and the second one has m power...
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 10; int n, m; struct point { int x, y; point() {} point(int x, int y) : x(x), y(y) {} point operator-(point a) { return point(x - a.x, y - a.y); } bool operator<(const point& a) const { return x == a.x ? y < a.y : x < a.x; } } a[N], b[N]; long ...
### Prompt Your task is to create a cpp solution to the following problem: After the war, the supersonic rocket became the most common public transportation. Each supersonic rocket consists of two "engines". Each engine is a set of "power sources". The first engine has n power sources, and the second one has m power...
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 1; const int inf = 0x3f3f3f3f; const double pi = acos(-1); int read() { char c = getchar(); int res = 0; while (c < '0' || c > '9') c = getchar(); while (48 <= c && c <= 57) { res = res * 10 + c - '0'; c = getchar(); } return res; } b...
### Prompt Generate a cpp solution to the following problem: After the war, the supersonic rocket became the most common public transportation. Each supersonic rocket consists of two "engines". Each engine is a set of "power sources". The first engine has n power sources, and the second one has m power sources. A po...
#include <bits/stdc++.h> using namespace std; using namespace std; struct pt { long long x, y; }; bool cmp(pt a, pt b) { return a.x < b.x || (a.x == b.x && a.y < b.y); } bool cw(pt a, pt b, pt c) { return a.x * (b.y - c.y) + b.x * (c.y - a.y) + c.x * (a.y - b.y) < 0; } bool ccw(pt a, pt b, pt c) { return a.x * (b...
### Prompt Please provide a Cpp coded solution to the problem described below: After the war, the supersonic rocket became the most common public transportation. Each supersonic rocket consists of two "engines". Each engine is a set of "power sources". The first engine has n power sources, and the second one has m p...
#include <bits/stdc++.h> const int moder = 998244353; int powermod(int a, int exp) { int ret = 1; for (; exp > 0; exp >>= 1) { if (exp & 1) { ret = 1ll * ret * a % moder; } a = 1ll * a * a % moder; } return ret; } struct KMP { int m; std::pair<long long, int> p[(1000010)]; int fail[(1000...
### Prompt Construct a Cpp code solution to the problem outlined: After the war, the supersonic rocket became the most common public transportation. Each supersonic rocket consists of two "engines". Each engine is a set of "power sources". The first engine has n power sources, and the second one has m power sources....
#include <bits/stdc++.h> using namespace std; long long add(long long a, long long b) { return a + b; } struct P { long long x, y; P(long long x = 0, long long y = 0) : x(x), y(y) {} P operator+(const P &b) const { return P(add(x, b.x), add(y, b.y)); } P operator-(const P &b) const { return P(add(x, -b.x), add(...
### Prompt Construct a Cpp code solution to the problem outlined: After the war, the supersonic rocket became the most common public transportation. Each supersonic rocket consists of two "engines". Each engine is a set of "power sources". The first engine has n power sources, and the second one has m power sources....
#include <bits/stdc++.h> using namespace std; struct Point { long long first, second; }; Point p0; Point nextToTop(stack<Point> &S) { Point p = S.top(); S.pop(); Point res = S.top(); S.push(p); return res; } int distSq(Point p1, Point p2) { return (p1.first - p2.first) * (p1.first - p2.first) + (...
### Prompt Develop a solution in cpp to the problem described below: After the war, the supersonic rocket became the most common public transportation. Each supersonic rocket consists of two "engines". Each engine is a set of "power sources". The first engine has n power sources, and the second one has m power sourc...
#include <bits/stdc++.h> using namespace std; struct point { long long x, y; point(long long x = 0, long long y = 0) : x(x), y(y) {} point operator+(point p) { return point(x + p.x, y + p.y); } point operator-(point p) { return point(x - p.x, y - p.y); } point operator*(long long k) { return point(x * k, y * ...
### Prompt Generate a CPP solution to the following problem: After the war, the supersonic rocket became the most common public transportation. Each supersonic rocket consists of two "engines". Each engine is a set of "power sources". The first engine has n power sources, and the second one has m power sources. A po...
#include <bits/stdc++.h> const long double eps = 1e-9; const long double pi = acos(-1.0); struct vec { long double x, y; vec operator+(const vec &k) const { return {x + k.x, y + k.y}; } vec operator-(const vec &k) const { return {x - k.x, y - k.y}; } vec operator*(const long double &k) const { return {x * k, y ...
### Prompt Your challenge is to write a CPP solution to the following problem: After the war, the supersonic rocket became the most common public transportation. Each supersonic rocket consists of two "engines". Each engine is a set of "power sources". The first engine has n power sources, and the second one has m p...
#include <bits/stdc++.h> using namespace std; inline int read() { int X = 0, w = 1; char ch = 0; while (ch < '0' || ch > '9') { if (ch == '-') w = -1; ch = getchar(); } while (ch >= '0' && ch <= '9') X = (X << 3) + (X << 1) + ch - '0', ch = getchar(); return X * w; } struct poi { double x, y; ...
### Prompt Your task is to create a Cpp solution to the following problem: After the war, the supersonic rocket became the most common public transportation. Each supersonic rocket consists of two "engines". Each engine is a set of "power sources". The first engine has n power sources, and the second one has m power...
#include <bits/stdc++.h> using namespace std; vector<string> split(const string& s, char c) { vector<string> v; stringstream ss(s); string x; while (getline(ss, x, c)) v.emplace_back(x); return move(v); } void err(vector<string>::iterator it) {} template <typename T, typename... Args> void err(vector<string>:...
### Prompt Construct a CPP code solution to the problem outlined: After the war, the supersonic rocket became the most common public transportation. Each supersonic rocket consists of two "engines". Each engine is a set of "power sources". The first engine has n power sources, and the second one has m power sources....
#include <bits/stdc++.h> int sig(long long p) { return (p > 0) - (p < 0); } class P { public: long long x, y; P(long long x = 0, long long y = 0) : x(x), y(y) {} P operator-(const P &p) const { return P(x - p.x, y - p.y); } long long operator^(const P &p) const { return x * p.y - y * p.x; } long long operato...
### Prompt Please provide a Cpp coded solution to the problem described below: After the war, the supersonic rocket became the most common public transportation. Each supersonic rocket consists of two "engines". Each engine is a set of "power sources". The first engine has n power sources, and the second one has m p...
#include <bits/stdc++.h> using namespace std; const double EPS = 1e-10; bool dcmp(double x, double y = 0) { return fabs(x - y) <= EPS; } double add(double a, double b) { if (abs(a + b) < EPS * (abs(a) + abs(b))) return 0; return a + b; } struct P { double x, y; P() {} P(double x, double y) : x(x), y(y) {} P...
### Prompt Please create a solution in Cpp to the following problem: After the war, the supersonic rocket became the most common public transportation. Each supersonic rocket consists of two "engines". Each engine is a set of "power sources". The first engine has n power sources, and the second one has m power sourc...
#include <bits/stdc++.h> using namespace std; template <typename T> using maxHeap = priority_queue<T, vector<T>, less<T>>; template <typename T> using minHeap = priority_queue<T, vector<T>, greater<T>>; template <typename Iter> ostream& _out(ostream& s, Iter b, Iter e) { s << "["; for (auto it = b; it != e; it++) s...
### Prompt Please create a solution in CPP to the following problem: After the war, the supersonic rocket became the most common public transportation. Each supersonic rocket consists of two "engines". Each engine is a set of "power sources". The first engine has n power sources, and the second one has m power sourc...
#include <bits/stdc++.h> using namespace std; template <typename T> using maxHeap = priority_queue<T, vector<T>, less<T>>; template <typename T> using minHeap = priority_queue<T, vector<T>, greater<T>>; template <typename Iter> ostream& _out(ostream& s, Iter b, Iter e) { s << "["; for (auto it = b; it != e; it++) s...
### Prompt Generate a Cpp solution to the following problem: After the war, the supersonic rocket became the most common public transportation. Each supersonic rocket consists of two "engines". Each engine is a set of "power sources". The first engine has n power sources, and the second one has m power sources. A po...
#include <bits/stdc++.h> using namespace std; struct vec { long long first, second; vec() {} vec(long long first, long long second) : first(first), second(second) {} vec operator+(const vec& T) const { return {first + T.first, second + T.second}; } vec operator-(const vec& T) const { return {first -...
### Prompt Please provide a cpp coded solution to the problem described below: After the war, the supersonic rocket became the most common public transportation. Each supersonic rocket consists of two "engines". Each engine is a set of "power sources". The first engine has n power sources, and the second one has m p...
#include <bits/stdc++.h> using namespace std; const int INF = 0x3f3f3f3f; const double EPS = 1e-9; inline int cmp(double x, double y = 0, double tol = EPS) { return ((x <= y + tol) ? (x + tol < y) ? -1 : 0 : 1); } struct point { long long x, y; point(long long x = 0, long long y = 0) : x(x), y(y) {} point opera...
### Prompt Your task is to create a cpp solution to the following problem: After the war, the supersonic rocket became the most common public transportation. Each supersonic rocket consists of two "engines". Each engine is a set of "power sources". The first engine has n power sources, and the second one has m power...
#include <bits/stdc++.h> using namespace std; struct Point { long long x, y; Point(long long x = 0, long long y = 0) : x(x), y(y) {} void input() { scanf("%I64d%I64d", &x, &y); } bool operator<(const Point& R) const { if (x == R.x) return y < R.y; else return x < R.x; } Point operator-(c...
### Prompt Your challenge is to write a cpp solution to the following problem: After the war, the supersonic rocket became the most common public transportation. Each supersonic rocket consists of two "engines". Each engine is a set of "power sources". The first engine has n power sources, and the second one has m p...
#include <bits/stdc++.h> #pragma comment(linker, "/STACK:512000000") using namespace std; using li = long long; using ld = long double; void solve(bool); void precalc(); clock_t start; int main() { start = clock(); int t = 1; cout.sync_with_stdio(0); cin.tie(0); cout.precision(20); cout << fixed; precalc(...
### Prompt Create a solution in CPP for the following problem: After the war, the supersonic rocket became the most common public transportation. Each supersonic rocket consists of two "engines". Each engine is a set of "power sources". The first engine has n power sources, and the second one has m power sources. A ...
#include <bits/stdc++.h> using namespace std; const double EPS = 1e-6; struct point { double x, y; point() {} point(double x, double y) : x(x), y(y) {} }; point operator-(point a, point b) { return point(a.x - b.x, a.y - b.y); } int dcmp(double x) { return fabs(x) < EPS ? 0 : (x > 0 ? 1 : -1); } double Cross(poin...
### Prompt Develop a solution in Cpp to the problem described below: After the war, the supersonic rocket became the most common public transportation. Each supersonic rocket consists of two "engines". Each engine is a set of "power sources". The first engine has n power sources, and the second one has m power sourc...