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.IOException; import java.io.InputStreamReader; import java.util.Arrays; import java.util.InputMismatchException; import java.util.ArrayList; import java.io.PrintStream; import java.io.BufferedReader; import java.io.OutputStream; import java.io.PrintWriter; import java.io.Reader; import java.util.TreeSet;...
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 one { int i; int end; bool operator<(const one &e) const { return i < e.i; } }; struct zero { int i, j; }; const int inf = 1e9; class segment { public: vector<int> n, t; segment() { ; } segment(vector<int> &a) : n(a), t(4 * a.size(), 0) { build(0, 0, a...
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.*; import java.util.*; import java.math.*; public class CF483D { static final int N=100005; static int l[]=new int[N]; static int r[]=new int[N]; static int v[]=new int[N]; public static void main(String args[]) { InputReader in=new InputReader(System.in); PrintWriter ...
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> int a[111111][33]; int d[111111][33]; int l[111111]; int r[111111]; int x[111111]; int main() { int t; int i, j, k, n, m; scanf("%d%d", &n, &m); for (i = 1; i <= m; i++) { scanf("%d%d%d", &l[i], &r[i], &x[i]); for (t = 0; t < 32; t++) if ((x[i] >> t) & 1) { a[l[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
/** * 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> using namespace std; int p[100005]; int add[100005]; int f[100005]; int first[100005], second[100005], x[100005]; int find(int x) { return f[x] == x ? x : f[x] = find(f[x]); } int read() { int s = 0; char ch = getchar(); while (ch < '0' || ch > '9') ch = getchar(); while (ch >= '0' && c...
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 gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); } int lcm(long long a, long long b) { return a * (b / gcd(a, b)); } string A; int r[1000001], l[1000001], q[1000001], ans[1000001], a[1000001]; struct node { int x; void merge(node a, node b) { x = a...
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 int tree[400000] = {0}; long long int lazy[400000] = {0}; void update(long long int node, long long int a, long long int b, long long int i, long long int j, long long int val) { if (lazy[node] != 0) { tree[node] |= lazy[node]; if (a != b) { ...
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 i, j, k, n, m, x, z, t, f, dp[100007][35], cp[100007][35], l[100007], r[100007], v[100007]; int main() { cin >> n >> m; for (i = 0; i < m; i++) { cin >> l[i] >> r[i] >> v[i]; for (j = 0; j < 32; j++) { if ((v[i] & (1LL << j)) != 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
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Arrays; import java.util.Scanner; /** * Built using CHelper plug-in * Actual solution is at the top * * @author zodiacLeo */ public class Main { public static void main(String[] ar...
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; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); const long long maxn = 3e5; const long long mod = 1e9 + 7; const long double PI = acos((long double)-1); long long pw(long long a, long long b, long long md = mod) { long long res = 1; while (b) { ...
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 = 100001, B = 30; int l[N], r[N], q[N], a[N], t[4 * N], sum[N]; inline void build(int v, int l, int r) { if (l + 1 == r) { t[v] = a[l]; return; } int mid = (l + r) >> 1; build(v * 2, l, mid); build(v * 2 + 1, mid, r); t[v] = t[v * 2] & t[v * ...
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 R = 1e9 + 7; template <typename T> T last(vector<T>& v) { return v[v.size() - 1]; } template <typename T> void print(vector<T>& v) { for (int i = 0; i < v.size(); i++) { cout << v[i] << ' '; } cout << endl; } template <typename T1, typename T2> void print(ve...
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.*; import java.util.List; public class B { private static StringTokenizer st; private static BufferedReader br; public static int MOD = 1000000007; public static long tenFive = 100000; public static void print(Object x) { System.out.println(x + ""); }...
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 read() { int x = 0, f = 1; char ch = getchar(); while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); } while (ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); } return x * f; } int n, m; int l[100005], r[100...
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 codeforces; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.Comparator; import java.util.HashMap; import java.util.List; import java.uti...
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 max_n = 100010; int arr[31][max_n]; long long q[3][max_n]; int sum[31][max_n]; int main() { int n, m; cin >> n >> m; for (int i = 0; i < m; i++) { long long r, l, val; cin >> l >> r >> val; q[0][i] = l; q[1][i] = r; q[2][i] = val; 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 int maxn = 100050; int a[maxn][32]; int l[maxn], r[maxn], q[maxn]; int cnt[maxn][32]; int main() { int n, m; scanf("%d%d", &n, &m); for (int i = 0; i < m; ++i) scanf("%d%d%d", &l[i], &r[i], &q[i]); for (int i = 0; i < m; ++i) { for (int j = 0; j < 30; ++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> using namespace std; const int MAXN = 10 + 100000; const int INF = int(1e9); int n, m; int l[MAXN], r[MAXN], q[MAXN]; void input() { ({ int neg = 0; n = 0; char ch; for (ch = getchar(); ch < '0' || ch > '9'; ch = getchar()) if (ch == '-') neg = 1; n = ch - 48; fo...
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 dr[] = {-1, 1, 0, 0, -1, -1, 1, 1}; const int dc[] = {0, 0, 1, -1, -1, 1, -1, 1}; const int MOD = 1e9 + 7; const int INF = 1e9; const int N = 1e5 + 5; const long double pi = acos(-1); const double eps = 1e-9; struct query { int l, r, q; }; bool cmp(query x, 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
#include <bits/stdc++.h> using namespace std; const int INF = (int)1e9 + 7; const int MXN = (int)1e5 + 7; int n, m; int a[MXN][31], s[MXN][31], ps[MXN][31]; int l[MXN], r[MXN], q[MXN]; int main() { ios_base::sync_with_stdio(0); cin >> n >> m; for (int i = 1; i <= m; i++) { cin >> l[i] >> r[i] >> q[i]; 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
# Legends Always Come Up with Solution # Author: Manvir Singh import os from io import BytesIO, IOBase import sys from collections import defaultdict, deque, Counter from math import sqrt, pi, ceil, log, inf, gcd, floor from itertools import combinations, permutations from bisect import * from fractions import Fractio...
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; struct pot { int x, y, d[31]; }; pot a[200020]; int dig[200020][30], sum[200020][30], n, ans[200020], m, k, l; bool f; bool cmp(pot u, pot v) { return (u.x < v.x); } int main() { scanf("%d%d", &n, &m); for (int i = 1; i <= m; i++) { scanf("%d%d%d", &a[i].x, &a[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; long long lo[4 * 100100 + 1], hi[4 * 100100 + 1], tree[4 * 100100 + 1], delta[4 * 100100 + 1]; void init(int i, int l, int r) { lo[i] = l; hi[i] = r; if (l == r) return; int m = (l + r) / 2; init(2 * i, l, m); init(2 * i + 1, m + 1, r); } void prop...
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 GCC optimize("Ofast") #pragma GCC optimize("unroll-loops") using namespace std; const int mn = 1e5 + 1; int n, m, tree[mn * 4][30]; struct query { int l, r, k; } queries[mn]; void update(int id, int l, int r, int x, int y, int type) { if (l > y || r < x) { return; } 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
import java.io.BufferedInputStream; import java.io.BufferedOutputStream; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.Scanner; import java.util.StringTokenizer; public class Main { public static 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
#include <bits/stdc++.h> const int MAXN = 1e5 + 10; const int MOD = 2333; const double eps = 1e-6; using namespace std; int bit[MAXN << 2], AND[MAXN << 2], l[MAXN], r[MAXN], q[MAXN]; void pushdown(int rt) { if (bit[rt]) { bit[rt << 1] |= bit[rt]; bit[rt << 1 | 1] |= bit[rt]; AND[rt << 1] |= bit[rt]; A...
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 SegTree { int n; vector<unsigned int> t1, t2; SegTree(int n_) { n = 1; while (n < n_) n <<= 1; t1.resize(2 * n - 1, 0); t2.resize(2 * n - 1, 0); } void update(int k) { t1[k] = (t1[2 * k + 1] | t2[2 * k + 1]) & (t1[2 * k + 2] | t2[2 * 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 long long maxn = 3e5 + 100; const long long mod = 1e9 + 7; const long long INF = 1e9 + 7; const long long mlog = 22; const long long SQ = 400; long long n, m; long long seg[maxn * 4]; long long l[maxn], r[maxn], q[maxn]; long long a[maxn]; long long lg[maxn]; long lon...
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; int a[100005]; int l[100005], r[100005], q[100005]; int sgn[100005], pr[100005]; bool ok[100005]; void die() { cout << "NO\n"; exit(0); } int main() { ios_base::sync_with_stdio(0); cin >> n >> m; for (int i = 1; i <= m; i++) cin >> l[i] >> r[i] >> q[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.util.*; import java.math.*; import java.io.*; import static java.lang.Math.*; import static java.util.Arrays.*; import static java.util.Collections.*; public class Main{ // ArrayList<Integer> lis = new ArrayList<Integer>(); // ArrayList<String> lis = new ArrayList<String>(); // PriorityQueue<P> que...
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.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.Arrays; import java.util.StringTokenizer; public class Main { public static void main(String[] args) throws NumberFormatException, IOExceptio...
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; public class B { static int[] tree; static int[] lazy; static void refresh(int idx) { if (lazy[idx] != 0) { tree[idx] |= lazy[idx]; if (idx * 2 < tree....
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.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.StringTokenizer; public class D { static int mo7ayed = (1 << 31) - 1; public static void main(String[] args) throws Exception { Scanner sc = new...
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.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.Arrays; import java.util.StringTokenizer; public class CF_275_Div1_InterestingArray { public static void main(String[] args) throws 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; inline void ri(int& x) { scanf("%d", &x); } class FenwickTree { private: vector<int> ft; void update(int pos, int val) { while (pos < ft.size()) { ft[pos] += val; pos += pos & (-pos); } } public: FenwickTree() {} FenwickTree(int n) { ft.assi...
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 GCC optimize("Ofast") #pragma GCC optimize("unroll-loops") #pragma GCC target("sse4") using namespace std; long long dp[100005][35]; long long val[100005][35]; long long a[100005][35]; struct node { long long l, r, q; }; int32_t main() { ios_base::sync_with_stdio(0); cin.tie(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; const int N = 1e6 + 100, B = 30; int L[N], R[N], X[N]; int A[N], res[N]; int main() { ios::sync_with_stdio(0); cin.tie(0); int n, q; cin >> n >> q; for (int i = 1; i <= q; i++) { cin >> L[i] >> R[i] >> X[i]; } for (int bit = B - 1; bit >= 0; bit--) { 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; template <class T> T pmax(T a, T b) { return max(a, b); } const long long int mod = 1e9 + 7; const long long int Maa = 3e5; vector<long long int> edge[Maa]; long long int n, m, l[Maa], r[Maa], q[Maa], A[Maa], p[Maa], c[Maa]; int main() { cin >> n >> m; for (int i = 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; const int MAXN = 1e5 + 5; const int MAXB = 30; int ls[MAXN], rs[MAXN], qs[MAXN], out[MAXN]; int res[MAXN]; int main(void) { int n, m; scanf("%d", &(n)); scanf("%d", &(m)); vector<pair<int, int> > intv[MAXN]; for (int i = 0; i < m; i++) { scanf("%d", &(ls[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 InterestingArray { public static void main(String[] args) throws Exception{ BufferedReader f = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(f.readLine()); int n = Integer.parseInt(st.nextToken()); 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
#include <bits/stdc++.h> using namespace std; int arr[100002][30], res[100002][30], cnt[100002][30]; int l[100002], r[100002], q[100002]; int main() { int n, m; 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 < 30; 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.io.*; import java.util.*; public class Main { public static void main(String[] args) { Scanner s = new Scanner(System.in); int n = s.nextInt(), m = s.nextInt(); Condition[] c = new Condition[m]; for (int i = 0; i < m; i++) { c[i] = new Condition(s.nextInt() -...
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 lend = '\n'; const int N = 100000, M = 30; int vet[N][M], n, m, l[N], r[N], x[N]; void first(int b) { set<int> s; for (int i = 0; i < n; ++i) s.insert(i); for (int i = 0; i < m; ++i) if (x[i] >> b & 1) { auto it = s.lower_bound(l[i]); while ...
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]; void tree(int n, int 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++) { scanf("%d %d %d", fro...
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; vector<pair<pair<int, int>, int> > vec; int tree[4 * 100011]; int arr[30][100011]; int n, k; int ans[100011]; int build(int node, int b, int e) { if (b == e) { return tree[node] = ans[b]; } int mid = (b + e) >> 1; int l = node << 1; int r = l + 1; int p = bu...
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 rnd(239); const int N = 100001; int a[2 * N]; int t[2 * N]; void prop(int i) { t[i] |= t[i >> 1]; t[i ^ 1] |= t[i >> 1]; } void f(int ls, int rs, int x) { for (int l = ls + N, r = rs + N; l <= r; l = l + 1 >> 1, r = r - 1 >> 1) { if (l & 1) { 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
#include <bits/stdc++.h> using namespace std; class SGTreeLazy { long long int size; vector<long long int> arr; public: vector<long long int> result; SGTreeLazy(long long int s) { size = s; arr.resize(4 * s, 0); } void build(long long int x, vector<long long int> &a, long long 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
#include <bits/stdc++.h> using namespace std; const int maxn = 100010; const int maxm = 200010; const int inf = 1e9; int n, m; int a[maxn]; int b[maxn]; int r1[maxn]; int r2[maxn]; int r3[maxn]; struct Node { int l; int r; int val; int re; } Tree[maxn << 2]; void BuildTree(int left, int right, int rt) { 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> using namespace std; const int N = 111111; int req[N][32], c[N][32]; int s[32]; int ans[N]; int main() { int n, m; scanf("%d%d", &n, &m); vector<pair<int, pair<int, int> > > z; for (int i = 0; i < m; ++i) { int l, r, q; scanf("%d%d%d", &l, &r, &q); for (int j = 0; j < 30; ++...
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; vector<int> seg1; void update(int st, int en, int i, int val, int l, int r) { if (r < st || en < l) return; if (l <= st && en <= r) { seg1[i] |= val; return; } int mid = (st + en) / 2; update(st, mid, (2 * i), val, l, r); update(mid + 1, en, (2 * 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
#include <bits/stdc++.h> #pragma warning(disable : 4996) #pragma comment(linker, "/STACK:336777216") using namespace std; inline long long gcd(long long a, long long b) { if (a == 0) return b; return gcd(b % a, a); } inline long long power(long long a, long long n, long long m) { if (n == 0) return 1; long 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
#include <bits/stdc++.h> using namespace std; const int lim = 1e5 + 5; int arr[lim][31], qur[lim][3], fin[lim], seg[4 * lim], q, n; void make() { cin >> n >> q; for (int i = 0; i < q; ++i) { cin >> qur[i][0] >> qur[i][1] >> qur[i][2]; for (int j = 0; j < 31; ++j) if ((qur[i][2] >> j) & 1) arr[qur[i][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> #pragma GCC optimize("Ofast") using namespace std; int n; class bit { public: int s[200005]; void up(int p, int x) { while (p <= n) { s[p] += x; p += p & -p; } } int get(int p) { int re = 0; while (p) { re = re + s[p]; p -= p & -p; } retu...
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.Arrays; 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...
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 static java.lang.System.in; import static java.lang.System.out; import java.io.*; import java.util.*; public class B482bitSegmentTree { static final double EPS = 1e-10; static final int INF = (1 << 30)-1; static final double PI = Math.PI; public static Scanner sc = new Scanner(in); StringBuilder sb = new...
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.OutputStreamWriter; import java.io.BufferedWriter; import java.io.OutputStream; import java.io.PrintWriter; import java.io.Writer; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at the top * @author Mahmoud Aladdin <aladdin3> */ public ...
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[100005][30]; int n, q, s[100005], e[100005], x[100005]; int main() { scanf("%d %d", &n, &q); for (int i = 0; i < q; i++) { scanf("%d %d %d", &s[i], &e[i], &x[i]); for (int j = 0; j < 30; j++) { if ((x[i] >> j) & 1) { dx[s[i]][j]++; d...
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 Solution{ public static int n,m; public static int[] l; public static int[] r; public static int[] q; public static int[][] a; public static int[][] beg; public static int[][] end; public static int k; public stat...
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 = (int)1e5 + 10; const int MOD = (int)1e9 + 7; int rs[MAXN * 4], vl[MAXN * 4]; void update(int l, int r, int x, int y, int z, int rt) { if (l == x && r == y) { vl[rt] |= z; return; } int mid = l + r >> 1; if (mid >= y) update(l, mid, x, y,...
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 long long maxn = 1e5 + 9, modn = 1e9 + 7; using namespace std; long long n, m, l[maxn], r[maxn], q[maxn], s[4 * maxn], a[maxn]; void query(long long x, long long y, long long q, long long v = 1, long long l = 0, long long r = n) { if (x >= r || y <= l) return; if (l >= 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; struct dat { int L, R, V; } a[100005]; int N, M; bool cmp(dat a, dat b) { if (a.L != b.L) return a.L < b.L; if (a.R != b.R) return a.R < b.R; return a.V < b.V; } int ans[100005], s[100005]; void build(int k) { int last = 0; for (int i = (1), _b = (M); i <= _b; 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; const int N = 100010, D = 30; int n, m, c[D], a[N]; int l[N], r[N], q[N], s[N][D]; vector<int> p[N], k[N]; int main() { scanf("%d %d", &n, &m); for (int i = 1; i <= m; i++) { scanf("%d %d %d", &l[i], &r[i], &q[i]); p[l[i]].push_back(q[i]); k[r[i]].push_back(...
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 ar[101000], a, b, c, n, m; vector<pair<pair<int, int>, int> > V; vector<pair<int, pair<int, int> > > A; int ans[101000]; bool cari(int k) { A.clear(); for (int i = 0; i < V.size(); i++) if ((1 << k) & (V[i].second)) A.push_back(make_pair(1, V[i].first)); ...
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.BufferedReader; import java.io.OutputStream; import java.io.PrintWriter; import java.util.StringTokenizer; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at the top * @author Rubanenko */ public class M...
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 sequence { int t[100010], s[100010]; inline void insert(int l, int r) { t[l]++; t[r + 1]--; } inline void modify(int n) { for (int i = 1; i <= n; i++) t[i] += t[i - 1]; for (int i = 1; i <= n; i++) t[i] = t[i] > 0; for (int i = 1; i <= n; i++) s[i] = s[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
#include <bits/stdc++.h> using namespace std; long long gcd(long long x, long long y) { if (x == 0) return y; return gcd(y % x, x); } long long powmod(long long x, long long y, long long m) { if (y == 0) return 1; long long p = powmod(x, y / 2, m) % m; p = (p * p) % m; return (y % 2 == 0) ? p : (x * p) % 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
import java.io.BufferedInputStream; import java.io.BufferedOutputStream; import java.io.PrintWriter; import java.util.Scanner; public class Main{ public static void main(String[] args) { Scanner in = new Scanner(new BufferedInputStream(System.in)); PrintWriter out = new PrintWriter(new BufferedOutputStream(Syste...
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.Arrays; import java.util.StringTokenizer; public class Main { public static void main(String[]args) throws IOException { Scanner sc = new Scanner(System.in); PrintWriter out = new PrintWriter(System.out); StringBuilder sb = new StringBuilder(); 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; class Node { public: int left; int right; int value; }; class segTree { public: Node *tree; int length; segTree(int length) { this->length = length; tree = new Node[length * 4]; createTree(0, 0, length - 1); } void createTree(int root, int left...
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 class InputReader { public BufferedReader reader; public StringTokenizer tokenizer; public InputReader(InputStream stream) { reader = new BufferedReader(new InputStreamReader(stream), 32768); tokenizer...
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; const long long INF = (1ll << 32) - 1; long long sum[maxn << 2], add[maxn << 2]; int n, m; struct Node { int l, r; long long q; } nd[maxn]; void Pushup(int root); void Pushdown(int root); void update(long long q, int L, int R, int left, int rig...
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 double eps = 1e-9; const int mod = (int)1e+9 + 7; const double pi = acos(-1.0); unsigned int t[32][100100]; bool x[100100]; unsigned int z[2 * 131072], k = 131072; struct zp { unsigned int l, r, q; } zap[100100]; unsigned int getand(unsigned int l, unsigned int 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
#include <bits/stdc++.h> using namespace std; int main() { int n, m; pair<pair<int, int>, int> a[101010]; cin >> n >> m; int x, y, z; for (int i = 1; i <= m; i++) { cin >> x >> y >> z; pair<int, int> p = make_pair(x, y); pair<pair<int, int>, int> q = make_pair(p, z); a[i] = q; } bool ok = ...
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 _ { ios_base::Init i; _() { cin.sync_with_stdio(0); cin.tie(0); } } _; int n, m; const int N = 100 * 1000 + 1; int l[N], r[N], q[N], sum[N]; int MAXBIT = 30; int main() { cin >> n >> m; for (int i = 0; i < m; ++i) { cin >> l[i] >> r[i] >> q[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 Main { static PrintWriter pw; static Scanner sc; static int[] a, b, dp[]; static long ceildiv(long x, long y){ return (x+y-1)/y;} public static void main(String[] args) throws Exception { sc = new Scanner(System.in); pw = new Print...
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
/** * Created by Aminul on 10/28/2017. */ import java.io.*; import java.util.*; public class CF482B { public static void main(String[] args) throws Exception { FastReader in = new FastReader(System.in); PrintWriter pw = new PrintWriter(System.out); int n = in.nextInt(), k = in.nextInt();...
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 java.math.*; public class CF483D { static final int N=100005; static int l[]=new int[N]; static int r[]=new int[N]; static int v[]=new int[N]; public static void main(String args[]) { InputReader in=new InputReader(System.in); PrintWriter ...
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 a[100009][30]; int b[100009][30]; int c[30]; void solve() { int n, m; cin >> n >> m; int mark[m][3]; c[0] = 1; for (int i = 0; i < m; i++) { cin >> mark[i][0] >> mark[i][1] >> mark[i][2]; int ele = mark[i][2]; int ind = 0; int x = mark[i][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> const int N = 100100; int n, m, l[N], r[N], q[N], c[N], s[N], a[N], f; int go(int b) { memset(c, 0, sizeof(c)); for (int i = 0; i < m; ++i) if (q[i] & b) ++c[l[i]], --c[r[i] + 1]; for (int i = 1; i <= n; ++i) c[i] += c[i - 1], s[i] = s[i - 1] + (c[i] < 1), a[i] |= c[i] ? b : 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; const int INF = (1LL << 31) - 1; const long long int LINF = (1LL << 62) - 1; const int NMAX = 100000 + 5; const int MMAX = 100000 + 5; const int KMAX = 100000 + 5; const int PMAX = 100000 + 5; const int LMAX = 100000 + 5; const int VMAX = 100000 + 5; int N, M; int L[NMAX]; ...
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 { // main public static void main(String [] args) throws IOException { // makes the reader and writer BufferedReader f = new BufferedReader(new InputStreamReader(System.in)); PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));...
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 <class T> inline T poww(T b, T p) { long long a = 1; while (p) { if (p & 1) { a = (a * b); } p >>= 1; b = (b * b); } return a; } template <class T> inline T poww2(T b, int p) { T a = 1; while (p) { if (p & 1) { a = (a * b...
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
#include <bits/stdc++.h> const int N = 1000 * 1000; const int MAXBIT = 30; int l[N], r[N], q[N], a[N], t[4 * N]; int sum[N]; inline void build(int v, int l, int r) { if (l + 1 == r) { t[v] = a[l]; return; } int mid = (l + r) >> 1; build(v * 2, l, mid); build(v * 2 + 1, mid, r); t[v] = t[v * 2] & t[v...
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 int t[100100 * 4], lz[100100 * 4]; pair<pair<int, int>, int> qr[100100]; void update(int node, int st, int en, int l, int r, int q) { t[node] = t[node] | lz[node]; if (st != en) { lz[node * 2 + 1] = lz[node] | lz[node * 2 + 1]; lz[node * 2 + 2] = lz[no...
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[100010], r[100010], n, m; ; long long val[100010], num[100010][30], a[100010][30]; int main() { cin >> n >> m; for (int i = 0; i < m; i++) { cin >> l[i] >> r[i] >> val[i]; for (int j = 0; j < 30; j++) if ((val[i] & (1 << j)) != 0) { a[l[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> using namespace std; const double eps = 1e-9; const double pi = acos(-1.0); int a[32][101111], n, m, d[32][111111], b[111111], t[400111]; pair<pair<int, int>, int> p[111111]; int bit(int mask, int i) { return (mask & (1 << i)) > 0; } void build(int v, int tl, int tr) { if (tl == tr) t[v] ...
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 + 5; const int INF = 0x3f3f3f3f; int n, m; int L[MX], R[MX], Q[MX], A[MX]; bool ok[32][MX << 2]; int cnt[32][MX]; void update(int L, int R, int id, int l, int r, int rt) { if (L <= l && r <= R) { ok[id][rt] = 1; return; } int m = (l + 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
#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
// package CodeForces; import java.io.*; import java.util.*; public class Problem_482B { public static void main(String[] args) throws IOException { Scanner sc = new Scanner(); PrintWriter pw = new PrintWriter(System.out); int n=sc.nextInt(),q=sc.nextInt(); SegmentTree sgt=new SegmentTree(n); Triple[]query...
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; 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> int n, m; int a[100010]; int queryL[100010], queryR[100010], b[100010]; int s[30][100010]; int data[400010]; void build(int p, int L, int R) { if (L == R) { data[p] = a[L]; return; } int mid = L + R >> 1; build(p << 1, L, mid); build(p << 1 | 1, mid + 1, R); data[p] = data[p...
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.math.BigInteger; import java.util.ArrayList; import java.util.Arrays; import java.util.LinkedList; import java.util.Queue; import java.util.Stack; import jav...
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.OutputStreamWriter; import java.io.PrintWriter; import java.util.StringTokenizer; public class Solver { public static void main(String[] Args) 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 long long D = 31; const long long N = 100010; struct constraint { long long l, r, q; constraint(long long _l, long long _r, long long _q) { l = _l; r = _r; q = _q; } }; void err() { cout << "NO" << '\n'; exit(0); } long long n, m; long long a[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
#include <bits/stdc++.h> using namespace std; int n, m; int l[100005], r[100005], q[100005]; struct node { int v, add; }; node t[4 * 100005]; const int MX = (1LL << 31) - 1; void Push(int v, int tl, int tm, int tr) { if (t[v].add != 0) { t[2 * v].add |= t[v].add; t[2 * v].v |= t[v].add; t[2 * v + 1].add...
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 javafx.util.*; public class Solution { public static void main(String []args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); HashMap<Pair<Integer,Integer> , Long> map = new HashMap<Pair<Integer,Integer> , 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; int n, m; int l[112345], r[112345], q[112345]; int prefix[31][112345], s[31][112345], cnt[31][112345]; int main() { ios_base::sync_with_stdio(false); cin >> n >> m; for (int i = 0; i < m; ++i) cin >> l[i] >> r[i] >> q[i]; for (int i = 0; i < m; ++i) { for (int b...
CPP