Search is not available for this dataset
name
stringlengths
2
112
description
stringlengths
29
13k
source
int64
1
7
difficulty
int64
0
25
solution
stringlengths
7
983k
language
stringclasses
4 values
482_B. Interesting Array
We'll call an array of n non-negative integers a[1], a[2], ..., a[n] interesting, if it meets m constraints. The i-th of the m constraints consists of three integers li, ri, qi (1 ≤ li ≤ ri ≤ n) meaning that value <image> should be equal to qi. Your task is to find any interesting array of n elements or state that su...
2
8
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Arrays; public class InterestingArray { public static int tree[]; public static int lazy[]; public static void create(int s, int e, int p, int l, int r, int val) { if (lazy[p] != 0) { tree[p] |= lazy...
JAVA
482_B. Interesting Array
We'll call an array of n non-negative integers a[1], a[2], ..., a[n] interesting, if it meets m constraints. The i-th of the m constraints consists of three integers li, ri, qi (1 ≤ li ≤ ri ≤ n) meaning that value <image> should be equal to qi. Your task is to find any interesting array of n elements or state that su...
2
8
import java.io.BufferedReader; import java.io.FileReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.Arrays; import java.util.StringTokenizer; public class InterestingArray { public static void main(String[] args) throws Numb...
JAVA
482_B. Interesting Array
We'll call an array of n non-negative integers a[1], a[2], ..., a[n] interesting, if it meets m constraints. The i-th of the m constraints consists of three integers li, ri, qi (1 ≤ li ≤ ri ≤ n) meaning that value <image> should be equal to qi. Your task is to find any interesting array of n elements or state that su...
2
8
#include <bits/stdc++.h> using namespace std; int t, n, m, q, k; int ql[111111], qr[111111], qq[111111], sm[111111], ans[111111]; int T[111111 << 3]; void bt(int x, int l, int r) { if (l == r) { T[x] = ans[l]; return; } int md = (l + r) >> 1; bt((x << 1), l, md); bt(((x << 1) | 1), md + 1, r); T[x] ...
CPP
482_B. Interesting Array
We'll call an array of n non-negative integers a[1], a[2], ..., a[n] interesting, if it meets m constraints. The i-th of the m constraints consists of three integers li, ri, qi (1 ≤ li ≤ ri ≤ n) meaning that value <image> should be equal to qi. Your task is to find any interesting array of n elements or state that su...
2
8
#include <bits/stdc++.h> using namespace std; const int bits = 30; struct rest { int l, r, q; }; int n, m, i; int ans[100011]; rest R[100011]; int sum[100011]; int cnt[100011]; void solve(int bit) { int i; memset(sum, 0, sizeof(sum)); for (i = 1; i <= m; i++) { if ((R[i].q >> bit) & 1) { sum[R[i].l]++...
CPP
482_B. Interesting Array
We'll call an array of n non-negative integers a[1], a[2], ..., a[n] interesting, if it meets m constraints. The i-th of the m constraints consists of three integers li, ri, qi (1 ≤ li ≤ ri ≤ n) meaning that value <image> should be equal to qi. Your task is to find any interesting array of n elements or state that su...
2
8
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0); int n, m; cin >> n >> m; vector<vector<int> > A(n + 2, vector<int>(32)); vector<int> q(m), l(m), r(m); for (int i = 0; i < m; i++) { cin >> l[i] >> r[i] >> q[i]; for (int j = 0; j < 30; j++) { if ((q[i] >> j) &...
CPP
482_B. Interesting Array
We'll call an array of n non-negative integers a[1], a[2], ..., a[n] interesting, if it meets m constraints. The i-th of the m constraints consists of three integers li, ri, qi (1 ≤ li ≤ ri ≤ n) meaning that value <image> should be equal to qi. Your task is to find any interesting array of n elements or state that su...
2
8
#include <bits/stdc++.h> const int N = 1e5 + 20; using namespace std; int n, m; int l[N], r[N], q[N], a[N], it[4 * N], s[N][30]; void build(int ind, int b, int e) { if (b == e) { it[ind] = a[b]; return; } int mid = (b + e) / 2; build(2 * ind, b, mid); build(2 * ind + 1, mid + 1, e); it[ind] = it[2 *...
CPP
482_B. Interesting Array
We'll call an array of n non-negative integers a[1], a[2], ..., a[n] interesting, if it meets m constraints. The i-th of the m constraints consists of three integers li, ri, qi (1 ≤ li ≤ ri ≤ n) meaning that value <image> should be equal to qi. Your task is to find any interesting array of n elements or state that su...
2
8
//package Graphs; import java.io.*; import java.util.Arrays; import java.util.StringTokenizer; public class main482B { public static PrintWriter out = new PrintWriter(System.out); public static FastScanner enter = new FastScanner(System.in); public static long mod=(1 << 30) - 1; public static void mai...
JAVA
482_B. Interesting Array
We'll call an array of n non-negative integers a[1], a[2], ..., a[n] interesting, if it meets m constraints. The i-th of the m constraints consists of three integers li, ri, qi (1 ≤ li ≤ ri ≤ n) meaning that value <image> should be equal to qi. Your task is to find any interesting array of n elements or state that su...
2
8
#include <bits/stdc++.h> using namespace std; const int MAXN = 5 + 100000; int b[MAXN][32]; struct Query { int l, r, q; } arr[MAXN]; int go(int l, int r, int bit) { return b[r][bit] - (l ? b[l - 1][bit] : 0); } int main() { ios::sync_with_stdio(false); cin.tie(0); int n, m; cin >> n >> m; for (int i = (int)...
CPP
482_B. Interesting Array
We'll call an array of n non-negative integers a[1], a[2], ..., a[n] interesting, if it meets m constraints. The i-th of the m constraints consists of three integers li, ri, qi (1 ≤ li ≤ ri ≤ n) meaning that value <image> should be equal to qi. Your task is to find any interesting array of n elements or state that su...
2
8
#include <bits/stdc++.h> using namespace std; long long a[100005], n, i, l[100005], r[100005], value, qu, q[100005], lazy[400005]; long long st[400005]; void update(long long node, long long start, long long end, long long l, long long r, long long value) { if (lazy[node] != 0) { st[node] |= lazy[...
CPP
482_B. Interesting Array
We'll call an array of n non-negative integers a[1], a[2], ..., a[n] interesting, if it meets m constraints. The i-th of the m constraints consists of three integers li, ri, qi (1 ≤ li ≤ ri ≤ n) meaning that value <image> should be equal to qi. Your task is to find any interesting array of n elements or state that su...
2
8
/* ID: govind.3, GhpS, govindpatel LANG: JAVA TASK: Main */ import java.io.*; import java.util.*; public class Main { private final int BIT = 30; private final int MAX = 1000 * 1000;//10^6 private int[] tree = new int[4 * MAX]; private int[] values = new int[MAX]; private void build(int v, ...
JAVA
482_B. Interesting Array
We'll call an array of n non-negative integers a[1], a[2], ..., a[n] interesting, if it meets m constraints. The i-th of the m constraints consists of three integers li, ri, qi (1 ≤ li ≤ ri ≤ n) meaning that value <image> should be equal to qi. Your task is to find any interesting array of n elements or state that su...
2
8
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.Scanner; import java.util.StringTokenizer; public class Main { public static void main(String[] args) throws IOException { BufferedReader reader = new BufferedReader...
JAVA
482_B. Interesting Array
We'll call an array of n non-negative integers a[1], a[2], ..., a[n] interesting, if it meets m constraints. The i-th of the m constraints consists of three integers li, ri, qi (1 ≤ li ≤ ri ≤ n) meaning that value <image> should be equal to qi. Your task is to find any interesting array of n elements or state that su...
2
8
import java.awt.*; import java.awt.event.*; import java.awt.geom.*; import java.io.*; import java.math.*; import java.text.*; import java.util.*; import java.util.regex.*; /* br = new BufferedReader(new FileReader("input.txt")); pw = new PrintWriter(new BufferedWriter(new FileWriter("output.txt"))); br = new Bu...
JAVA
482_B. Interesting Array
We'll call an array of n non-negative integers a[1], a[2], ..., a[n] interesting, if it meets m constraints. The i-th of the m constraints consists of three integers li, ri, qi (1 ≤ li ≤ ri ≤ n) meaning that value <image> should be equal to qi. Your task is to find any interesting array of n elements or state that su...
2
8
#include <bits/stdc++.h> using namespace std; int n, l[100005], r[100005], q[100005], m, t[300000], sum[100005], arr[100005]; void buildTree(int root, int l, int r) { if (l == r) { t[root] = arr[l]; return; } int mid = (l + r) >> 1; buildTree(root * 2, l, mid); buildTree(root * 2 + 1, mid + 1, r); t...
CPP
482_B. Interesting Array
We'll call an array of n non-negative integers a[1], a[2], ..., a[n] interesting, if it meets m constraints. The i-th of the m constraints consists of three integers li, ri, qi (1 ≤ li ≤ ri ≤ n) meaning that value <image> should be equal to qi. Your task is to find any interesting array of n elements or state that su...
2
8
import java.io.*; import java.math.*; import java.util.*; public class Main { public static class pair implements Comparable<pair> { int a; int b; public pair(int pa, int pb) { a = pa; b= pb; } @Override public int compareTo(pair o) { if(this.a < o.a) return -1; if(this.a > o.a) ret...
JAVA
482_B. Interesting Array
We'll call an array of n non-negative integers a[1], a[2], ..., a[n] interesting, if it meets m constraints. The i-th of the m constraints consists of three integers li, ri, qi (1 ≤ li ≤ ri ≤ n) meaning that value <image> should be equal to qi. Your task is to find any interesting array of n elements or state that su...
2
8
#include <bits/stdc++.h> using namespace std; int n, m; int arr[100005]; int pf[32][100005]; int st[4 * 100005]; void init() { memset(arr, 0, sizeof(arr)); memset(pf, 0, sizeof(pf)); return; } void build(int l = 0, int r = n - 1, int idx = 0) { if (l == r) { st[idx] = arr[l]; return; } int mid = l +...
CPP
482_B. Interesting Array
We'll call an array of n non-negative integers a[1], a[2], ..., a[n] interesting, if it meets m constraints. The i-th of the m constraints consists of three integers li, ri, qi (1 ≤ li ≤ ri ≤ n) meaning that value <image> should be equal to qi. Your task is to find any interesting array of n elements or state that su...
2
8
#include <bits/stdc++.h> #pragma comment(linker, "/STACK:256000000") using namespace std; struct item { int l, r, q; }; item a[100007]; int t[100007 * 4]; int t_add[100007 * 4]; void add(int v, int l, int r, int pl, int pr, int delta) { if (pl > pr) return; if (pr < l || r < pl) return; if (pl <= l && r <= pr) ...
CPP
482_B. Interesting Array
We'll call an array of n non-negative integers a[1], a[2], ..., a[n] interesting, if it meets m constraints. The i-th of the m constraints consists of three integers li, ri, qi (1 ≤ li ≤ ri ≤ n) meaning that value <image> should be equal to qi. Your task is to find any interesting array of n elements or state that su...
2
8
//package HackerEarthA; import java.io.*; import java.util.*; import java.util.Map.Entry; import java.text.*; import java.math.*; import java.util.regex.*; import java.awt.Point; /** * * @author prabhat */ public class easy18{ public static long[] BIT; public static long[] tree; public static long...
JAVA
482_B. Interesting Array
We'll call an array of n non-negative integers a[1], a[2], ..., a[n] interesting, if it meets m constraints. The i-th of the m constraints consists of three integers li, ri, qi (1 ≤ li ≤ ri ≤ n) meaning that value <image> should be equal to qi. Your task is to find any interesting array of n elements or state that su...
2
8
#include <bits/stdc++.h> using namespace std; const int MAXN = 100005; vector<int> op[MAXN], cl[MAXN]; int l[MAXN], r[MAXN]; int a[MAXN]; int val[MAXN]; int n, m; int t[MAXN * 4]; int tsize; int getAnd(int l, int r) { l += tsize; r += tsize; int res = (1 << 30) - 1; while (l <= r) { if (l & 1) res &= t[l++]...
CPP
482_B. Interesting Array
We'll call an array of n non-negative integers a[1], a[2], ..., a[n] interesting, if it meets m constraints. The i-th of the m constraints consists of three integers li, ri, qi (1 ≤ li ≤ ri ≤ n) meaning that value <image> should be equal to qi. Your task is to find any interesting array of n elements or state that su...
2
8
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.Arrays; import java.util.StringTokenizer; public class InterestingArray { public static void main(String[] args) throws IOException { Scanner s = new Scanner(System.in); int n ...
JAVA
482_B. Interesting Array
We'll call an array of n non-negative integers a[1], a[2], ..., a[n] interesting, if it meets m constraints. The i-th of the m constraints consists of three integers li, ri, qi (1 ≤ li ≤ ri ≤ n) meaning that value <image> should be equal to qi. Your task is to find any interesting array of n elements or state that su...
2
8
#include <bits/stdc++.h> #pragma comment(linker, "/stack:32000000") using namespace std; const int INF = 2147483647; const long long LLINF = 9223372036854775807LL; const int maxn = 4 * 100010; int T[maxn]; int N; int query(int l, int r) { int ans = ~0; for (l += N, r += N; l <= r; l = (l + 1) >> 1, r = (r - 1) >> 1...
CPP
482_B. Interesting Array
We'll call an array of n non-negative integers a[1], a[2], ..., a[n] interesting, if it meets m constraints. The i-th of the m constraints consists of three integers li, ri, qi (1 ≤ li ≤ ri ≤ n) meaning that value <image> should be equal to qi. Your task is to find any interesting array of n elements or state that su...
2
8
/** * Date: 20 Nov, 2018 * Link: * * @author Prasad-Chaudhari * @linkedIn: https://www.linkedin.com/in/prasad-chaudhari-841655a6/ * @git: https://github.com/Prasad-Chaudhari */ import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.IOException; import java.io.InputStreamReader; import java...
JAVA
482_B. Interesting Array
We'll call an array of n non-negative integers a[1], a[2], ..., a[n] interesting, if it meets m constraints. The i-th of the m constraints consists of three integers li, ri, qi (1 ≤ li ≤ ri ≤ n) meaning that value <image> should be equal to qi. Your task is to find any interesting array of n elements or state that su...
2
8
#include <bits/stdc++.h> #pragma GCC optimize("Ofast") using namespace std; const int B = 317; const int N = 1e5 + 7; const long long mod = 998244353; const long long inf = 1e18; long long n, k; long long a[N]; long long l[N]; long long q[N]; long long r[N]; long long sum[N]; long long t[4 * N]; void build(int x, int l...
CPP
482_B. Interesting Array
We'll call an array of n non-negative integers a[1], a[2], ..., a[n] interesting, if it meets m constraints. The i-th of the m constraints consists of three integers li, ri, qi (1 ≤ li ≤ ri ≤ n) meaning that value <image> should be equal to qi. Your task is to find any interesting array of n elements or state that su...
2
8
import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; // atharva washimkar // Oct 18, 2018 public class CODEFORCES_482_B { static int[] tree; public static void build (int i, int l, int r, int[] arr) { if (l == r) { tree[i] = arr[l]; } else { ...
JAVA
482_B. Interesting Array
We'll call an array of n non-negative integers a[1], a[2], ..., a[n] interesting, if it meets m constraints. The i-th of the m constraints consists of three integers li, ri, qi (1 ≤ li ≤ ri ≤ n) meaning that value <image> should be equal to qi. Your task is to find any interesting array of n elements or state that su...
2
8
#include <bits/stdc++.h> using namespace std; const char InFile[] = "input.in"; const char OutFile[] = "output.out"; const int MaxN = 100111; int N, M; int T[32][MaxN], L[MaxN], R[MaxN], Q[MaxN]; int main() { cin >> N >> M; for (int i = 1; i <= M; ++i) { cin >> L[i] >> R[i] >> Q[i]; int X = Q[i]; for (i...
CPP
482_B. Interesting Array
We'll call an array of n non-negative integers a[1], a[2], ..., a[n] interesting, if it meets m constraints. The i-th of the m constraints consists of three integers li, ri, qi (1 ≤ li ≤ ri ≤ n) meaning that value <image> should be equal to qi. Your task is to find any interesting array of n elements or state that su...
2
8
import java.io.*; import java.util.*; public class B { public static void main(String[] args) throws Exception { new B().solve(); } void solve() throws IOException { FastScanner in = new FastScanner(System.in); int n = in.nextInt(); int m = in.nextInt(); int[][] d...
JAVA
482_B. Interesting Array
We'll call an array of n non-negative integers a[1], a[2], ..., a[n] interesting, if it meets m constraints. The i-th of the m constraints consists of three integers li, ri, qi (1 ≤ li ≤ ri ≤ n) meaning that value <image> should be equal to qi. Your task is to find any interesting array of n elements or state that su...
2
8
import java.io.BufferedReader; import java.io.File; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.util.HashSet; import java.util.Set; import java.util.StringToken...
JAVA
482_B. Interesting Array
We'll call an array of n non-negative integers a[1], a[2], ..., a[n] interesting, if it meets m constraints. The i-th of the m constraints consists of three integers li, ri, qi (1 ≤ li ≤ ri ≤ n) meaning that value <image> should be equal to qi. Your task is to find any interesting array of n elements or state that su...
2
8
#include <bits/stdc++.h> using namespace std; const int base = 1331; const int N = 1e5 + 1; template <typename T> inline void Cin(T& x) { char c = getchar(); x = 0; while (c < '0' || c > '9') c = getchar(); while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar(); } template <typename T, typename... Arg...
CPP
482_B. Interesting Array
We'll call an array of n non-negative integers a[1], a[2], ..., a[n] interesting, if it meets m constraints. The i-th of the m constraints consists of three integers li, ri, qi (1 ≤ li ≤ ri ≤ n) meaning that value <image> should be equal to qi. Your task is to find any interesting array of n elements or state that su...
2
8
import java.io.*; import java.math.*; import java.util.*; import static java.util.Arrays.*; public class B { private static final int mod = (int)1e9+7; final Random random = new Random(0); final IOFast io = new IOFast(); /// MAIN CODE public void run() throws IOException { // int TEST_CASE = Integer.parseInt...
JAVA
482_B. Interesting Array
We'll call an array of n non-negative integers a[1], a[2], ..., a[n] interesting, if it meets m constraints. The i-th of the m constraints consists of three integers li, ri, qi (1 ≤ li ≤ ri ≤ n) meaning that value <image> should be equal to qi. Your task is to find any interesting array of n elements or state that su...
2
8
#include <bits/stdc++.h> using namespace std; int x[100005], y[100005], q[100005], ans[100005]; struct segtree { private: bool tree[100005 << 2]; public: void Clear(int l, int r, int rt) { tree[rt] = false; if (l == r) return; int m = (l + r) >> 1; Clear(l, m, rt << 1); Clear(m + 1, r, rt << ...
CPP
482_B. Interesting Array
We'll call an array of n non-negative integers a[1], a[2], ..., a[n] interesting, if it meets m constraints. The i-th of the m constraints consists of three integers li, ri, qi (1 ≤ li ≤ ri ≤ n) meaning that value <image> should be equal to qi. Your task is to find any interesting array of n elements or state that su...
2
8
#include <bits/stdc++.h> using namespace std; struct Tree { int sz; vector<int> t; vector<int> d; Tree(int sz) : sz(sz), t(sz * 4), d(sz * 4) {} void push(int v) { d[2 * v + 1] |= d[v]; t[2 * v + 1] |= d[v]; d[2 * v + 2] |= d[v]; t[2 * v + 2] |= d[v]; d[v] = 0; } int get(int v) { retur...
CPP
482_B. Interesting Array
We'll call an array of n non-negative integers a[1], a[2], ..., a[n] interesting, if it meets m constraints. The i-th of the m constraints consists of three integers li, ri, qi (1 ≤ li ≤ ri ≤ n) meaning that value <image> should be equal to qi. Your task is to find any interesting array of n elements or state that su...
2
8
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.InputMismatchException; import java.io.IOException; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at the top * * @author Pradyumn Agrawal coderbond0...
JAVA
482_B. Interesting Array
We'll call an array of n non-negative integers a[1], a[2], ..., a[n] interesting, if it meets m constraints. The i-th of the m constraints consists of three integers li, ri, qi (1 ≤ li ≤ ri ≤ n) meaning that value <image> should be equal to qi. Your task is to find any interesting array of n elements or state that su...
2
8
#include <bits/stdc++.h> using namespace std; const int N = 100010, M = 35; long long prefix[M][N], bit[M][N]; int get_sum(int p, int left, int right) { int res = prefix[p][right]; if (left > 0) res -= prefix[p][left - 1]; return res; } int main() { int n, m; scanf("%d %d", &n, &m); vector<vector<int>> arr;...
CPP
482_B. Interesting Array
We'll call an array of n non-negative integers a[1], a[2], ..., a[n] interesting, if it meets m constraints. The i-th of the m constraints consists of three integers li, ri, qi (1 ≤ li ≤ ri ≤ n) meaning that value <image> should be equal to qi. Your task is to find any interesting array of n elements or state that su...
2
8
#include <bits/stdc++.h> using namespace std; int lazy[5000001]; int it[5000001]; int l[1000001], r[1000001], u[1000001]; void push_down(int k, int l, int r) { if (l == r) return; it[2 * k] |= lazy[k]; it[2 * k + 1] |= lazy[k]; lazy[2 * k] |= lazy[k]; lazy[2 * k + 1] |= lazy[k]; } void update(int k, int l, in...
CPP
482_B. Interesting Array
We'll call an array of n non-negative integers a[1], a[2], ..., a[n] interesting, if it meets m constraints. The i-th of the m constraints consists of three integers li, ri, qi (1 ≤ li ≤ ri ≤ n) meaning that value <image> should be equal to qi. Your task is to find any interesting array of n elements or state that su...
2
8
#include <bits/stdc++.h> using namespace std; template <class T> void read(T &x) { int f = 0; x = 0; char ch = getchar(); for (; !isdigit(ch); ch = getchar()) f |= (ch == '-'); for (; isdigit(ch); ch = getchar()) x = x * 10 + ch - '0'; if (f) x = -x; } const int N = 100005; int s[N][30], t[N][30], l[N], r[N...
CPP
482_B. Interesting Array
We'll call an array of n non-negative integers a[1], a[2], ..., a[n] interesting, if it meets m constraints. The i-th of the m constraints consists of three integers li, ri, qi (1 ≤ li ≤ ri ≤ n) meaning that value <image> should be equal to qi. Your task is to find any interesting array of n elements or state that su...
2
8
import java.io.*; import java.util.StringTokenizer; public class Main { public static void main(String[] args) throws IOException { // write your code here InputReader reader = new InputReader(System.in); PrintWriter writer = new PrintWriter(System.out,true); try { Task task =...
JAVA
482_B. Interesting Array
We'll call an array of n non-negative integers a[1], a[2], ..., a[n] interesting, if it meets m constraints. The i-th of the m constraints consists of three integers li, ri, qi (1 ≤ li ≤ ri ≤ n) meaning that value <image> should be equal to qi. Your task is to find any interesting array of n elements or state that su...
2
8
#include <bits/stdc++.h> using namespace std; const int MAXN = 1 << 17; const int MAXB = 30; int a[MAXN][MAXB]; int l[MAXN], r[MAXN], q[MAXN]; int T[2 * MAXN]; int offset = 1 << 17; int query(int i, int lo, int hi, int a, int b) { if (lo >= b || hi <= a) return (1 << MAXB) - 1; if (lo >= a && hi <= b) return T[i]; ...
CPP
482_B. Interesting Array
We'll call an array of n non-negative integers a[1], a[2], ..., a[n] interesting, if it meets m constraints. The i-th of the m constraints consists of three integers li, ri, qi (1 ≤ li ≤ ri ≤ n) meaning that value <image> should be equal to qi. Your task is to find any interesting array of n elements or state that su...
2
8
#include <bits/stdc++.h> using namespace std; int n, m, l, r, q, gl = 0; int ans[200000], seg[3000000], hl[200000], hr[200000], hq[200000]; void func(int pos, int l, int r, int ql, int qr, int x) { if (r < ql || l > qr) return; if (l >= ql && r <= qr) { seg[pos] = seg[pos] | x; return; } int mid = (l + ...
CPP
482_B. Interesting Array
We'll call an array of n non-negative integers a[1], a[2], ..., a[n] interesting, if it meets m constraints. The i-th of the m constraints consists of three integers li, ri, qi (1 ≤ li ≤ ri ≤ n) meaning that value <image> should be equal to qi. Your task is to find any interesting array of n elements or state that su...
2
8
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 123; const int mod = 1e9 + 7; const int INF = 1e9 + 1; const long long INFL = 3e18 + 1; const double pi = acos(-1.0); int n, m; struct ramen { int l, r, val; } a[N]; int sum[N][50], ans[N][50]; int f[N], T[4 * N]; void build(int v = 1, int tl = 1, int ...
CPP
482_B. Interesting Array
We'll call an array of n non-negative integers a[1], a[2], ..., a[n] interesting, if it meets m constraints. The i-th of the m constraints consists of three integers li, ri, qi (1 ≤ li ≤ ri ≤ n) meaning that value <image> should be equal to qi. Your task is to find any interesting array of n elements or state that su...
2
8
import java.io.*; import java.util.*; public class segTree { public static void main(String[] args) throws IOException { Scanner sc = new Scanner(System.in); PrintWriter out = new PrintWriter(System.out); int n = sc.nextInt(), m = sc.nextInt(); Triple[] queries = new Triple[m]; for(int i=0;i<m;i++) quer...
JAVA
482_B. Interesting Array
We'll call an array of n non-negative integers a[1], a[2], ..., a[n] interesting, if it meets m constraints. The i-th of the m constraints consists of three integers li, ri, qi (1 ≤ li ≤ ri ≤ n) meaning that value <image> should be equal to qi. Your task is to find any interesting array of n elements or state that su...
2
8
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.StringTokenizer; /** * @author Don Li */ public class InterestingArray { static final int INF = (1 << 30) - 1; void solve() { int n = in.nextInt(), m = in.nextIn...
JAVA
482_B. Interesting Array
We'll call an array of n non-negative integers a[1], a[2], ..., a[n] interesting, if it meets m constraints. The i-th of the m constraints consists of three integers li, ri, qi (1 ≤ li ≤ ri ≤ n) meaning that value <image> should be equal to qi. Your task is to find any interesting array of n elements or state that su...
2
8
#include <bits/stdc++.h> using namespace std; const int N = 110000; vector<int> ans; struct Node { int l, r, q; }; Node a[N]; Node tree[10 * N]; void build(int root, int l, int r) { tree[root].l = l; tree[root].r = r; tree[root].q = 0; if (l == r) return; build(root * 2, l, (l + r) / 2); build(root * 2 + ...
CPP
482_B. Interesting Array
We'll call an array of n non-negative integers a[1], a[2], ..., a[n] interesting, if it meets m constraints. The i-th of the m constraints consists of three integers li, ri, qi (1 ≤ li ≤ ri ≤ n) meaning that value <image> should be equal to qi. Your task is to find any interesting array of n elements or state that su...
2
8
import sys input = sys.stdin.readline n, m = map(int, input().split()) a = [] for _ in range(m): l, r, q = map(int, input().split()) l -= 1 r -= 1 a.append((l, r, q)) res = [0] * n bad = False for i in range(30): events = [0] * (n + 1) for l, r, q in a: if q & (1 << i): eve...
PYTHON3
482_B. Interesting Array
We'll call an array of n non-negative integers a[1], a[2], ..., a[n] interesting, if it meets m constraints. The i-th of the m constraints consists of three integers li, ri, qi (1 ≤ li ≤ ri ≤ n) meaning that value <image> should be equal to qi. Your task is to find any interesting array of n elements or state that su...
2
8
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 7; const int inf = (1 << 30) - 1; int t[4 * N]; int bit[30]; vector<int> seg[N][2]; void build(int v, int tl, int tr, vector<int> &a) { if (tl == tr) { t[v] = a[tl]; return; } int tm = (tl + tr) >> 1; build(2 * v + 1, tl, tm, a); build(...
CPP
482_B. Interesting Array
We'll call an array of n non-negative integers a[1], a[2], ..., a[n] interesting, if it meets m constraints. The i-th of the m constraints consists of three integers li, ri, qi (1 ≤ li ≤ ri ≤ n) meaning that value <image> should be equal to qi. Your task is to find any interesting array of n elements or state that su...
2
8
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.InputMismatchException; import java.io.IOException; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at the top * * @author Pradyumn Agrawal coderbond0...
JAVA
482_B. Interesting Array
We'll call an array of n non-negative integers a[1], a[2], ..., a[n] interesting, if it meets m constraints. The i-th of the m constraints consists of three integers li, ri, qi (1 ≤ li ≤ ri ≤ n) meaning that value <image> should be equal to qi. Your task is to find any interesting array of n elements or state that su...
2
8
#include <bits/stdc++.h> using namespace std; template <typename T> ostream& operator<<(ostream& output, vector<T>& v) { output << "[ "; if (int(v.size())) { output << v[0]; } for (int i = 1; i < int(v.size()); i++) { output << ", " << v[i]; } output << " ]"; return output; } template <typename T1...
CPP
482_B. Interesting Array
We'll call an array of n non-negative integers a[1], a[2], ..., a[n] interesting, if it meets m constraints. The i-th of the m constraints consists of three integers li, ri, qi (1 ≤ li ≤ ri ≤ n) meaning that value <image> should be equal to qi. Your task is to find any interesting array of n elements or state that su...
2
8
#include <bits/stdc++.h> using namespace std; const int B = 31, N = 100012; int n, m, q, w, y, l[N], r[N], x[N]; int s[N][B + 1], ss[N][B + 1], cur[B + 1], a[N], ll, rr, xx; int sum(int l, int r, int x) { return ss[r][x] - ss[l - 1][x]; } int main() { cin.tie(NULL); ios_base::sync_with_stdio(false); cin >> n >> m...
CPP
482_B. Interesting Array
We'll call an array of n non-negative integers a[1], a[2], ..., a[n] interesting, if it meets m constraints. The i-th of the m constraints consists of three integers li, ri, qi (1 ≤ li ≤ ri ≤ n) meaning that value <image> should be equal to qi. Your task is to find any interesting array of n elements or state that su...
2
8
#include <bits/stdc++.h> using namespace std; const long long L = 30; const long long INF = 1e9; const long long N = 1e5 + 1; const long long mod = 1e9 + 7; const long double eps = 1E-7; int n, m, now, l[N], r[N], x[N]; int a[N], p[L], d[L][N], t[4 * N]; void bld(int v, int tl, int tr) { if (tl == tr) t[v] = a[tl...
CPP
482_B. Interesting Array
We'll call an array of n non-negative integers a[1], a[2], ..., a[n] interesting, if it meets m constraints. The i-th of the m constraints consists of three integers li, ri, qi (1 ≤ li ≤ ri ≤ n) meaning that value <image> should be equal to qi. Your task is to find any interesting array of n elements or state that su...
2
8
#include <bits/stdc++.h> using namespace std; struct Cond { int l, r, q; }; struct PCond { int type; int p, q; }; bool operator<(const PCond& left, const PCond& right) { if (left.p != right.p) return left.p < right.p; return left.type < right.type; } int build_mask(int* vmask) { int ret = 0; for (int i = ...
CPP
482_B. Interesting Array
We'll call an array of n non-negative integers a[1], a[2], ..., a[n] interesting, if it meets m constraints. The i-th of the m constraints consists of three integers li, ri, qi (1 ≤ li ≤ ri ≤ n) meaning that value <image> should be equal to qi. Your task is to find any interesting array of n elements or state that su...
2
8
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.StringTokenizer; import java.io.IOException; import java.io.BufferedReader; import java.io.FileReader; import java.io.InputStreamReader; import java.io.InputStream; /** * Built using CHelp...
JAVA
482_B. Interesting Array
We'll call an array of n non-negative integers a[1], a[2], ..., a[n] interesting, if it meets m constraints. The i-th of the m constraints consists of three integers li, ri, qi (1 ≤ li ≤ ri ≤ n) meaning that value <image> should be equal to qi. Your task is to find any interesting array of n elements or state that su...
2
8
#include <bits/stdc++.h> using namespace std; const int maxn = 100000 + 10; int n, k; int l[maxn], r[maxn], q[maxn], ans[maxn], sum[maxn]; struct Segment { int val; } tree[maxn * 4]; void built(int v, int l, int r) { if (l + 1 == r) { tree[v].val = ans[l]; return; } else { int mid = (l + r) >> 1; ...
CPP
482_B. Interesting Array
We'll call an array of n non-negative integers a[1], a[2], ..., a[n] interesting, if it meets m constraints. The i-th of the m constraints consists of three integers li, ri, qi (1 ≤ li ≤ ri ≤ n) meaning that value <image> should be equal to qi. Your task is to find any interesting array of n elements or state that su...
2
8
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.InputMismatchException; import java.io.IOException; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at the top */ public class Main { public static...
JAVA
482_B. Interesting Array
We'll call an array of n non-negative integers a[1], a[2], ..., a[n] interesting, if it meets m constraints. The i-th of the m constraints consists of three integers li, ri, qi (1 ≤ li ≤ ri ≤ n) meaning that value <image> should be equal to qi. Your task is to find any interesting array of n elements or state that su...
2
8
//package com.himanshu.practice.july20.hour11; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; /** * Created by himanshubhardwaj on 20/07/18. */ public class InterestingArray { public static void main(String[] args) throws IOException { BufferedReader br ...
JAVA
482_B. Interesting Array
We'll call an array of n non-negative integers a[1], a[2], ..., a[n] interesting, if it meets m constraints. The i-th of the m constraints consists of three integers li, ri, qi (1 ≤ li ≤ ri ≤ n) meaning that value <image> should be equal to qi. Your task is to find any interesting array of n elements or state that su...
2
8
#include <bits/stdc++.h> using namespace std; int dx[] = {0, 0, 1, -1}; int dy[] = {1, -1, 0, 0}; int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1}; int dy8[] = {1, -1, -1, 0, 1, -1, 0, 1}; long long sum[100005 * 4], prop[100005 * 4]; pair<int, pair<int, int> > p[100005]; long long a[100005]; void propagate(int l, int r, int k) ...
CPP
482_B. Interesting Array
We'll call an array of n non-negative integers a[1], a[2], ..., a[n] interesting, if it meets m constraints. The i-th of the m constraints consists of three integers li, ri, qi (1 ≤ li ≤ ri ≤ n) meaning that value <image> should be equal to qi. Your task is to find any interesting array of n elements or state that su...
2
8
#include <bits/stdc++.h> using namespace std; const int mx = 1e5 + 7; struct node { int l, r, q; } a[mx]; int col[mx << 2], lazy[mx << 2]; void push_down(int id) { if (lazy[id]) { lazy[id << 1] |= lazy[id]; lazy[id << 1 | 1] |= lazy[id]; col[id << 1] |= lazy[id]; col[id << 1 | 1] |= lazy[id]; la...
CPP
482_B. Interesting Array
We'll call an array of n non-negative integers a[1], a[2], ..., a[n] interesting, if it meets m constraints. The i-th of the m constraints consists of three integers li, ri, qi (1 ≤ li ≤ ri ≤ n) meaning that value <image> should be equal to qi. Your task is to find any interesting array of n elements or state that su...
2
8
#include <bits/stdc++.h> using namespace std; const int MAXN = 1e5 + 5; const int MAXK = 30; const int MAXST = (1 << (32 - __builtin_clz(MAXN))); const int NEUT = (1 << 30) - 1; struct mon { int v; mon operator+(const mon &o) const { return {v & o.v}; } }; struct queryTyp { int l, r, q; }; int arr[MAXN]; int dp[M...
CPP
482_B. Interesting Array
We'll call an array of n non-negative integers a[1], a[2], ..., a[n] interesting, if it meets m constraints. The i-th of the m constraints consists of three integers li, ri, qi (1 ≤ li ≤ ri ≤ n) meaning that value <image> should be equal to qi. Your task is to find any interesting array of n elements or state that su...
2
8
#include <bits/stdc++.h> using namespace std; long long n, m, l[100005], r[100005], q[100005], chk[33][100005], ans[100005], cur, re[33][100005]; int main() { cin >> n >> m; memset(chk, 0, sizeof(chk)); memset(re, 0, sizeof(re)); for (int ii = 0; ii < m; ii++) { cin >> l[ii] >> r[ii] >> q[ii]; for (...
CPP
482_B. Interesting Array
We'll call an array of n non-negative integers a[1], a[2], ..., a[n] interesting, if it meets m constraints. The i-th of the m constraints consists of three integers li, ri, qi (1 ≤ li ≤ ri ≤ n) meaning that value <image> should be equal to qi. Your task is to find any interesting array of n elements or state that su...
2
8
#include <bits/stdc++.h> using namespace std; const long long int N = 1e5 + 10, N2 = 2e5 + 10, delta = 46639, mod = 1e9 + 7, oo = 1e18, LOG = 20; const long double PI = 3.141592653589793; long long int a[N], n, or1[N << 2], and1[N << 2]; pair<pair<long long int, long long int>, long long int> query[...
CPP
482_B. Interesting Array
We'll call an array of n non-negative integers a[1], a[2], ..., a[n] interesting, if it meets m constraints. The i-th of the m constraints consists of three integers li, ri, qi (1 ≤ li ≤ ri ≤ n) meaning that value <image> should be equal to qi. Your task is to find any interesting array of n elements or state that su...
2
8
import java.io.BufferedReader; import java.io.File; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.Arrays; import java.util.StringTokenizer; public class CF_275D { ...
JAVA
482_B. Interesting Array
We'll call an array of n non-negative integers a[1], a[2], ..., a[n] interesting, if it meets m constraints. The i-th of the m constraints consists of three integers li, ri, qi (1 ≤ li ≤ ri ≤ n) meaning that value <image> should be equal to qi. Your task is to find any interesting array of n elements or state that su...
2
8
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.StringTokenizer; import java.io.IOException; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.InputStream; /** * Built using CHelper plug-in * Actual soluti...
JAVA
482_B. Interesting Array
We'll call an array of n non-negative integers a[1], a[2], ..., a[n] interesting, if it meets m constraints. The i-th of the m constraints consists of three integers li, ri, qi (1 ≤ li ≤ ri ≤ n) meaning that value <image> should be equal to qi. Your task is to find any interesting array of n elements or state that su...
2
8
#include <bits/stdc++.h> const int SZ = 1e5 + 5; using namespace std; int n, m, res[SZ]; int l[SZ], r[SZ], q[SZ]; int d[SZ][33], cumm[SZ][33], cur[33]; int main() { scanf("%d%d", &n, &m); for (int i = 0; i < m; i++) { scanf("%d%d%d", &l[i], &r[i], &q[i]); for (int j = 0; j < 31; j++) if (q[i] & (1 << ...
CPP
482_B. Interesting Array
We'll call an array of n non-negative integers a[1], a[2], ..., a[n] interesting, if it meets m constraints. The i-th of the m constraints consists of three integers li, ri, qi (1 ≤ li ≤ ri ≤ n) meaning that value <image> should be equal to qi. Your task is to find any interesting array of n elements or state that su...
2
8
import java.awt.Point; import java.awt.geom.Line2D; import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; import java.io.FileReader; import java.io.OutputStream; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.security.GuardedObject; im...
JAVA
482_B. Interesting Array
We'll call an array of n non-negative integers a[1], a[2], ..., a[n] interesting, if it meets m constraints. The i-th of the m constraints consists of three integers li, ri, qi (1 ≤ li ≤ ri ≤ n) meaning that value <image> should be equal to qi. Your task is to find any interesting array of n elements or state that su...
2
8
import java.io.*; import java.util.*; public class Main{ final boolean isFileIO = false; BufferedReader in; PrintWriter out; StringTokenizer st = new StringTokenizer(""); String delim = " "; public static void main(String[] args) throws IOException { Main m = new Main(); m.ini...
JAVA
482_B. Interesting Array
We'll call an array of n non-negative integers a[1], a[2], ..., a[n] interesting, if it meets m constraints. The i-th of the m constraints consists of three integers li, ri, qi (1 ≤ li ≤ ri ≤ n) meaning that value <image> should be equal to qi. Your task is to find any interesting array of n elements or state that su...
2
8
#include <bits/stdc++.h> using namespace std; int tree[4 * 100010], arr[4 * 100010], n; void build(int no, int L, int R) { if (L == R) { tree[no] = arr[L]; return; } int nl = 2 * no, nr = 2 * no + 1, mid = (L + R) >> 1; build(nl, L, mid); build(nr, mid + 1, R); tree[no] = tree[nl] & tree[nr]; } void...
CPP
482_B. Interesting Array
We'll call an array of n non-negative integers a[1], a[2], ..., a[n] interesting, if it meets m constraints. The i-th of the m constraints consists of three integers li, ri, qi (1 ≤ li ≤ ri ≤ n) meaning that value <image> should be equal to qi. Your task is to find any interesting array of n elements or state that su...
2
8
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 7; struct tree { int l, r, val; } a[maxn << 2]; int p[maxn], q[maxn], z[maxn], u = 0; void Buildtree(int l, int r, int key) { a[key].l = l; a[key].r = r; a[key].val = 0; if (l == r) return; int mid = (l + r) / 2; Buildtree(l, mid, key <<...
CPP
482_B. Interesting Array
We'll call an array of n non-negative integers a[1], a[2], ..., a[n] interesting, if it meets m constraints. The i-th of the m constraints consists of three integers li, ri, qi (1 ≤ li ≤ ri ≤ n) meaning that value <image> should be equal to qi. Your task is to find any interesting array of n elements or state that su...
2
8
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.StringTokenizer; public class InterestingArray { public static void main(String[] args) throws IOException { Scanner sc= new Scanner(System.in); in...
JAVA
482_B. Interesting Array
We'll call an array of n non-negative integers a[1], a[2], ..., a[n] interesting, if it meets m constraints. The i-th of the m constraints consists of three integers li, ri, qi (1 ≤ li ≤ ri ≤ n) meaning that value <image> should be equal to qi. Your task is to find any interesting array of n elements or state that su...
2
8
#include <bits/stdc++.h> using namespace std; const long long INF = 1000000000 + 7; const double esp = 1e-13; int n, m, xx[100000 + 10][50]; long long f[800000 + 10], a[100000 + 10], s, x[100000 + 10], y[100000 + 10], z[100000 + 10]; void build(int k, int l, int r) { if (l > r) return; if (l == r) { f[k] = ...
CPP
482_B. Interesting Array
We'll call an array of n non-negative integers a[1], a[2], ..., a[n] interesting, if it meets m constraints. The i-th of the m constraints consists of three integers li, ri, qi (1 ≤ li ≤ ri ≤ n) meaning that value <image> should be equal to qi. Your task is to find any interesting array of n elements or state that su...
2
8
//package SegmentFenwick; import java.io.*; import java.util.StringTokenizer; public class practice { public static void main(String[] args) throws IOException, InterruptedException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(br.readLine())...
JAVA
482_B. Interesting Array
We'll call an array of n non-negative integers a[1], a[2], ..., a[n] interesting, if it meets m constraints. The i-th of the m constraints consists of three integers li, ri, qi (1 ≤ li ≤ ri ≤ n) meaning that value <image> should be equal to qi. Your task is to find any interesting array of n elements or state that su...
2
8
import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.InputMismatchException; import java.util.Scanner; public class ProbA { public static int a[][]; public static int b[][]; public static int l[], r[], gt[]...
JAVA
482_B. Interesting Array
We'll call an array of n non-negative integers a[1], a[2], ..., a[n] interesting, if it meets m constraints. The i-th of the m constraints consists of three integers li, ri, qi (1 ≤ li ≤ ri ≤ n) meaning that value <image> should be equal to qi. Your task is to find any interesting array of n elements or state that su...
2
8
#include <bits/stdc++.h> using namespace std; struct Tre { int add, sum; } Tree[400001]; int ans[100001]; struct Node { int l, r, q; } Q[100001]; int x[31], i, j, m, n, p, k, q, l, r, sum; void down(int t) { if (!Tree[t].add) return; Tree[(t << 1)].add |= Tree[t].add; Tree[(t << 1)].sum |= Tree[t].add; Tree...
CPP
482_B. Interesting Array
We'll call an array of n non-negative integers a[1], a[2], ..., a[n] interesting, if it meets m constraints. The i-th of the m constraints consists of three integers li, ri, qi (1 ≤ li ≤ ri ≤ n) meaning that value <image> should be equal to qi. Your task is to find any interesting array of n elements or state that su...
2
8
#include <bits/stdc++.h> const int inf = (1 << 30) - 1; namespace SgT { int n; int L, R, q; int V[100010 << 2], tg[100010 << 2]; inline void pushdown(int rt) { int &x = tg[rt]; V[rt << 1] |= x; V[rt << 1 | 1] |= x; tg[rt << 1] |= x; tg[rt << 1 | 1] |= x; x = 0; } void modify(int rt, int l, int r) { if (L ...
CPP
482_B. Interesting Array
We'll call an array of n non-negative integers a[1], a[2], ..., a[n] interesting, if it meets m constraints. The i-th of the m constraints consists of three integers li, ri, qi (1 ≤ li ≤ ri ≤ n) meaning that value <image> should be equal to qi. Your task is to find any interesting array of n elements or state that su...
2
8
#include <bits/stdc++.h> using namespace std; long long st[300010], lz[300010]; void upd(long long val, long long l, long long r, long long low, long long high, long long i) { if (lz[i]) { st[i] |= lz[i]; if (high != low) { lz[2 * i + 1] |= lz[i]; lz[2 * i + 2] |= lz[i]; } lz[i] =...
CPP
482_B. Interesting Array
We'll call an array of n non-negative integers a[1], a[2], ..., a[n] interesting, if it meets m constraints. The i-th of the m constraints consists of three integers li, ri, qi (1 ≤ li ≤ ri ≤ n) meaning that value <image> should be equal to qi. Your task is to find any interesting array of n elements or state that su...
2
8
import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.StringTokenizer; public class P482B { public static void main(String[] args) { FastScanner scan = new FastScanner(); int n = scan.nextInt(); int m = scan.nextInt(); int[] a = new int[m]; int[] b = ...
JAVA
482_B. Interesting Array
We'll call an array of n non-negative integers a[1], a[2], ..., a[n] interesting, if it meets m constraints. The i-th of the m constraints consists of three integers li, ri, qi (1 ≤ li ≤ ri ≤ n) meaning that value <image> should be equal to qi. Your task is to find any interesting array of n elements or state that su...
2
8
#include <bits/stdc++.h> using namespace std; long long gcd(long long a, long long b) { if (b == 0) return a; return gcd(b, a % b); } long long powx(long long a, long long p) { long long ans = 1; for (int i = 0; i < p; i++) ans *= a; return ans; } int main() { ios_base::sync_with_stdio(false); cin.tie(NUL...
CPP
482_B. Interesting Array
We'll call an array of n non-negative integers a[1], a[2], ..., a[n] interesting, if it meets m constraints. The i-th of the m constraints consists of three integers li, ri, qi (1 ≤ li ≤ ri ≤ n) meaning that value <image> should be equal to qi. Your task is to find any interesting array of n elements or state that su...
2
8
#include <bits/stdc++.h> using namespace std; const int maxn = 100000 + 100; int t[maxn * 8], a[maxn], l[maxn], r[maxn], q[maxn], ans[maxn], n, m; inline int C(int x, int y) { return x & (1 << y); } void build(int l, int r, int p) { if (l == r) { t[p] = ans[l]; return; } int mid = l + r >> 1; build(l, m...
CPP
482_B. Interesting Array
We'll call an array of n non-negative integers a[1], a[2], ..., a[n] interesting, if it meets m constraints. The i-th of the m constraints consists of three integers li, ri, qi (1 ≤ li ≤ ri ≤ n) meaning that value <image> should be equal to qi. Your task is to find any interesting array of n elements or state that su...
2
8
#include <bits/stdc++.h> using namespace std; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); int dx[8] = {1, -1, 0, 0, -1, -1, 1, 1}; int dy[8] = {0, 0, -1, 1, -1, 1, -1, 1}; const long long inf = 998244353; vector<int> adj[200010], vis(200010, 0), par(200010, 0), dis(200010, 0), di(200010, 0)...
CPP
482_B. Interesting Array
We'll call an array of n non-negative integers a[1], a[2], ..., a[n] interesting, if it meets m constraints. The i-th of the m constraints consists of three integers li, ri, qi (1 ≤ li ≤ ri ≤ n) meaning that value <image> should be equal to qi. Your task is to find any interesting array of n elements or state that su...
2
8
#include <bits/stdc++.h> using namespace std; #pragma comment(linker, "/stack:200000000") #pragma GCC optimize("Ofast") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") template <typename T> bool mmax(T &m, const T q) { if (m < q) { m = q; return true; } else return false; }...
CPP
482_B. Interesting Array
We'll call an array of n non-negative integers a[1], a[2], ..., a[n] interesting, if it meets m constraints. The i-th of the m constraints consists of three integers li, ri, qi (1 ≤ li ≤ ri ≤ n) meaning that value <image> should be equal to qi. Your task is to find any interesting array of n elements or state that su...
2
8
#include <bits/stdc++.h> using namespace std; const int N = 200010; int from[N], to[N], num[N]; int s[N][30]; int a[N][30]; int sum[N][30]; int main() { int n, m; scanf("%d %d", &n, &m); for (int i = 0; i <= n; i++) { for (int j = 0; j < 30; j++) { s[i][j] = 0; } } for (int k = 0; k < m; k++) { ...
CPP
482_B. Interesting Array
We'll call an array of n non-negative integers a[1], a[2], ..., a[n] interesting, if it meets m constraints. The i-th of the m constraints consists of three integers li, ri, qi (1 ≤ li ≤ ri ≤ n) meaning that value <image> should be equal to qi. Your task is to find any interesting array of n elements or state that su...
2
8
import java.util.List; import java.io.InputStreamReader; import java.io.IOException; import java.util.Arrays; import java.util.ArrayList; import java.io.BufferedReader; import java.io.OutputStream; import java.io.PrintWriter; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at the t...
JAVA
482_B. Interesting Array
We'll call an array of n non-negative integers a[1], a[2], ..., a[n] interesting, if it meets m constraints. The i-th of the m constraints consists of three integers li, ri, qi (1 ≤ li ≤ ri ≤ n) meaning that value <image> should be equal to qi. Your task is to find any interesting array of n elements or state that su...
2
8
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 5; int c[32][maxn]; int l[maxn]; int r[maxn]; int q[maxn]; int n; int main(void) { memset(c, 0, sizeof(c)); int n, m; scanf("%d%d", &n, &m); for (int i = 1; i <= m; i++) { scanf("%d%d%d", &l[i], &r[i], &q[i]); int x = q[i]; for (in...
CPP
482_B. Interesting Array
We'll call an array of n non-negative integers a[1], a[2], ..., a[n] interesting, if it meets m constraints. The i-th of the m constraints consists of three integers li, ri, qi (1 ≤ li ≤ ri ≤ n) meaning that value <image> should be equal to qi. Your task is to find any interesting array of n elements or state that su...
2
8
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 11; int num[N]; struct Segment { int mark[N << 2]; int x1, y1, ans; int n; void init(int x) { n = x; build(1, 1, n); } void build(int u, int l, int r) { mark[u] = 0; if (l == r) return; build(u << 1, l, ((l + r) >> 1)); ...
CPP
482_B. Interesting Array
We'll call an array of n non-negative integers a[1], a[2], ..., a[n] interesting, if it meets m constraints. The i-th of the m constraints consists of three integers li, ri, qi (1 ≤ li ≤ ri ≤ n) meaning that value <image> should be equal to qi. Your task is to find any interesting array of n elements or state that su...
2
8
#include <bits/stdc++.h> using namespace std; const int mxN = 1e5 + 10; int l[mxN]; int r[mxN]; int q[mxN]; int s[mxN], ss[mxN]; int ans[mxN]; void solve() { int n, m; cin >> n >> m; for (int i = 0; i < m; i++) { cin >> l[i] >> r[i] >> q[i]; l[i]--; r[i]--; } for (int bit = 0; bit < 30; bit++) { ...
CPP
482_B. Interesting Array
We'll call an array of n non-negative integers a[1], a[2], ..., a[n] interesting, if it meets m constraints. The i-th of the m constraints consists of three integers li, ri, qi (1 ≤ li ≤ ri ≤ n) meaning that value <image> should be equal to qi. Your task is to find any interesting array of n elements or state that su...
2
8
import java.io.InputStreamReader; import java.io.IOException; import java.io.FileReader; import java.io.BufferedReader; import java.io.OutputStream; import java.io.PrintWriter; import java.io.Writer; import java.util.StringTokenizer; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is ...
JAVA
482_B. Interesting Array
We'll call an array of n non-negative integers a[1], a[2], ..., a[n] interesting, if it meets m constraints. The i-th of the m constraints consists of three integers li, ri, qi (1 ≤ li ≤ ri ≤ n) meaning that value <image> should be equal to qi. Your task is to find any interesting array of n elements or state that su...
2
8
#include <bits/stdc++.h> struct tree { int l, r; int sum[33]; } tr[444444]; int a; int build(int l, int r, int i) { tr[i].l = l; tr[i].r = r; int j; for (j = 0; j <= 30; j++) tr[i].sum[j] = 0; if (l == r) return 0; int mid = (l + r) / 2; build(l, mid, i * 2); build(mid + 1, r, i * 2 + 1); } int quer...
CPP
482_B. Interesting Array
We'll call an array of n non-negative integers a[1], a[2], ..., a[n] interesting, if it meets m constraints. The i-th of the m constraints consists of three integers li, ri, qi (1 ≤ li ≤ ri ≤ n) meaning that value <image> should be equal to qi. Your task is to find any interesting array of n elements or state that su...
2
8
import java.io.BufferedReader; import java.io.File; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.util.HashSet; import java.util.Set; import java.util.StringToken...
JAVA
482_B. Interesting Array
We'll call an array of n non-negative integers a[1], a[2], ..., a[n] interesting, if it meets m constraints. The i-th of the m constraints consists of three integers li, ri, qi (1 ≤ li ≤ ri ≤ n) meaning that value <image> should be equal to qi. Your task is to find any interesting array of n elements or state that su...
2
8
#include <bits/stdc++.h> using namespace std; bool z[100100][40]; int dp[100100][40]; pair<pair<long long, long long>, long long> q[100100]; int r[300300][35]; int main() { int n, m; cin >> n >> m; for (int i = 0; i < m; i++) { scanf("%I64d%I64d%I64d", &q[i].first.second, &q[i].first.first, &q[i].se...
CPP
482_B. Interesting Array
We'll call an array of n non-negative integers a[1], a[2], ..., a[n] interesting, if it meets m constraints. The i-th of the m constraints consists of three integers li, ri, qi (1 ≤ li ≤ ri ≤ n) meaning that value <image> should be equal to qi. Your task is to find any interesting array of n elements or state that su...
2
8
import java.util.*;import java.io.*;import java.math.*; public class Main { public static void process()throws IOException { int n=ni(); int m=ni(); int[][]A=new int[30][n+1]; int[][]q=new int[m][3]; for(int i=0;i<m;i++) { q[i][0]=ni(); q[i...
JAVA
482_B. Interesting Array
We'll call an array of n non-negative integers a[1], a[2], ..., a[n] interesting, if it meets m constraints. The i-th of the m constraints consists of three integers li, ri, qi (1 ≤ li ≤ ri ≤ n) meaning that value <image> should be equal to qi. Your task is to find any interesting array of n elements or state that su...
2
8
#include <bits/stdc++.h> using namespace std; const int N = 1e6 + 10; struct Tr { int l, r; int sum, add; } tr[N << 1]; void up(int rt) { tr[rt].sum = tr[rt << 1].sum & tr[rt << 1 | 1].sum; } void dwn(int rt) { if (tr[rt].add) { int tmp = tr[rt].add; tr[rt << 1].add = tr[rt << 1].add | tmp; tr[rt << 1...
CPP
482_B. Interesting Array
We'll call an array of n non-negative integers a[1], a[2], ..., a[n] interesting, if it meets m constraints. The i-th of the m constraints consists of three integers li, ri, qi (1 ≤ li ≤ ri ≤ n) meaning that value <image> should be equal to qi. Your task is to find any interesting array of n elements or state that su...
2
8
import java.awt.Point; import java.io.*; import java.math.BigInteger; import java.util.*; import java.text.*; public class cf482b { static BufferedReader br; static Scanner sc; static PrintWriter out; public static void initA() { try { br = new BufferedReader(new InputStreamReade...
JAVA
482_B. Interesting Array
We'll call an array of n non-negative integers a[1], a[2], ..., a[n] interesting, if it meets m constraints. The i-th of the m constraints consists of three integers li, ri, qi (1 ≤ li ≤ ri ≤ n) meaning that value <image> should be equal to qi. Your task is to find any interesting array of n elements or state that su...
2
8
#include <bits/stdc++.h> #pragma GCC optimize("O2") using namespace std; const int N = 1e5 + 1; vector<int> st(4 * N, 0), lazy(4 * N, 0); void prop(int p, int l, int r) { if (lazy[p] == 0) return; st[p] += lazy[p]; if (l != r) lazy[(2 * p + 1)] += lazy[p], lazy[(2 * p)] += lazy[p]; lazy[p] = 0; } void update(in...
CPP
482_B. Interesting Array
We'll call an array of n non-negative integers a[1], a[2], ..., a[n] interesting, if it meets m constraints. The i-th of the m constraints consists of three integers li, ri, qi (1 ≤ li ≤ ri ≤ n) meaning that value <image> should be equal to qi. Your task is to find any interesting array of n elements or state that su...
2
8
#include <bits/stdc++.h> using namespace std; using i64 = long long int; using ii = pair<int, int>; using ii64 = pair<i64, i64>; int bits[32][100005]; int l[100005], r[100005], q[100005]; template <typename T> class SegmentTree { public: void init(vector<T>& raw) { assert(!is_init); is_init = true; n = r...
CPP
482_B. Interesting Array
We'll call an array of n non-negative integers a[1], a[2], ..., a[n] interesting, if it meets m constraints. The i-th of the m constraints consists of three integers li, ri, qi (1 ≤ li ≤ ri ≤ n) meaning that value <image> should be equal to qi. Your task is to find any interesting array of n elements or state that su...
2
8
import java.io.*; import java.text.DecimalFormat; import java.util.*; public class Main { static class SegmentTree { // 1-based DS, OOP int N; // the number of elements in the array as a power of 2 (i.e. after padding) int[] array, sTree, lazy; SegmentTree(int[] in) { array = in; N = in.length - 1; ...
JAVA
482_B. Interesting Array
We'll call an array of n non-negative integers a[1], a[2], ..., a[n] interesting, if it meets m constraints. The i-th of the m constraints consists of three integers li, ri, qi (1 ≤ li ≤ ri ≤ n) meaning that value <image> should be equal to qi. Your task is to find any interesting array of n elements or state that su...
2
8
import java.io.BufferedReader; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.StringTokenizer; public class A { public static void main(String[] args) throws NumberFormatException, IOException...
JAVA
482_B. Interesting Array
We'll call an array of n non-negative integers a[1], a[2], ..., a[n] interesting, if it meets m constraints. The i-th of the m constraints consists of three integers li, ri, qi (1 ≤ li ≤ ri ≤ n) meaning that value <image> should be equal to qi. Your task is to find any interesting array of n elements or state that su...
2
8
#include <bits/stdc++.h> using namespace std; struct SegmentTreeOR { vector<int> t; int size; void init(int n) { size = 1; while (size < n) size *= 2; t.assign(2 * size, 0); } int get(int x, int lx, int rx, int p) { if (rx - lx == 1) { return t[x]; } int mx = (lx + rx) / 2; i...
CPP
482_B. Interesting Array
We'll call an array of n non-negative integers a[1], a[2], ..., a[n] interesting, if it meets m constraints. The i-th of the m constraints consists of three integers li, ri, qi (1 ≤ li ≤ ri ≤ n) meaning that value <image> should be equal to qi. Your task is to find any interesting array of n elements or state that su...
2
8
#include <bits/stdc++.h> using namespace std; template <class T> bool Maximize(T &v, T nv) { if (nv > v) return v = nv, 1; return 0; } template <class T> bool Minimize(T &v, T nv) { if (nv < v) return v = nv, 1; return 0; } template <class T> T Mod(T &v, T mod) { return v = (v % mod + mod) % mod; } const long...
CPP
482_B. Interesting Array
We'll call an array of n non-negative integers a[1], a[2], ..., a[n] interesting, if it meets m constraints. The i-th of the m constraints consists of three integers li, ri, qi (1 ≤ li ≤ ri ≤ n) meaning that value <image> should be equal to qi. Your task is to find any interesting array of n elements or state that su...
2
8
import java.io.*; import java.util.*; public class Main { static PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out)); static BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); static StringTokenizer st = new StringTokenizer(""); static String next() { ...
JAVA
482_B. Interesting Array
We'll call an array of n non-negative integers a[1], a[2], ..., a[n] interesting, if it meets m constraints. The i-th of the m constraints consists of three integers li, ri, qi (1 ≤ li ≤ ri ≤ n) meaning that value <image> should be equal to qi. Your task is to find any interesting array of n elements or state that su...
2
8
import java.io.*; import java.util.*; import static java.lang.Math.*; public class Main extends PrintWriter { BufferedReader in; StringTokenizer stok; final Random rand = new Random(31); final int inf = (int) 1e9; final long linf = (long) 1e18; class SegmentTree { int[] a; int...
JAVA
482_B. Interesting Array
We'll call an array of n non-negative integers a[1], a[2], ..., a[n] interesting, if it meets m constraints. The i-th of the m constraints consists of three integers li, ri, qi (1 ≤ li ≤ ri ≤ n) meaning that value <image> should be equal to qi. Your task is to find any interesting array of n elements or state that su...
2
8
import java.util.*; import java.io.*; public class Solution { public static void main(String[] args) throws IOException, InterruptedException { Scanner sc = new Scanner(System.in); PrintWriter pw = new PrintWriter(System.out); int n = sc.nextInt(); int m = sc.nextInt(); int N = 1; while (N < n) { N *= ...
JAVA
482_B. Interesting Array
We'll call an array of n non-negative integers a[1], a[2], ..., a[n] interesting, if it meets m constraints. The i-th of the m constraints consists of three integers li, ri, qi (1 ≤ li ≤ ri ≤ n) meaning that value <image> should be equal to qi. Your task is to find any interesting array of n elements or state that su...
2
8
import java.io.*; import java.math.*; import java.util.*; import java.util.Map.*; public class Main { public static void main(String[] args) throws IOException { // System.setIn(new FileInputStream("copycat.in"));// 读入文件 // System.setOut(new PrintStream(new FileOutputStream("copycat.out")));// 输出到文件 Scanner sc ...
JAVA
482_B. Interesting Array
We'll call an array of n non-negative integers a[1], a[2], ..., a[n] interesting, if it meets m constraints. The i-th of the m constraints consists of three integers li, ri, qi (1 ≤ li ≤ ri ≤ n) meaning that value <image> should be equal to qi. Your task is to find any interesting array of n elements or state that su...
2
8
#include <bits/stdc++.h> using namespace std; const int INF = 2e9; const long long INFL = 2e18; const int N = 1e5 + 5; int n, m; pair<pair<int, int>, int> a[N]; int s[N], res[N]; const int SZ_ = 4 * N; struct intervalTree { int L[SZ_], H[SZ_], val[SZ_]; void build(int x, int lo, int hi) { L[x] = lo; H[x] = ...
CPP
482_B. Interesting Array
We'll call an array of n non-negative integers a[1], a[2], ..., a[n] interesting, if it meets m constraints. The i-th of the m constraints consists of three integers li, ri, qi (1 ≤ li ≤ ri ≤ n) meaning that value <image> should be equal to qi. Your task is to find any interesting array of n elements or state that su...
2
8
#include <bits/stdc++.h> using namespace std; int l[100005], r[100005], q[100005]; int sum[100005]; int arr[100005]; int Tree[400000]; void build(int ind, int s, int e) { if (s == e) { Tree[ind] = arr[s]; return; } build(ind * 2, s, (s + e) / 2); build(ind * 2 + 1, (s + e) / 2 + 1, e); Tree[ind] = Tre...
CPP