output
stringlengths
52
181k
instruction
stringlengths
296
182k
#include<bits/stdc++.h> using namespace std; int h,m;//一天h小时,1小时m分钟 int rref[10]={0,1,5,-1,-1,2,-1,-1,8,-1}; //下标是原数字,值是镜面反射后的结果 //-1表示反射后不是一个数字 bool check(int hh,int mm)//判断反射是否合法 { int cnt=0; int tmp_h=0;//反射后的小时 while(mm)//反射之后,原分钟作为小时 { if(rref[mm%10]==-1)//反射后不是一个数字 return 0; tmp_h=tmp_h*10+rref[mm...
### Prompt Construct a cpp code solution to the problem outlined: The time on the planet Lapituletti goes the same way it goes on Earth but a day lasts h hours and each hour lasts m minutes. The inhabitants of that planet use digital clocks similar to earth ones. Clocks display time in a format HH:MM (the number of h...
#include<bits/stdc++.h> using namespace std; #define boost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); typedef long long int ll; int A[]={0,1,5,-1,-1,2,-1,-1,8,-1}; bool judge(int H, int M, int h, int m) { if(A[h%10]==-1 || A[h/10]==-1 || A[m%10]==-1 ||...
### Prompt Develop a solution in Cpp to the problem described below: The time on the planet Lapituletti goes the same way it goes on Earth but a day lasts h hours and each hour lasts m minutes. The inhabitants of that planet use digital clocks similar to earth ones. Clocks display time in a format HH:MM (the number o...
#include <bits/stdc++.h> using namespace std; const int N = 1e7 + 5, K = 20, W = 1 << K; int n, q, tot; int ls[N], rs[N], sum[N], or0[N], or1[N], tag[N], dep[N]; void pushup(int p) { sum[p] = sum[ls[p]] + sum[rs[p]]; or0[p] = or0[ls[p]] | or0[rs[p]]; or1[p] = or1[ls[p]] | or1[rs[p]]; } void Tag(int p, int k) ...
### Prompt Your task is to create a CPP solution to the following problem: Phoenix loves playing with bits — specifically, by using the bitwise operations AND, OR, and XOR. He has n integers a_1, a_2, ..., a_n, and will perform q of the following queries: 1. replace all numbers a_i where l ≤ a_i ≤ r with a_i AND x...
#include <bits/stdc++.h> const int N = 5e6 + 5, K = 20, M = 1 << K; int n, q, tot, ls[N], rs[N], tk[N], t0[N], t1[N], ts[N], tt[N]; inline void pushup(int p) { ts[p] = ts[ls[p]] + ts[rs[p]]; t0[p] = t0[ls[p]] | t0[rs[p]]; t1[p] = t1[ls[p]] | t1[rs[p]]; } inline void tag(int p, int t) { if (!p) return; tt[p] ^=...
### Prompt Generate a Cpp solution to the following problem: Phoenix loves playing with bits — specifically, by using the bitwise operations AND, OR, and XOR. He has n integers a_1, a_2, ..., a_n, and will perform q of the following queries: 1. replace all numbers a_i where l ≤ a_i ≤ r with a_i AND x; 2. replac...
#include<bits/stdc++.h> using namespace std; const int N=1e7+7,B=(1<<20)-1; bool fl[N]; int op,l,r,x; int n,m,ql,qr,rt,ans,A,q[N],fa[N],s1[N],s2[N],ch[N][2],dep[N],f1[N],f2[N],f3[N],qt[N],qc[N]; inline bool get(int u){ return (ch[fa[u]][1]==u); } inline void upd(int u){ if(dep[u]==-1) return; if(!ch[u][1]) f1[u]=f1[...
### Prompt Please formulate a Cpp solution to the following problem: Phoenix loves playing with bits — specifically, by using the bitwise operations AND, OR, and XOR. He has n integers a_1, a_2, ..., a_n, and will perform q of the following queries: 1. replace all numbers a_i where l ≤ a_i ≤ r with a_i AND x; 2...
#include <bits/stdc++.h> const int N = 200005, M = 1 << 20; int n, Q, rt = 0; int lc[N * 50], rc[N * 50], tagx[N * 50], tagl[N * 50], tagr[N * 50], sum[N * 50], tot = 0; void up(int o) { tagl[o] = tagl[lc[o]] | tagl[rc[o]]; tagr[o] = tagr[lc[o]] | tagr[rc[o]]; sum[o] = sum[lc[o]] + sum[rc[o]]; } void pushx(int o, in...
### Prompt Construct a Cpp code solution to the problem outlined: Phoenix loves playing with bits — specifically, by using the bitwise operations AND, OR, and XOR. He has n integers a_1, a_2, ..., a_n, and will perform q of the following queries: 1. replace all numbers a_i where l ≤ a_i ≤ r with a_i AND x; 2. r...
#include<iostream> #include<cstdio> #include<algorithm> #include<set> #include<vector> #include<ctime> #include<cstring> #include<map> #include<queue> #define mp make_pair #define PII pair<int,int> #define fi first #define se second #define pb push_back using namespace std; inline int read(){ int x=0,f=1; char c=getc...
### Prompt Your task is to create a Cpp solution to the following problem: Phoenix loves playing with bits — specifically, by using the bitwise operations AND, OR, and XOR. He has n integers a_1, a_2, ..., a_n, and will perform q of the following queries: 1. replace all numbers a_i where l ≤ a_i ≤ r with a_i AND x...
#include <bits/stdc++.h> using namespace std; #define rep(i, a, b) for(int i = a; i < (b); ++i) #define all(x) begin(x), end(x) #define sz(x) (int)(x).size() #define debug(...) //ignore typedef long long ll; typedef pair<int, int> pii; typedef vector<int> vi; typedef long double ld; const int LEV = 22; int BIT(int x...
### Prompt Your task is to create a CPP solution to the following problem: Phoenix loves playing with bits — specifically, by using the bitwise operations AND, OR, and XOR. He has n integers a_1, a_2, ..., a_n, and will perform q of the following queries: 1. replace all numbers a_i where l ≤ a_i ≤ r with a_i AND x...
#include<bits/stdc++.h> template <typename _Tp>void read(_Tp &x){ char ch(getchar());bool f(false);while(!isdigit(ch))f|=ch==45,ch=getchar(); x=ch&15,ch=getchar();while(isdigit(ch))x=x*10+(ch&15),ch=getchar(); if(f)x=-x; } template <typename _Tp,typename... Args>void read(_Tp &t,Args &...args){read(t);read(args...);...
### Prompt Please create a solution in Cpp to the following problem: Phoenix loves playing with bits — specifically, by using the bitwise operations AND, OR, and XOR. He has n integers a_1, a_2, ..., a_n, and will perform q of the following queries: 1. replace all numbers a_i where l ≤ a_i ≤ r with a_i AND x; 2...
//Original Code: //#include <self/utility> //#include <self/debug> //using namespace std; //const int U=(1<<20)-1; //int n,q; //int inv[(1<<20)]; // //struct Node //{ // Node *l=0,*r=0; // int sz; // int ed; // int swp=0; // int hasl=0,hasr=0; // Node(int _v):sz(_v),ed(_v){} // void pushup() // { // sz=(l?l->sz:0)+(r?...
### Prompt Please create a solution in cpp to the following problem: Phoenix loves playing with bits — specifically, by using the bitwise operations AND, OR, and XOR. He has n integers a_1, a_2, ..., a_n, and will perform q of the following queries: 1. replace all numbers a_i where l ≤ a_i ≤ r with a_i AND x; 2...
/* author: Maksim1744 created: 06.05.2021 16:01:27 */ #include "bits/stdc++.h" using namespace std; using ll = long long; using ld = long double; #define mp make_pair #define pb push_back #define eb emplace_back #define sum(a) ( accumulate ((a).begin(), (a).end(), 0ll)) #define mine(a) (*min_...
### Prompt In Cpp, your task is to solve the following problem: Phoenix loves playing with bits — specifically, by using the bitwise operations AND, OR, and XOR. He has n integers a_1, a_2, ..., a_n, and will perform q of the following queries: 1. replace all numbers a_i where l ≤ a_i ≤ r with a_i AND x; 2. rep...
#include <bits/stdc++.h> using namespace std; using ll = long long; using uint = unsigned int; template<int H> struct MergeTree { array<MergeTree<H-1>*, 2> ch; array<int, H+1> branch_cou; // (01 -> no change), (00 -> set 0), (11 -> set 1), (10 -> flip) uint s0 = 0, s1 = -1; uint size = 0; MergeTree() : branch_...
### Prompt Please provide a Cpp coded solution to the problem described below: Phoenix loves playing with bits — specifically, by using the bitwise operations AND, OR, and XOR. He has n integers a_1, a_2, ..., a_n, and will perform q of the following queries: 1. replace all numbers a_i where l ≤ a_i ≤ r with a_i A...
#include <bits/stdc++.h> using namespace std; const int maxlog=19; const int maxnode=(1<<21)+((maxlog+5)<<1); int rt,tag[maxnode][2],frk[maxnode],ch[maxnode][2],sz[maxnode],sta[maxnode],top,tot; // 0000->tag[0] 1111->tag[1] frk:can merge // time complexity: potetion:#nodes, ~delta*log inline int newnode() { return ((to...
### Prompt Please provide a Cpp coded solution to the problem described below: Phoenix loves playing with bits — specifically, by using the bitwise operations AND, OR, and XOR. He has n integers a_1, a_2, ..., a_n, and will perform q of the following queries: 1. replace all numbers a_i where l ≤ a_i ≤ r with a_i A...
#include<bits/stdc++.h> using namespace std; const int N=1234568,B=(1<<20)-1; bool fl[N]; int op,l,r,x; int n,m,ql,qr,rt,ans,A,q[N],fa[N],s1[N],s2[N],ch[N][2],dep[N],f1[N],f2[N],f3[N],qt[N],qc[N]; inline bool get(int u){ return (ch[fa[u]][1]==u); } inline void upd(int u){ if(dep[u]==-1) return; if(!ch[u][1]) f1[u]=f...
### Prompt Please create a solution in cpp to the following problem: Phoenix loves playing with bits — specifically, by using the bitwise operations AND, OR, and XOR. He has n integers a_1, a_2, ..., a_n, and will perform q of the following queries: 1. replace all numbers a_i where l ≤ a_i ≤ r with a_i AND x; 2...
/* author: Maksim1744 created: 06.05.2021 16:01:27 */ #include "bits/stdc++.h" using namespace std; using ll = long long; using ld = long double; #define mp make_pair #define pb push_back #define eb emplace_back #define sum(a) ( accumulate ((a).begin(), (a).end(), 0ll)) #define mine(a) (*min_...
### Prompt Please create a solution in CPP to the following problem: Phoenix loves playing with bits — specifically, by using the bitwise operations AND, OR, and XOR. He has n integers a_1, a_2, ..., a_n, and will perform q of the following queries: 1. replace all numbers a_i where l ≤ a_i ≤ r with a_i AND x; 2...
#include<bits/stdc++.h> using namespace std; const int M = 4000003, all = (1<<20)-1; template<typename T> void read(T &x){ int ch = getchar(); x = 0; bool f = false; for(;ch < '0' || ch > '9';ch = getchar()) f |= ch == '-'; for(;ch >= '0' && ch <= '9';ch = getchar()) x = x * 10 + ch - '0'; if(f) x = -x; } int n, q,...
### Prompt Please formulate a cpp solution to the following problem: Phoenix loves playing with bits — specifically, by using the bitwise operations AND, OR, and XOR. He has n integers a_1, a_2, ..., a_n, and will perform q of the following queries: 1. replace all numbers a_i where l ≤ a_i ≤ r with a_i AND x; 2...
#include <cstdio> #include <iostream> using namespace std; const int M = 10000005; int read() { int x=0,f=1;char c; while((c=getchar())<'0' || c>'9') {if(c=='-') f=-1;} while(c>='0' && c<='9') {x=(x<<3)+(x<<1)+(c^48);c=getchar();} return x*f; } int n,k,q,rt,cnt,now,ls[M],rs[M],res[M],la[M],v[M],vk[M]; void up(int x...
### Prompt Please formulate a cpp solution to the following problem: Phoenix loves playing with bits — specifically, by using the bitwise operations AND, OR, and XOR. He has n integers a_1, a_2, ..., a_n, and will perform q of the following queries: 1. replace all numbers a_i where l ≤ a_i ≤ r with a_i AND x; 2...
/* author: Maksim1744 created: 06.05.2021 16:01:27 */ #include "bits/stdc++.h" using namespace std; using ll = long long; using ld = long double; #define mp make_pair #define pb push_back #define eb emplace_back #define sum(a) ( accumulate ((a).begin(), (a).end(), 0ll)) #define mine(a) (*min_...
### Prompt In Cpp, your task is to solve the following problem: Phoenix loves playing with bits — specifically, by using the bitwise operations AND, OR, and XOR. He has n integers a_1, a_2, ..., a_n, and will perform q of the following queries: 1. replace all numbers a_i where l ≤ a_i ≤ r with a_i AND x; 2. rep...
#include<stdio.h> const int maxn=200005,maxk=maxn*50; int n,q,k,rt,cnt; int lc[maxk],rc[maxk],lazy[maxk],Vand[maxk],Vor[maxk],res[maxk]; inline void swp(int &a,int &b){ a+=b,b=a-b,a-=b; } inline void pushup(int now){ Vand[now]=Vand[lc[now]]|Vand[rc[now]]; Vor[now]=Vor[lc[now]]|Vor[rc[now]]; res[now]=res[lc[now]]+re...
### Prompt Construct a Cpp code solution to the problem outlined: Phoenix loves playing with bits — specifically, by using the bitwise operations AND, OR, and XOR. He has n integers a_1, a_2, ..., a_n, and will perform q of the following queries: 1. replace all numbers a_i where l ≤ a_i ≤ r with a_i AND x; 2. r...
#include<bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int,int> PII; const int maxn=4444444,mod=998244353,A1=(1<<20)-1; #define MP make_pair #define PB push_back #define lson o<<1,l,mid #define rson o<<1|1,mid+1,r #define FOR(i,a,b) for(int i=(a);i<=(b);i++) #define ROF(i,a,b) for(int i=(a);i>=...
### Prompt Develop a solution in CPP to the problem described below: Phoenix loves playing with bits — specifically, by using the bitwise operations AND, OR, and XOR. He has n integers a_1, a_2, ..., a_n, and will perform q of the following queries: 1. replace all numbers a_i where l ≤ a_i ≤ r with a_i AND x; 2...
#include <bits/stdc++.h> using namespace std; constexpr int LV = 20, M = (1 << LV) - 1; int n, q; struct D { D* c[2] = {nullptr, nullptr}; // bx: bits that differ, by: not in bx, the same bit int bx = 0, by = 0, num = 0, lz = 0; void down(int lv) { if (lv < 0) return; if (lz >> lv & ...
### Prompt Please provide a CPP coded solution to the problem described below: Phoenix loves playing with bits — specifically, by using the bitwise operations AND, OR, and XOR. He has n integers a_1, a_2, ..., a_n, and will perform q of the following queries: 1. replace all numbers a_i where l ≤ a_i ≤ r with a_i A...
#include <bits/stdc++.h> using namespace std; template<class t> inline t read(t &x){ char c=getchar();bool f=0;x=0; while(!isdigit(c)) f|=c=='-',c=getchar(); while(isdigit(c)) x=(x<<1)+(x<<3)+(c^48),c=getchar(); if(f) x=-x;return x; } template<class t> inline void write(t x){ if(x<0) putchar('-'),wr...
### Prompt Please create a solution in Cpp to the following problem: Phoenix loves playing with bits — specifically, by using the bitwise operations AND, OR, and XOR. He has n integers a_1, a_2, ..., a_n, and will perform q of the following queries: 1. replace all numbers a_i where l ≤ a_i ≤ r with a_i AND x; 2...
#include <bits/stdc++.h> #define rep(i, a, b) for (int i = a; i <= b; i++) #define per(i, a, b) for (int i = a; i >= b; i--) using namespace std; typedef unsigned long long ull; typedef pair <int, int> pii; typedef long long ll; template <typename T> inline void read(T &f) { f = 0; T fu = 1; char c = getchar();...
### Prompt Create a solution in cpp for the following problem: Phoenix loves playing with bits — specifically, by using the bitwise operations AND, OR, and XOR. He has n integers a_1, a_2, ..., a_n, and will perform q of the following queries: 1. replace all numbers a_i where l ≤ a_i ≤ r with a_i AND x; 2. repl...
#include <bits/stdc++.h> using namespace std; using ll = long long; int MOD; struct modint { private: int v; static int minv(int a, int m) { a %= m; assert(a); return a == 1 ? 1 : int(m - ll(minv(m, a)) * ll(m) / a); } public: modint() : v(0) {} modint(ll v_) : v(int(v_...
### Prompt In cpp, your task is to solve the following problem: Phoenix loves playing with bits — specifically, by using the bitwise operations AND, OR, and XOR. He has n integers a_1, a_2, ..., a_n, and will perform q of the following queries: 1. replace all numbers a_i where l ≤ a_i ≤ r with a_i AND x; 2. rep...
#include<bits/stdc++.h> using namespace std; const int N=200005,f=(1<<20)-1; int n,q,u,m,lc[N<<6],rc[N<<6],tr[N<<6],t0[N<<6],t1[N<<6],t[N<<6]; void pt(int u,int p,int x) { if(!u) return; if(x>>(p-1)&1) swap(lc[u],rc[u]); int v0=(t0[u]&(~x))|(t1[u]&x),v1=(t1[u]&(~x))|(t0[u]&x); t0[u]=v0,t1[u]=v1,t[u]^=x; } void ...
### Prompt In cpp, your task is to solve the following problem: Phoenix loves playing with bits — specifically, by using the bitwise operations AND, OR, and XOR. He has n integers a_1, a_2, ..., a_n, and will perform q of the following queries: 1. replace all numbers a_i where l ≤ a_i ≤ r with a_i AND x; 2. rep...
/* author: Maksim1744 created: 06.05.2021 16:01:27 */ #include "bits/stdc++.h" using namespace std; using ll = long long; using ld = long double; #define mp make_pair #define pb push_back #define eb emplace_back #define sum(a) ( accumulate ((a).begin(), (a).end(), 0ll)) #define mine(a) (*min_...
### Prompt Develop a solution in Cpp to the problem described below: Phoenix loves playing with bits — specifically, by using the bitwise operations AND, OR, and XOR. He has n integers a_1, a_2, ..., a_n, and will perform q of the following queries: 1. replace all numbers a_i where l ≤ a_i ≤ r with a_i AND x; 2...
#include <bits/stdc++.h> const int LG = 20, U = (1 << LG) - 1; struct Node { int all0, all1; int sz; Node() : all0(U), all1(U), sz(0) {} Node(int a0, int a1, int _sz) : all0(a0), all1(a1), sz(_sz) {} }; Node operator+(const Node &a, const Node &b) { return Node(a.all0 & b.all0, a.all1 & b.all1, a.sz + b.sz); }...
### Prompt Create a solution in Cpp for the following problem: Phoenix loves playing with bits — specifically, by using the bitwise operations AND, OR, and XOR. He has n integers a_1, a_2, ..., a_n, and will perform q of the following queries: 1. replace all numbers a_i where l ≤ a_i ≤ r with a_i AND x; 2. repl...
#include<stdio.h> const int maxn=200005,maxk=maxn*40; int n,q,k,rt,cnt; int lc[maxk],rc[maxk],lazy[maxk],Vand[maxk],Vor[maxk],res[maxk]; inline void swp(int &a,int &b){ a+=b,b=a-b,a-=b; } inline void pushup(int now){ Vand[now]=Vand[lc[now]]|Vand[rc[now]]; Vor[now]=Vor[lc[now]]|Vor[rc[now]]; res[now]=res[lc[now]]+re...
### Prompt Develop a solution in CPP to the problem described below: Phoenix loves playing with bits — specifically, by using the bitwise operations AND, OR, and XOR. He has n integers a_1, a_2, ..., a_n, and will perform q of the following queries: 1. replace all numbers a_i where l ≤ a_i ≤ r with a_i AND x; 2...
#include<bits/stdc++.h> #define lson ls[x],l,mid #define rson rs[x],mid+1,r using namespace std;const int N=2e5+7,M=N*50; int rt,rt1,x,n,m,i,j,l,r,t,tk[M],ls[M],rs[M],ts[M],ts0[M],ts1[M],U,tag[M],sz; void ud(int x){ts[x]=ts[ls[x]]+ts[rs[x]];ts0[x]=ts0[ls[x]]|ts0[rs[x]];ts1[x]=ts1[ls[x]]|ts1[rs[x]];} int newnode(int k){...
### Prompt In Cpp, your task is to solve the following problem: Phoenix loves playing with bits — specifically, by using the bitwise operations AND, OR, and XOR. He has n integers a_1, a_2, ..., a_n, and will perform q of the following queries: 1. replace all numbers a_i where l ≤ a_i ≤ r with a_i AND x; 2. rep...
#include<bits/stdc++.h> using namespace std; #define ll long long const int maxn = 200005; const int maxd = 19; const int S = (1 << (maxd + 1)) - 1; const int maxp = 10000005; int ch[maxp][2], sz[maxp], sta[maxp][2]; inline void pushup(int x) { sz[x] = sz[ch[x][0]] + sz[ch[x][1]]; for(int i = 0; i <= 1; i++) sta[x]...
### Prompt Please create a solution in CPP to the following problem: Phoenix loves playing with bits — specifically, by using the bitwise operations AND, OR, and XOR. He has n integers a_1, a_2, ..., a_n, and will perform q of the following queries: 1. replace all numbers a_i where l ≤ a_i ≤ r with a_i AND x; 2...
#include<bits/stdc++.h> using namespace std; const int maxb=20; const int maxs=1<<maxb; int n,q,tot,top,rt; int st[maxs<<1],ls[maxs<<1],rs[maxs<<1],tag0[maxs<<1],tag1[maxs<<1],tagx[maxs<<1],sdep[maxs<<1],cnt[maxs<<1]; vector<pair<pair<int,int>,int> >todo; void apply0(int cur,int mask){ tag1[cur]&=~mask; tagx[cur]&=...
### Prompt Your challenge is to write a Cpp solution to the following problem: Phoenix loves playing with bits — specifically, by using the bitwise operations AND, OR, and XOR. He has n integers a_1, a_2, ..., a_n, and will perform q of the following queries: 1. replace all numbers a_i where l ≤ a_i ≤ r with a_i A...
#include<bits/stdc++.h> using namespace std; # define ll long long # define read read1<ll>() # define Type template<typename T> Type T read1(){ T t=0; char k; bool vis=0; do (k=getchar())=='-'&&(vis=1);while('0'>k||k>'9'); while('0'<=k&&k<='9')t=(t<<3)+(t<<1)+(k^'0'),k=getchar(); return vis?-t:t; } # define fre(k...
### Prompt Construct a CPP code solution to the problem outlined: Phoenix loves playing with bits — specifically, by using the bitwise operations AND, OR, and XOR. He has n integers a_1, a_2, ..., a_n, and will perform q of the following queries: 1. replace all numbers a_i where l ≤ a_i ≤ r with a_i AND x; 2. r...
#include <bits/stdc++.h> using namespace std; using ll = long long; int MOD; struct modint { private: int v; static int minv(int a, int m) { a %= m; assert(a); return a == 1 ? 1 : int(m - ll(minv(m, a)) * ll(m) / a); } public: modint() : v(0) {} modint(ll v_) : v(int(v_...
### Prompt Construct a CPP code solution to the problem outlined: Phoenix loves playing with bits — specifically, by using the bitwise operations AND, OR, and XOR. He has n integers a_1, a_2, ..., a_n, and will perform q of the following queries: 1. replace all numbers a_i where l ≤ a_i ≤ r with a_i AND x; 2. r...
#include <stdio.h> #include <stdlib.h> #define N 200000 #define Q 100000 #define N_ ((N + Q * 2) * (LG + 1)) #define LG 20 #define B (1 << LG) int ll[1 + N_], rr[1 + N_], sz[1 + N_], msk0[1 + N_], msk1[1 + N_], lz[1 + N_], _ = 1; void put(int u, int lg, int x) {int tmp, x0, x1;if (u == 0)return;if ((x & 1 << lg - 1) !=...
### Prompt Construct a cpp code solution to the problem outlined: Phoenix loves playing with bits — specifically, by using the bitwise operations AND, OR, and XOR. He has n integers a_1, a_2, ..., a_n, and will perform q of the following queries: 1. replace all numbers a_i where l ≤ a_i ≤ r with a_i AND x; 2. r...
/* https://codeforces.com/blog/entry/90236 (segment tree beats) */ #include <stdio.h> #include <stdlib.h> #define N 200000 #define Q 100000 #define N_ ((N + Q * 2) * (LG + 1)) #define LG 20 #define B (1 << LG) int ll[1 + N_], rr[1 + N_], sz[1 + N_], msk0[1 + N_], msk1[1 + N_], lz[1 + N_], _ = 1; void put(int u, int ...
### Prompt In cpp, your task is to solve the following problem: Phoenix loves playing with bits — specifically, by using the bitwise operations AND, OR, and XOR. He has n integers a_1, a_2, ..., a_n, and will perform q of the following queries: 1. replace all numbers a_i where l ≤ a_i ≤ r with a_i AND x; 2. rep...
#include<stdio.h> const int maxn=200005,maxk=maxn*50; int n,q,k,rt,cnt; int lc[maxk],rc[maxk],lazy[maxk],Vand[maxk],Vor[maxk],res[maxk]; inline void swp(int &a,int &b){ a+=b,b=a-b,a-=b; } inline void pushup(int now){ Vand[now]=Vand[lc[now]]|Vand[rc[now]]; Vor[now]=Vor[lc[now]]|Vor[rc[now]]; res[now]=res[lc[now]]+re...
### Prompt Generate a cpp solution to the following problem: Phoenix loves playing with bits — specifically, by using the bitwise operations AND, OR, and XOR. He has n integers a_1, a_2, ..., a_n, and will perform q of the following queries: 1. replace all numbers a_i where l ≤ a_i ≤ r with a_i AND x; 2. replac...
#include <bits/stdc++.h> using namespace std; const int B=20; int n,q,rt=1,cnt=1; int t0[15000000],t1[15000000],sz[15000000],s[2][15000000],lz[15000000]; void pushup(int id,int d){ sz[id]=sz[s[0][id]]+sz[s[1][id]]; t0[id]=t0[s[0][id]]|t0[s[1][id]]; t1[id]=t1[s[0][id]]|t1[s[1][id]]; if(s[0][id])t0[id]|=(1<<d); if(s...
### Prompt Construct a cpp code solution to the problem outlined: Phoenix loves playing with bits — specifically, by using the bitwise operations AND, OR, and XOR. He has n integers a_1, a_2, ..., a_n, and will perform q of the following queries: 1. replace all numbers a_i where l ≤ a_i ≤ r with a_i AND x; 2. r...
#include<bits/stdc++.h> #define ll long long #define N 200015 #define rep(i,a,n) for (int i=a;i<=n;i++) #define per(i,a,n) for (int i=n;i>=a;i--) #define inf 0x3f3f3f3f #define pb push_back #define mp make_pair #define pii pair<int,int> #define fi first #define se second #define lowbit(i) ((i)&(-i)) #define VI vector<i...
### Prompt Your challenge is to write a CPP solution to the following problem: Phoenix loves playing with bits — specifically, by using the bitwise operations AND, OR, and XOR. He has n integers a_1, a_2, ..., a_n, and will perform q of the following queries: 1. replace all numbers a_i where l ≤ a_i ≤ r with a_i A...
#include <cstdio> #include <cassert> #include <utility> #include <functional> //numbers up to 2^MAXLOGX-1 const int MAXLOGX=20; template<int k> struct Trie{ Trie<k-1>* chd[2]; int cnt; int lazy; int has[2]; int get_cnt(){ assert(this!=NULL); return cnt; } int get_has(int d){ assert(this!=NUL...
### Prompt Your challenge is to write a Cpp solution to the following problem: Phoenix loves playing with bits — specifically, by using the bitwise operations AND, OR, and XOR. He has n integers a_1, a_2, ..., a_n, and will perform q of the following queries: 1. replace all numbers a_i where l ≤ a_i ≤ r with a_i A...
//因为,已经我不想写代码了啊 #include<stdio.h> const int maxn=200005,maxk=maxn*40; int n,q,k,rt,cnt; int lc[maxk],rc[maxk],lazy[maxk],Vand[maxk],Vor[maxk],res[maxk]; inline void swp(int &a,int &b){ a+=b,b=a-b,a-=b; } inline void pushup(int now){ Vand[now]=Vand[lc[now]]|Vand[rc[now]]; Vor[now]=Vor[lc[now]]|Vor[rc[now]]; res[now]...
### Prompt Your challenge is to write a cpp solution to the following problem: Phoenix loves playing with bits — specifically, by using the bitwise operations AND, OR, and XOR. He has n integers a_1, a_2, ..., a_n, and will perform q of the following queries: 1. replace all numbers a_i where l ≤ a_i ≤ r with a_i A...
#include<stdio.h> const int maxn=200005,maxk=maxn*40; int n,q,k,rt,cnt; int lc[maxk],rc[maxk],lazy[maxk],Vand[maxk],Vor[maxk],res[maxk]; inline void swp(int &a,int &b){ a+=b,b=a-b,a-=b; } inline void pushup(int now){ Vand[now]=Vand[lc[now]]|Vand[rc[now]]; Vor[now]=Vor[lc[now]]|Vor[rc[now]]; res[now]=res[lc[now]]+re...
### Prompt Generate a CPP solution to the following problem: Phoenix loves playing with bits — specifically, by using the bitwise operations AND, OR, and XOR. He has n integers a_1, a_2, ..., a_n, and will perform q of the following queries: 1. replace all numbers a_i where l ≤ a_i ≤ r with a_i AND x; 2. replac...
#include<bits/stdc++.h> using namespace std; const int M = 2111111, all = (1<<20)-1; template<typename T> void read(T &x){ int ch = getchar(); x = 0; bool f = false; for(;ch < '0' || ch > '9';ch = getchar()) f |= ch == '-'; for(;ch >= '0' && ch <= '9';ch = getchar()) x = x * 10 + ch - '0'; if(f) x = -x; } int n, q,...
### Prompt Please create a solution in cpp to the following problem: Phoenix loves playing with bits — specifically, by using the bitwise operations AND, OR, and XOR. He has n integers a_1, a_2, ..., a_n, and will perform q of the following queries: 1. replace all numbers a_i where l ≤ a_i ≤ r with a_i AND x; 2...
#include <bits/stdc++.h> using namespace std; struct Node { int cnt; int type; int tag; int both; int d; Node *lc, *rc; }; Node *null = new Node(); Node *newNode(int d) { Node *t = new Node(); *t = *null; t->d = d; return t; } Node *merge(Node *, Node *); void maintain(Node *); void pull(Node *t) { if (t->d ...
### Prompt Your task is to create a Cpp solution to the following problem: Phoenix loves playing with bits — specifically, by using the bitwise operations AND, OR, and XOR. He has n integers a_1, a_2, ..., a_n, and will perform q of the following queries: 1. replace all numbers a_i where l ≤ a_i ≤ r with a_i AND x...
#include <bits/stdc++.h> using namespace std; const int N = 1e7 + 5, K = 20, W = 1 << K; int n, q, tot; int ls[N], rs[N], sum[N], or0[N], or1[N], tag[N], dep[N]; void pushup(int p) { sum[p] = sum[ls[p]] + sum[rs[p]]; or0[p] = or0[ls[p]] | or0[rs[p]]; or1[p] = or1[ls[p]] | or1[rs[p]]; } void Tag(int p, int k) ...
### Prompt Create a solution in Cpp for the following problem: Phoenix loves playing with bits — specifically, by using the bitwise operations AND, OR, and XOR. He has n integers a_1, a_2, ..., a_n, and will perform q of the following queries: 1. replace all numbers a_i where l ≤ a_i ≤ r with a_i AND x; 2. repl...
#include <algorithm> #include <iostream> #include <sstream> #include <string> #include <vector> #include <queue> #include <set> #include <map> #include <cstdio> #include <cstdlib> #include <cctype> #include <cmath> #include <cstring> #include <list> #include <cassert> #include <climits> #inclu...
### Prompt Please formulate a CPP solution to the following problem: Phoenix loves playing with bits — specifically, by using the bitwise operations AND, OR, and XOR. He has n integers a_1, a_2, ..., a_n, and will perform q of the following queries: 1. replace all numbers a_i where l ≤ a_i ≤ r with a_i AND x; 2...
#include<bits/stdc++.h> #define L(i, j, k) for(int i = (j); i <= (k); i++) #define R(i, j, k) for(int i = (j); i >= (k); i--) #define ll long long #define sz(a) a.size() #define vi vector<int> using namespace std; const int N = 2e5 + 7, M = N * 80, rk = 20, mx = (1 << rk) - 1; int n, q, a[N]; int ch[M][2], to0[M], to...
### Prompt Please provide a cpp coded solution to the problem described below: Phoenix loves playing with bits — specifically, by using the bitwise operations AND, OR, and XOR. He has n integers a_1, a_2, ..., a_n, and will perform q of the following queries: 1. replace all numbers a_i where l ≤ a_i ≤ r with a_i A...
#include <cstdio> #include <cassert> #include <algorithm> int n,q; int rt,cnt; int ch[2][8000001],size[8000001],diff[8000001],val[8000001],lazy[8000001]; bool vis[8000001]; void pushup(int x){ if(vis[x])return; if(!size[ch[0][x]]){ size[x]=size[ch[1][x]]; diff[x]=diff[ch[1][x]]; val[x]=val[ch[1][x]]; } else ...
### Prompt Generate a Cpp solution to the following problem: Phoenix loves playing with bits — specifically, by using the bitwise operations AND, OR, and XOR. He has n integers a_1, a_2, ..., a_n, and will perform q of the following queries: 1. replace all numbers a_i where l ≤ a_i ≤ r with a_i AND x; 2. replac...
#include<bits/stdc++.h> using namespace std; typedef long long LL; const int N=1048576,C=20; int Ri(){ int x=0; char c=getchar(); for (;c<'0'||c>'9';c=getchar()); for (;c<='9'&&c>='0';c=getchar()) x=x*10+c-'0'; return x; } int n,cq; struct tree{ int s[2],cnt,all[2],rev; }tr[N*2+9]; int sta[N*2+9],cst; i...
### Prompt Construct a cpp code solution to the problem outlined: Phoenix loves playing with bits — specifically, by using the bitwise operations AND, OR, and XOR. He has n integers a_1, a_2, ..., a_n, and will perform q of the following queries: 1. replace all numbers a_i where l ≤ a_i ≤ r with a_i AND x; 2. r...
#include <bits/stdc++.h> using namespace std; using ll = long long; int MOD; struct modint { private: int v; static int minv(int a, int m) { a %= m; assert(a); return a == 1 ? 1 : int(m - ll(minv(m, a)) * ll(m) / a); } public: modint() : v(0) {} modint(ll v_) : v(int(v_...
### Prompt Your task is to create a cpp solution to the following problem: Phoenix loves playing with bits — specifically, by using the bitwise operations AND, OR, and XOR. He has n integers a_1, a_2, ..., a_n, and will perform q of the following queries: 1. replace all numbers a_i where l ≤ a_i ≤ r with a_i AND x...
#include <bits/stdc++.h> const int N = 8e6 + 5, K = 20, M = 1 << K; int n, q, tot, ls[N], rs[N], tk[N], t0[N], t1[N], ts[N], tt[N]; inline void pushup(int p) { ts[p] = ts[ls[p]] + ts[rs[p]]; t0[p] = t0[ls[p]] | t0[rs[p]]; t1[p] = t1[ls[p]] | t1[rs[p]]; } inline void tag(int p, int t) { if (!p) return; tt[p] ^=...
### Prompt In Cpp, your task is to solve the following problem: Phoenix loves playing with bits — specifically, by using the bitwise operations AND, OR, and XOR. He has n integers a_1, a_2, ..., a_n, and will perform q of the following queries: 1. replace all numbers a_i where l ≤ a_i ≤ r with a_i AND x; 2. rep...
/* { ###################### # Author # # Gary # # 2021 # ###################### */ #include<bits/stdc++.h> #define rb(a,b,c) for(int a=b;a<=c;++a) #define rl(a,b,c) for(int a=b;a>=c;--a) #define LL long long #define IT iterator #define PB push_back #define II(a,b) make_pair(a,b) ...
### Prompt Generate a Cpp solution to the following problem: Phoenix loves playing with bits — specifically, by using the bitwise operations AND, OR, and XOR. He has n integers a_1, a_2, ..., a_n, and will perform q of the following queries: 1. replace all numbers a_i where l ≤ a_i ≤ r with a_i AND x; 2. replac...
#include <iostream> #include <algorithm> #include<cmath> #include<cstring> #include<cstdio> #include<cstdlib> #include<vector> #include<iomanip> #include<ctime> #include<set> #include<map> #include<queue> #include<stack> #include<bitset> #define sqr(x) ((x)*(x)) #define fz1(i,n) for ((i)=1;(i)<=(n);(i)++) #define fd1(i...
### Prompt Create a solution in cpp for the following problem: Phoenix loves playing with bits — specifically, by using the bitwise operations AND, OR, and XOR. He has n integers a_1, a_2, ..., a_n, and will perform q of the following queries: 1. replace all numbers a_i where l ≤ a_i ≤ r with a_i AND x; 2. repl...
#include <bits/stdc++.h> typedef long long i64; #define sz(a) int((a).size()) #define all(a) (a).begin(), (a).end() #define rep(i, a, b) for (int i = (a); i < (b); ++i) #define per(i, a, b) for (int i = (b) - 1; i >= (a); --i) using namespace std; const int xn = 8e6, xk = 20, xs = 1 << xk; int n = 1, ls[xn], rs[xn], h...
### Prompt Your challenge is to write a cpp solution to the following problem: Phoenix loves playing with bits — specifically, by using the bitwise operations AND, OR, and XOR. He has n integers a_1, a_2, ..., a_n, and will perform q of the following queries: 1. replace all numbers a_i where l ≤ a_i ≤ r with a_i A...
#include <bits/stdc++.h> using namespace std; using ll=long long; //#define int ll #define rng(i,a,b) for(int i=int(a);i<int(b);i++) #define rep(i,b) rng(i,0,b) #define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--) #define per(i,b) gnr(i,0,b) #define pb push_back #define eb emplace_back #define a first #define b secon...
### Prompt Create a solution in cpp for the following problem: Phoenix loves playing with bits — specifically, by using the bitwise operations AND, OR, and XOR. He has n integers a_1, a_2, ..., a_n, and will perform q of the following queries: 1. replace all numbers a_i where l ≤ a_i ≤ r with a_i AND x; 2. repl...
#define DEBUG 0 #include <bits/stdc++.h> using namespace std; #if DEBUG // basic debugging macros int __i__,__j__; #define printLine(l) for(__i__=0;__i__<l;__i__++){cout<<"-";}cout<<endl #define printLine2(l,c) for(__i__=0;__i__<l;__i__++){cout<<c;}cout<<endl #define printVar(n) cout<<#n<<": "<<n<<endl #define printA...
### Prompt Create a solution in cpp for the following problem: Phoenix loves playing with bits — specifically, by using the bitwise operations AND, OR, and XOR. He has n integers a_1, a_2, ..., a_n, and will perform q of the following queries: 1. replace all numbers a_i where l ≤ a_i ≤ r with a_i AND x; 2. repl...
#include <bits/stdc++.h> using namespace std; template <typename T> void read(T &t) { t=0; char ch=getchar(); int f=1; while (ch<'0'||ch>'9') { if (ch=='-') f=-1; ch=getchar(); } do { (t*=10)+=ch-'0'; ch=getchar(); } while ('0'<=ch&&ch<='9'); t*=f; } const int maxn=(1e7)+10; int n,q,a[200010]; int rt,tot,N; int ls[m...
### Prompt Your challenge is to write a CPP solution to the following problem: Phoenix loves playing with bits — specifically, by using the bitwise operations AND, OR, and XOR. He has n integers a_1, a_2, ..., a_n, and will perform q of the following queries: 1. replace all numbers a_i where l ≤ a_i ≤ r with a_i A...
#include<iostream> #include<cstdio> #include<cstring> using namespace std; const int N=200010,D=20,M=N*D,Mx=(1<<D)-1; int n,m; namespace trie{ int val[M],ls[M],rs[M],tot,tag[M]; int h0[M],h1[M]; void setg(int u,int v,int d=D-1) { if(!u || d<0) return; if(v>>d&1) swap(ls[u],rs[u]); ...
### Prompt Create a solution in CPP for the following problem: Phoenix loves playing with bits — specifically, by using the bitwise operations AND, OR, and XOR. He has n integers a_1, a_2, ..., a_n, and will perform q of the following queries: 1. replace all numbers a_i where l ≤ a_i ≤ r with a_i AND x; 2. repl...
#include <cstdio> #include <algorithm> const int Maxn=200000; const int Maxv=(1<<20); const int Maxk=20; int n,q; int a[Maxn+5]; int Root,id_tot; struct Trie_Node{ int ch[2]; int val_0,val_1; int sum; int lazy; }seg[Maxn*Maxk+5]; int st[Maxn*Maxk+5],st_top; int new_node(){ int u; if(st_top>0){ u=st[st_top--]; ...
### Prompt Please provide a cpp coded solution to the problem described below: Phoenix loves playing with bits — specifically, by using the bitwise operations AND, OR, and XOR. He has n integers a_1, a_2, ..., a_n, and will perform q of the following queries: 1. replace all numbers a_i where l ≤ a_i ≤ r with a_i A...
#include <bits/stdc++.h> using namespace std; using ll = long long; int MOD; struct modint { private: int v; static int minv(int a, int m) { a %= m; assert(a); return a == 1 ? 1 : int(m - ll(minv(m, a)) * ll(m) / a); } public: modint() : v(0) {} modint(ll v_) : v(int(v_...
### Prompt Develop a solution in CPP to the problem described below: Phoenix loves playing with bits — specifically, by using the bitwise operations AND, OR, and XOR. He has n integers a_1, a_2, ..., a_n, and will perform q of the following queries: 1. replace all numbers a_i where l ≤ a_i ≤ r with a_i AND x; 2...
#include <bits/stdc++.h> using namespace std; #define rep(i, a, b) for(int i = a; i < (b); ++i) #define all(x) begin(x), end(x) #define sz(x) (int)(x).size() #define debug(...) //ignore typedef long long ll; typedef pair<int, int> pii; typedef vector<int> vi; typedef long double ld; const int LEV = 22; const int M1 =...
### Prompt Please create a solution in Cpp to the following problem: Phoenix loves playing with bits — specifically, by using the bitwise operations AND, OR, and XOR. He has n integers a_1, a_2, ..., a_n, and will perform q of the following queries: 1. replace all numbers a_i where l ≤ a_i ≤ r with a_i AND x; 2...
#include <iostream> #include <cstdio> #include <cstdlib> #include <algorithm> #include <cmath> #include <vector> #include <set> #include <map> #include <unordered_set> #include <unordered_map> #include <queue> #include <ctime> #include <cassert> #include <complex> #include <string> #include <cstring> #include <chrono> ...
### Prompt Construct a CPP code solution to the problem outlined: Phoenix loves playing with bits — specifically, by using the bitwise operations AND, OR, and XOR. He has n integers a_1, a_2, ..., a_n, and will perform q of the following queries: 1. replace all numbers a_i where l ≤ a_i ≤ r with a_i AND x; 2. r...
#include <cstdio> #include <cassert> #include <utility> #include <functional> #define X first #define Y second const int mod = 998244353; template<int k> struct node{ node <k-1>* chd[2]; int cnt; int lazy; int has[2]; int get_cnt(){ assert(this!=NULL); return cnt; } int get_has(int d){ assert(...
### Prompt Create a solution in Cpp for the following problem: Phoenix loves playing with bits — specifically, by using the bitwise operations AND, OR, and XOR. He has n integers a_1, a_2, ..., a_n, and will perform q of the following queries: 1. replace all numbers a_i where l ≤ a_i ≤ r with a_i AND x; 2. repl...
// Author: wlzhouzhuan #pragma GCC optimize("Ofast") #include <bits/stdc++.h> using namespace std; #define ll long long #define ull unsigned long long #define pii pair<int, int> #define pb push_back #define fir first #define sec second #define rep(i, l, r) for (int i = l; i <= r; i++) #define per(i, l, r) for (int i = ...
### Prompt Please formulate a Cpp solution to the following problem: Phoenix loves playing with bits — specifically, by using the bitwise operations AND, OR, and XOR. He has n integers a_1, a_2, ..., a_n, and will perform q of the following queries: 1. replace all numbers a_i where l ≤ a_i ≤ r with a_i AND x; 2...
#include<bits/stdc++.h> using namespace std; #define ll long long int #define M 1000000007 #define read(arr) for(int i=0;i<n;i++) cin>>arr[i]; #define print(arr) for(int i=0;i<n;i++) cout<<arr[i]<<" "; cout<<endl; #define vl vector<ll> bool sortcoll(vector<ll> &v1, vector<ll> &v2) { return v1[1]>v2[1]; } bool i...
### Prompt Please create a solution in cpp to the following problem: Welcome to Rockport City! It is time for your first ever race in the game against Ronnie. To make the race interesting, you have bet a dollars and Ronnie has bet b dollars. But the fans seem to be disappointed. The excitement of the fans is given b...
#include <bits/stdc++.h> typedef long long int ll; const unsigned int MOD = 1000000007; using namespace std; int main() { int t; cin >> t; for (int tt = 0; tt < t; tt++) { ll a,b; cin>>a>>b; if(a>b) swap(a,b); if(a==b) cout<<"0 0\n"; else { ll x=abs(a-b); ...
### Prompt Develop a solution in Cpp to the problem described below: Welcome to Rockport City! It is time for your first ever race in the game against Ronnie. To make the race interesting, you have bet a dollars and Ronnie has bet b dollars. But the fans seem to be disappointed. The excitement of the fans is given b...
//@ikung #include <bits/stdc++.h> using namespace std; #define int long long #define fast \ ios_base::sync_with_stdio(0); \ cin.tie(0); #define f(i, k) for (int i = 0; i < k; i++) #define F first #define S second #define endl "\n" #define rep(i, n) for (int i = 1; i <= n; i++) #define rew(...
### Prompt Your task is to create a CPP solution to the following problem: Welcome to Rockport City! It is time for your first ever race in the game against Ronnie. To make the race interesting, you have bet a dollars and Ronnie has bet b dollars. But the fans seem to be disappointed. The excitement of the fans is g...
#include <iostream> #include <iomanip> #include <cstdio> #include <cstring> #include <algorithm> #include <string> #include <cmath> #include <cstdlib> #include <vector> #include <queue> #include <set> #include <map> using namespace std; #define DBG(x) \ (void)(cout << "L" << __LINE__ \ ...
### Prompt Please create a solution in CPP to the following problem: Welcome to Rockport City! It is time for your first ever race in the game against Ronnie. To make the race interesting, you have bet a dollars and Ronnie has bet b dollars. But the fans seem to be disappointed. The excitement of the fans is given b...
#include<bits/stdc++.h> #define ll long long #define str string #define ch char #define sz 200005 using namespace std; int main() { ll t; cin>>t; while(t--) { ll a,b,x; cin>>a>>b; if(a==b) { cout<<0<<' '<<0<<endl; } else ...
### Prompt Please provide a cpp coded solution to the problem described below: Welcome to Rockport City! It is time for your first ever race in the game against Ronnie. To make the race interesting, you have bet a dollars and Ronnie has bet b dollars. But the fans seem to be disappointed. The excitement of the fans ...
#include <bits/stdc++.h> #define fi first #define se second #define pb push_back #define all(x) (x).begin(), (x).end() #define sum(a) (accumulate((a).begin(), (a).end(), 0ll)) #define mine(a) (*min_element((a).begin(), (a).end())) #define maxe(a) (*max_element((a).begin(), (a).end())) #define mini(a) (min_element((a)....
### Prompt Your challenge is to write a Cpp solution to the following problem: Welcome to Rockport City! It is time for your first ever race in the game against Ronnie. To make the race interesting, you have bet a dollars and Ronnie has bet b dollars. But the fans seem to be disappointed. The excitement of the fans ...
#include <bits/stdc++.h> using namespace std; #define int long long #define pii pair<int, int> int32_t mod = 1e9 + 7; void solveCase() { int a = 0, b = 0; cin >> a >> b; int mx = abs(a - b); if (mx == 0) { cout << "0 0\n"; return; } int moves = (a % mx ? min(a % mx, mx - a %...
### Prompt Please provide a Cpp coded solution to the problem described below: Welcome to Rockport City! It is time for your first ever race in the game against Ronnie. To make the race interesting, you have bet a dollars and Ronnie has bet b dollars. But the fans seem to be disappointed. The excitement of the fans ...
#include<iostream> using namespace std; #include<bits/stdc++.h> #include<string.h> #include <iomanip> #include <ctype.h> #define ll long long int #define test cout<<"Nevil\n"; #define ios ios_base::sync_with_stdio(false); cin.tie(NULL) #define pi 3.14159265359 #define precise(x) fixed << setprecision(x) ll md=1e9+7; ...
### Prompt Create a solution in Cpp for the following problem: Welcome to Rockport City! It is time for your first ever race in the game against Ronnie. To make the race interesting, you have bet a dollars and Ronnie has bet b dollars. But the fans seem to be disappointed. The excitement of the fans is given by gcd(...
#include <bits/stdc++.h> #define all(x) x.begin(),x.end() #define setval(arr,v) memset(arr,v,sizeof(arr)); #define int long long int #define mod 1000000007 #define v vector #define umap unordered_map #define pb push_back #define pf push_front #define pii pair<int,int> #define fi first #define se second #define INF 1000...
### Prompt Your challenge is to write a cpp solution to the following problem: Welcome to Rockport City! It is time for your first ever race in the game against Ronnie. To make the race interesting, you have bet a dollars and Ronnie has bet b dollars. But the fans seem to be disappointed. The excitement of the fans ...
#include<bits/stdc++.h> using namespace std; typedef long long ll; const int N=1e5+10; int t; int main() { cin >> t; while(t--) { ll a,b; cin >> a >> b; if(a==b) { cout << "0 0" << endl; continue; } ll num=abs(a-b); cout << num << " " << mi...
### Prompt Generate a CPP solution to the following problem: Welcome to Rockport City! It is time for your first ever race in the game against Ronnie. To make the race interesting, you have bet a dollars and Ronnie has bet b dollars. But the fans seem to be disappointed. The excitement of the fans is given by gcd(a,...
#include<bits/stdc++.h> using namespace std; ///typedef typedef long long ll; typedef pair<int, int> pii; ///define constant const ll mxn = 200005; const int mod = 1000000007;//1e9+7; ///faster io #define faster_io ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); ///debug #define watch(x) cout << __LINE__ << "...
### Prompt Create a solution in Cpp for the following problem: Welcome to Rockport City! It is time for your first ever race in the game against Ronnie. To make the race interesting, you have bet a dollars and Ronnie has bet b dollars. But the fans seem to be disappointed. The excitement of the fans is given by gcd(...
#include <bits/stdc++.h> using namespace std; #define read(x) freopen(x, "r", stdin); #define write(x) freopen(x, "w", stdout); #define ll long long #define lli long long int #define FOR(n) for(int i=0; i<(int)(n); ++i) #define mod 1073741824 #define MAX 100001 #define gcd(a, b) __gcd(a, b) int m...
### Prompt Your challenge is to write a CPP solution to the following problem: Welcome to Rockport City! It is time for your first ever race in the game against Ronnie. To make the race interesting, you have bet a dollars and Ronnie has bet b dollars. But the fans seem to be disappointed. The excitement of the fans ...
#include<bits/stdc++.h> using namespace std; int main() { int t; cin>>t; while(t--) { long long a,b; cin>>a>>b; if (a==b) cout<<0<<" "<<0<<endl; else { long long d= abs(a-b); long long s= 0; if( a==0 || b==0) ...
### Prompt Please formulate a Cpp solution to the following problem: Welcome to Rockport City! It is time for your first ever race in the game against Ronnie. To make the race interesting, you have bet a dollars and Ronnie has bet b dollars. But the fans seem to be disappointed. The excitement of the fans is given b...
#include<bits/stdc++.h> using namespace std; int main() { int T; cin>>T; while(T--) { long long a,b; cin>>a>>b; if(a==b) cout<<0<<" "<<0<<"\n"; else { long long g = abs(a-b); long long d = min(a%g,g-a%g); cout<<g<<" "<<d<<"\n"; } ...
### Prompt Develop a solution in cpp to the problem described below: Welcome to Rockport City! It is time for your first ever race in the game against Ronnie. To make the race interesting, you have bet a dollars and Ronnie has bet b dollars. But the fans seem to be disappointed. The excitement of the fans is given b...
#include<bits/stdc++.h> #define inf 100000000 #define int long long #define ll long long #define fr(a,b) for(int i = a; i < b; i++) #define rep(i,a,b) for(int i = a; i < b; i++) #define repn(i,a,b) for(int i = a-1; i >=0; i--) #define prDouble(x) cout << fixed << setprecision(10) << x #define endl "\n" #define yes cout...
### Prompt Your challenge is to write a CPP solution to the following problem: Welcome to Rockport City! It is time for your first ever race in the game against Ronnie. To make the race interesting, you have bet a dollars and Ronnie has bet b dollars. But the fans seem to be disappointed. The excitement of the fans ...
#include <iostream> #include<string> #include<algorithm> #include<climits> #include<cmath> #include<vector> #include<map> using namespace std; #define ll long long // void pg() // { // #ifndef ONLINE_JUDGE // freopen("input.txt", "r", stdin); // freopen("output.txt", "w", stdout); // #endif // } int main()...
### Prompt Construct a Cpp code solution to the problem outlined: Welcome to Rockport City! It is time for your first ever race in the game against Ronnie. To make the race interesting, you have bet a dollars and Ronnie has bet b dollars. But the fans seem to be disappointed. The excitement of the fans is given by g...
#include<bits/stdc++.h> using namespace std; #define st first #define nd second #define pb push_back typedef long long ll; typedef pair<int,int> pii; const ll MOD = 1e9 + 7; const int N = 2e5 + 5; int n, t; ll gcd(ll a, ll b){ if(a % b) return gcd(b, a % b); return b; } int main(){ scanf("%d", &t); while(t--)...
### Prompt In CPP, your task is to solve the following problem: Welcome to Rockport City! It is time for your first ever race in the game against Ronnie. To make the race interesting, you have bet a dollars and Ronnie has bet b dollars. But the fans seem to be disappointed. The excitement of the fans is given by gcd...
#include <bits/stdc++.h> #include <algorithm> using namespace std; typedef long long ll; /*int gcd(ll n1,ll n2) { return _gcd(n1,n2); } */int main() { #ifndef ONLINE_JUDGE freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif ios_base::sync_with_stdio(false); cin.tie(NULL); ...
### Prompt Construct a CPP code solution to the problem outlined: Welcome to Rockport City! It is time for your first ever race in the game against Ronnie. To make the race interesting, you have bet a dollars and Ronnie has bet b dollars. But the fans seem to be disappointed. The excitement of the fans is given by g...
#include<bits/stdc++.h> // #include <ext/pb_ds/assoc_container.hpp> //Policy Based Data Structure // using namespace __gnu_pbds; //Policy Based Data Structure using namespace std; // typedef tree<int, null_type, less<int>, rb_tree_tag,tree_order_statistics_node_update> pbds; //Policy Based Data Structure /...
### Prompt Generate a cpp solution to the following problem: Welcome to Rockport City! It is time for your first ever race in the game against Ronnie. To make the race interesting, you have bet a dollars and Ronnie has bet b dollars. But the fans seem to be disappointed. The excitement of the fans is given by gcd(a,...
///to serach //n to go forwards N to bakcwards //? to search backwards???? idr //bitwise #include <bits/stdc++.h> using namespace std; #define ll long long #define vi vector<long long> #define vpi vector<pair<ll, ll>> #define pb push_back #define pi pair<ll, ll> #define mp make_pair #define mod 4294967295 #define p pai...
### Prompt Please create a solution in cpp to the following problem: Welcome to Rockport City! It is time for your first ever race in the game against Ronnie. To make the race interesting, you have bet a dollars and Ronnie has bet b dollars. But the fans seem to be disappointed. The excitement of the fans is given b...
//Jai Shri Ram //Jai Shri Krishna #include<bits/stdc++.h> using namespace std; #define int long long typedef vector<int> vi ; typedef map<int,int> mii ; typedef pair<int,int> pii ; #define pb push_back #define all(V) V.begin(),V.end() #define uniq(v) (v).erase(unique(all(v)),(v).end()) #define distinct(v) dis...
### Prompt Your task is to create a Cpp solution to the following problem: Welcome to Rockport City! It is time for your first ever race in the game against Ronnie. To make the race interesting, you have bet a dollars and Ronnie has bet b dollars. But the fans seem to be disappointed. The excitement of the fans is g...
#include <cstdio> #include <cstring> #include <iostream> #include <set> #include <vector> #include <cmath> #include <map> #include <algorithm> #include <utility> #include <string> #include <cstdlib> #include <queue> #pragma GCC optimize(1) #pragma GCC optimize(2) #pragma GCC optimize(3,"Ofast","inline") using namespace...
### Prompt Develop a solution in CPP to the problem described below: Welcome to Rockport City! It is time for your first ever race in the game against Ronnie. To make the race interesting, you have bet a dollars and Ronnie has bet b dollars. But the fans seem to be disappointed. The excitement of the fans is given b...
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Code written by Aditya ;) || Codechef/codeforces: @adityaraj5200 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ #include<bits/stdc++.h> using namespace std; //#include<ext/pb_ds/assoc_container.hpp> //#include<ext/pb_...
### Prompt Your challenge is to write a Cpp solution to the following problem: Welcome to Rockport City! It is time for your first ever race in the game against Ronnie. To make the race interesting, you have bet a dollars and Ronnie has bet b dollars. But the fans seem to be disappointed. The excitement of the fans ...
#include<bits/stdc++.h> using namespace std; #define mod 1000000007 #define ll long long int #define endl "\n" #define pb push_back #define mp make_pair #define ut unsigned int #define ss second #define ff first #define vi vector<int> #define vl vector<ll> #define lb lower_bound #define up upper_bound #define re return...
### Prompt Create a solution in CPP for the following problem: Welcome to Rockport City! It is time for your first ever race in the game against Ronnie. To make the race interesting, you have bet a dollars and Ronnie has bet b dollars. But the fans seem to be disappointed. The excitement of the fans is given by gcd(...
#include <bits/stdc++.h> #define cs(n) scanf("%d", &n) #define lcs(n) scanf("%lld", &n) #define F(i, j, k) for(int i = j; i <= k; ++i) using namespace std; using ll = long long; const int MAXN = 1000004; const int INF = 0x3f3f3f3f; int main() { int T; cs(T); while(T--) { ll a; lcs(a); ll b; lcs(b); if(a =...
### Prompt Construct a Cpp code solution to the problem outlined: Welcome to Rockport City! It is time for your first ever race in the game against Ronnie. To make the race interesting, you have bet a dollars and Ronnie has bet b dollars. But the fans seem to be disappointed. The excitement of the fans is given by g...
#include<bits/stdc++.h> using namespace std; #define mp make_pair #define pb push_back #define fi first #define se second #define int long long typedef long long ll; typedef pair<ll, ll> pii; const int N = 2e5 + 10, MOD = 1e9 + 7; int n, m, t, ans, tmp, k1, k2, ans1, ans2; int a[N], b[N]; string s; void read_input() ...
### Prompt Construct a Cpp code solution to the problem outlined: Welcome to Rockport City! It is time for your first ever race in the game against Ronnie. To make the race interesting, you have bet a dollars and Ronnie has bet b dollars. But the fans seem to be disappointed. The excitement of the fans is given by g...
#include <bits/stdc++.h> using namespace std; using ll = long long; void solve() { ll a, b; cin>>a>>b; if(a == b){ cout<<0<<" "<<0<<"\n"; } else { ll k = max(a, b)-min(a, b); cout<<k<<" "<<min(k-(b%k), b%k)<<"\n"; } } int main() { int t; cin >> t; while (t--) { solve...
### Prompt Develop a solution in Cpp to the problem described below: Welcome to Rockport City! It is time for your first ever race in the game against Ronnie. To make the race interesting, you have bet a dollars and Ronnie has bet b dollars. But the fans seem to be disappointed. The excitement of the fans is given b...
#include <bits/stdc++.h> using namespace std; #define int long long signed main() { int t; cin>>t; while(t--) { int a,b; cin>>a>>b; if(a==b) { cout<<"0 0"<<endl; } else { if(a<b) swap(a,b); int g=a-b; ...
### Prompt Your task is to create a cpp solution to the following problem: Welcome to Rockport City! It is time for your first ever race in the game against Ronnie. To make the race interesting, you have bet a dollars and Ronnie has bet b dollars. But the fans seem to be disappointed. The excitement of the fans is g...
#include<bits/stdc++.h> #define fi first #define se second #define pb push_back #define sz(x) (int)x.size() #define all(x) x.begin(), x.end() #define rall(x) x.rbegin(), x.rend() #define mset(x,y) memset(x,y,sizeof(x)) using namespace std; void DBG(){ cerr<<")\n";} template<class H, class... T > void DBG( H h, T... t...
### Prompt Create a solution in CPP for the following problem: Welcome to Rockport City! It is time for your first ever race in the game against Ronnie. To make the race interesting, you have bet a dollars and Ronnie has bet b dollars. But the fans seem to be disappointed. The excitement of the fans is given by gcd(...
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main () { ll tt; cin >> tt; while (tt --) { ll a, b, one, two; cin >> a >> b; if (a == b) { cout << "0 0" << '\n'; continue; } one = abs (a - b); two = min (a % one...
### Prompt Generate a Cpp solution to the following problem: Welcome to Rockport City! It is time for your first ever race in the game against Ronnie. To make the race interesting, you have bet a dollars and Ronnie has bet b dollars. But the fans seem to be disappointed. The excitement of the fans is given by gcd(a,...
#include<bits/stdc++.h> using namespace std; typedef long long int ll; void s() { ll a,b; cin>>a>>b; if(a==b) { cout<<"0"<<" "<<"0"; return; } ll dif = abs(a-b); b=min(a,b); if(b%dif==0)cout<<dif<<" "<<"0"; else { ll y = min(b%dif,(dif-b%dif)); co...
### Prompt Your task is to create a cpp solution to the following problem: Welcome to Rockport City! It is time for your first ever race in the game against Ronnie. To make the race interesting, you have bet a dollars and Ronnie has bet b dollars. But the fans seem to be disappointed. The excitement of the fans is g...
#include <iostream> #include<math.h> using namespace std; int main() { long long int t,x,y; cin>>t; for(int i=0;i<t;++i) { cin>>x>>y; if(x==y) cout<<0<<" "<<0<<endl; else if(abs(x-y)==1) cout<<1<<" "<<0<<endl; else { if(x<y) ...
### Prompt Please create a solution in Cpp to the following problem: Welcome to Rockport City! It is time for your first ever race in the game against Ronnie. To make the race interesting, you have bet a dollars and Ronnie has bet b dollars. But the fans seem to be disappointed. The excitement of the fans is given b...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; #define en "\n"; #define all(x) (x).begin(), (x).end() ll mod = 1000000007; //ull n = 1e8; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); ll t; cin >> t; //cout<<"as.size()"<<en; ...
### Prompt Develop a solution in CPP to the problem described below: Welcome to Rockport City! It is time for your first ever race in the game against Ronnie. To make the race interesting, you have bet a dollars and Ronnie has bet b dollars. But the fans seem to be disappointed. The excitement of the fans is given b...
#include <bits/stdc++.h> using namespace std; using lint = long long; int main() { ios_base::sync_with_stdio(false); cin.tie(0); int tc; cin >> tc; while (tc--) { lint a, b; cin >> a >> b; if (a < b) swap(a, b); if (a == b) cout << 0 << " " << 0 << '\n'; else { cout << (a - b) << " " << min(a % (a -...
### Prompt Develop a solution in CPP to the problem described below: Welcome to Rockport City! It is time for your first ever race in the game against Ronnie. To make the race interesting, you have bet a dollars and Ronnie has bet b dollars. But the fans seem to be disappointed. The excitement of the fans is given b...
#include<iostream> #include<cstdio> #include<cmath> using namespace std; int main() { int t; scanf("%d",&t); while(t--) { long long a,b,c,d,ans; scanf("%lld%lld",&a,&b); if(a==b) printf("0 0\n"); else { c=abs(a-b); d=a%c; if(d<=c-d) ans=d; else ans=c-d; printf("%lld %lld\n",c,ans); } } ...
### Prompt Please provide a Cpp coded solution to the problem described below: Welcome to Rockport City! It is time for your first ever race in the game against Ronnie. To make the race interesting, you have bet a dollars and Ronnie has bet b dollars. But the fans seem to be disappointed. The excitement of the fans ...
#include <bits/stdc++.h> using namespace std; const int maxn = 1000 * 100 + 10; int main(){ ios::sync_with_stdio(false),cin.tie(0),cout.tie(0); int t; cin >> t; while (t--){ long long a, b; cin >> a >> b; long long r = abs(a - b); if (!r){ cout << 0 << ' ' << 0 << '\n'; continue; } cout << r <<...
### Prompt Generate a Cpp solution to the following problem: Welcome to Rockport City! It is time for your first ever race in the game against Ronnie. To make the race interesting, you have bet a dollars and Ronnie has bet b dollars. But the fans seem to be disappointed. The excitement of the fans is given by gcd(a,...
#pragma GCC target ("avx2,fma") #pragma GCC optimize ("O3") #pragma GCC optimize ("unroll-loops") #include<bits/stdc++.h> #define int long long #define endl '\n' using namespace std; int IOS = []() {ios::sync_with_stdio(0); std::cin.tie(nullptr); std::cout.tie(nullptr); return 0; }(); #define pb push_back #define po p...
### Prompt Please provide a cpp coded solution to the problem described below: Welcome to Rockport City! It is time for your first ever race in the game against Ronnie. To make the race interesting, you have bet a dollars and Ronnie has bet b dollars. But the fans seem to be disappointed. The excitement of the fans ...