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.*; import java.lang.reflect.Array; import java.math.BigDecimal; import java.math.MathContext; import java.math.RoundingMode; import java.util.*; public class Main implements Runnable { private class Query { private int id; private int l; private int r; private int q; ...
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 = 1e5; const int M = 1e5; const int LG = 30; bool checkbit(int x, int i) { return (x >> i) & 1; } struct SEGTREE { bool tree[4 * N + 7]; bool lazy[4 * N + 7]; void flex(int ss, int se, int si) { if (lazy[si] == 1) { if (ss != se) { lazy[s...
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 queries[100005][3]; vector<pair<int, int> > ones; vector<pair<int, int> > zeros; int arr[100005]; int tree[2000000]; int lazy[2000000]; void init(int node, int l, int r) { lazy[node] = 0; tree[node] = 0; if (l != r) { int mid = (l + r) / 2; init(2 * node +...
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; const int len = 1e5 + 9; int a[len]; int b[len]; int c[len]; int freq[len]; int res[len]; int pt[31]; int last = (1 << 17); struct segmentTree { struct node { int value = 0; bool lazy = 0; }; node tree[1 << 18]; bool insert_(int l, int r, int now =...
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<long long, pair<long long, long long> > > t; long long cnt[100002][32]; long long left_zero[100002][32]; vector<pair<long long, pair<long long, long long> > > ans; int main() { memset(cnt, 0, sizeof(cnt)); long long n, m; cin >> n >> m; for (long long 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.*; import java.lang.*; import java.math.BigInteger; import java.util.Map.Entry; import java.util.logging.Level; import java.util.logging.Logger; public class Main { static StringTokenizer st=new StringTokenizer(""); static BufferedReader br; static int n,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
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 maxn = 100000 + 10; int node[maxn * 4] = {}, ql, qr, qv, fg[maxn * 4] = {}; void update(int o, int l, int r) { if (l >= ql && r <= qr) { fg[o] |= qv; return; } int m = (l + r) >> 1; if (ql <= m) update(o << 1, l, m); if (qr > m) update((o << 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> int n, m, seg[300005], lazy[300005], d[200005], l[200005], r[200005], q[200005]; bool b = 1; void update(int root, int lo, int hi, int l, int r, int val) { if (lazy[root]) { seg[root] |= lazy[root]; if (lo ^ hi) { lazy[root * 2 + 1] |= lazy[root]; lazy[root * 2 + 2] |= laz...
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
# by the authority of GOD author: manhar singh sachdev # import os,sys from io import BytesIO, IOBase def main(): n,m = map(int,input().split()) dp = [[0]*30 for _ in range(n+2)] op = [] for _ in range(m): op.append(tuple(map(int,input().split()))) l,r,q = op[-1] mask,cou =...
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
import java.io.*; import java.util.*; public final class interesting_array { static BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); static FastScanner sc=new FastScanner(br); static PrintWriter out=new PrintWriter(System.out); static Random rnd=new Random(); static int[][] arr; stati...
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; ifstream fin("in.in"); ofstream fout("out.out"); const int N = 1e5 + 10; long long n, m, a[N], bit[N][40], pw[40], node[N << 2], s[40], l[N], r[N], x[N]; void buildTree(int s, int e, int tag) { if (s + 1 == e) { node[tag] = a[s]; return; } int mid = (s + e) >>...
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 Fenwick { public: Fenwick(int size) { storage.resize(size + 1); n = size; } void update(int i, int val) { for (; i <= n; i += i & -i) storage[i] += val; } int sum(int i) { int result = 0; for (; i > 0; i -= i & -i) result += storage[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.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
import java.io.*; import java.util.*; public class Main { public static void main(String[] args) throws Exception { InputStream inputStream = System.in; OutputStream outputStream = System.out; InputReader in = new InputReader(inputStream); PrintWriter out = new PrintWriter(outputStream); Solver s...
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.DataInputStream; import java.io.FileInputStream; import java.io.IOException; import java.io.PrintWriter; import java.util.Arrays; // this is not good for reading double values. public class Problem482B { static long m = 100000007; static long[] a; public static void main(String[] args) throws IOExce...
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.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.math.BigInteger; import java.util.ArrayList; import java.util.Arrays; import java.util.Bit...
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.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.math.BigInteger; import java.util.StringTokenizer; public class Main { public static void main(String[] args){ new CF482B().solve() ; } } class CF482B{ InputReader in = new Inp...
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 D { class IntervalTree { int[] d; int neutral; boolean and; int cnt = 0; int n; public IntervalTree(int n, boolean and) { this.and = and; neutral = and ? Integer.MAX_VALUE : 0; 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.util.*; import java.io.*; public class Main{ BufferedReader in; StringTokenizer str = null; PrintWriter out; private String next() throws Exception{ while (str == null || !str.hasMoreElements()) str = new StringTokenizer(in.readLine()); return str.nextToken(); } ...
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; vector<int> sTree; void build(int left, int right, int ind, vector<int> &arr) { if (left == right) { sTree[ind] = arr[left]; return; } int lTree = ind * 2, rTree = lTree + 1; int mid = (left + right) / 2; build(left, mid, lTree, arr); build(mid + 1, righ...
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.InputStreamReader; import java.io.PrintWriter; import java.util.Arrays; import java.util.Collection; import java.util.StringTokenizer; import java.util.stream.Stream; public class CP implements Runnable { static final Reader in = new Reade...
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, q, l[1010000], r[1010000], a[1010000], ans, L, R, A; struct node { int f, w; } tree[1010000 * 4]; template <typename T> void read(T &x) { x = 0; char c = getchar(); int f = 1; for (; !isdigit(c); c = getchar()) if (c == '-') f = -1; for (; isdigit(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
import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.InputMismatchException; public class D { public static void main(String[] args) { InputReader in = new InputReader(System.in); PrintWriter out = new PrintWriter(System.out); int n = in.read...
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 TValue, class TDelta> struct SegmentTree { public: int sz; TValue *t; TDelta *d; const bool rangeUpdates; const TValue neutralValue; const TDelta neutralDelta; const function<TValue(TValue const &, TValue const &)> combineValues; const funct...
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 Query { int l, r, q; } q[100005], q0[100005], q1[100005]; int a[100005], ev1_l[100005], ev1_r[100005], cont[100005], resp[100005]; pair<int, int> ev0_l[100005], ev0_r[100005]; int main() { int n, m; cin >> n >> m; for (int i = 0; i < m; i++) { scanf("%d%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.io.BufferedReader; import java.io.BufferedWriter; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.util.StringTokenizer; public class B { static StringTokenizer st; static BufferedReader br; static PrintWr...
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 CF_483_D_INTERESTING_ARRAY { public static void main(String[] args) throws Exception { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int m = sc.nextInt(); SegmentTree st = new SegmentTree(n + 1); Triple[] queries = new Triple[m]; for (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.io.*; import java.util.*; public class D { class IntervalTree { int[] d; int neutral; boolean and; int cnt = 0; int n; public IntervalTree(int n, boolean and) { this.and = and; neutral = and ? Integer.MAX_VALUE : 0; 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
#include <bits/stdc++.h> const int MAXN = 1e5 + 5; struct SegmentTree { int sm[MAXN << 2], tag[MAXN << 2]; inline void cover(int x, int l, int r, int d) { sm[x] |= d; tag[x] |= d; } inline void pushdown(int x, int l, int r) { if (tag[x]) { int mid = (l + r) >> 1; cover(((x) << 1), l, mid...
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.IOException; import java.io.InputStreamReader; import java.io.FileReader; import java.util.Arrays; 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-...
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> namespace chtholly { inline int read() { int x = 0, f = 1; char c = getchar(); for (; !isdigit(c); c = getchar()) f ^= c == '-'; for (; isdigit(c); c = getchar()) x = (x << 3) + (x << 1) + (c ^ '0'); return f ? x : -x; } inline bool read(long long &x) { x = 0; int f = 1; char 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; struct pt { int p; int value; bool nd; }; int l[100005], r[100005], q[100005], n, m, p; int a[500005] = {0}; pt v[200005]; int bits[32] = {0}; int build_tree(int n) { int j = 1; while (j < n) j *= 2; for (int i = 0; i <= 2 * j; ++i) a[i] = (1 << 30) - 1; 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.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 A { static public class SegmentTree { // 1-based DS, OOP int N; //the number of elements ...
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.InputStream; import java.io.InputStreamReader; import java.io.BufferedReader; import java.io.OutputStream; import java.io.PrintWriter; import java.io.IOException; import java.util.StringTokenizer; public class D483 { public static BufferedReader in; public static PrintWriter out; public st...
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 B { public static void main(String[] args) throws Exception { new B().solve(); } void solve() throws IOException { FastScanner in = new FastScanner(System.in); n = in.nextInt(); int m = in.nextInt(); int[][] d = 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.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.HashSet; import java.util.Stack; public class Main { static final int SIZE = (int) Math.pow(2, 17); static final 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; const long long N = 1e5 + 10, mod = 1e9 + 7; long long tree[4 * N], lazy[4 * N], n, m, l[N], r[N], q[N]; void updateRange(int node, int start, int end, int l, int r, int val) { if (lazy[node] != 0) { tree[node] |= lazy[node]; if (start != end) { lazy[node * ...
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 optimization_level 3 using namespace std; using ll = long long; using ld = long double; const ll MOD = 1e+9 + 7; const ll INF = LLONG_MAX; const int N = (int)2e+5 + 8; ll n, m, a[N], l[N], r[N], x[N]; ll pre[50][N]; void MAIN(int tc) { cin >> n >> m; for (int i = 1; i <= m; 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.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
/** * ******* Created on 27/4/20 1:53 PM******* */ import java.io.*; import java.util.*; public class B482 implements Runnable { private static final int MAX = (int) (1E5 + 5); private static final int MOD = (int) (1E9 + 7); private static final long Inf = (long) (1E14 + 10); private static final ...
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 { // 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> void debug(T a, T b) { ; } template <class T> void chmin(T& a, const T& b) { if (a > b) a = b; } template <class T> void chmax(T& a, const T& b) { if (a < b) a = b; } namespace std { template <class S, class T> ostream& operator<<(ostream& out, cons...
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() { vector<int> ors[32], lastZero[32], a, l, r, q; int n, m; cin >> n >> m; a.resize(n + 1); for (__typeof(32) i = 0; i < 32; ++i) ors[i].resize(n + 2), lastZero[i].resize(n + 1); l.resize(m), r.resize(m), q.resize(m); for (__typeof(m) p = 0; 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.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.util.Scanner; public class D { private Scanner scanner = new Scanner(System.in); private final int N = 100000 + 4; private final int MAXBIT = 30; private int[] l = new int[N], r = new int[N], q = new int[N], a = new int[N], t = new int[N << 2]; private int n, m; public void readDat...
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 bit[100005][32]; int sifirsayisi[100005][32]; int sonuc[32]; int cvp[100005]; pair<pair<int, int>, int> girdi[100005]; int main() { int n, m; scanf("%d%d", &n, &m); for (int i = 1; i <= m; i++) { int l, r, q; scanf("%d%d%d", &l, &r, &q); for (int s = 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.*; import java.util.*; public class C{ static int []ans; public static void main(String[] args) throws IOException { Scanner sc=new Scanner(System.in); PrintWriter pw=new PrintWriter(System.out); int n=sc.nextInt(),q=sc.nextInt(); ans=new int [n]; int []l=new int [q],r=new int [q],x=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.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.FileReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.ArrayList; 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
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.PrintWriter; import java.io.BufferedWriter; import java.util.InputMismatchException; import java.io.IOException; import java.util.ArrayList; import java.io.Writer; import java.io.OutputStream...
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; const int inf = 1e9; const int N = 1e6 + 9; int n, m, mask = 30; int l[N], r[N], q[N], a[N]; int bit[30][N], t[4 * N]; void build(int v, int tl, int tr) { if (tl == tr) { t[v] = a[tl]; } else { int md = (tl + tr) / 2; build(v * 2, tl, md); build(v * 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
#include <bits/stdc++.h> using namespace std; int answers[100100]; int n, m; int lft[100100]; int rgt[100100]; int query[100100]; int cnts[100100]; int diff[100100]; bool solve(int b) { memset(cnts, 0, sizeof(cnts)); memset(diff, 0, sizeof(diff)); for (int i = 0; i < m; i++) { int t = (query[i] >> b) & 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 SIZEN = 100010; int N, M; int chafen[33][SIZEN] = {0}; int ans[SIZEN] = {0}; int a[SIZEN], b[SIZEN], c[SIZEN]; int main() { int N, M; scanf("%d%d", &N, &M); for (int i = 1; i <= M; i++) { scanf("%d%d%d", &a[i], &b[i], &c[i]); int now = 0; int tmp...
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.util.ArrayList; import java.util.Arrays; import java.util.List; public class C { static class Node { int l, r, value; Node left, right; public Node(int l, int r) { this.l = l; this.r = r; value = 0; if (l != r) { 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
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.util.Arrays; import java.util.function.Supplier; import java.io.OutputStreamWriter; import java.util.function.IntFunction; import java.io.OutputStream; import java.io.PrintStream; import java.io.IOException; import java.io....
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.util.Map.Entry; import java.io.*; import java.awt.Point; import java.math.BigInteger; import static java.lang.Math.*; public class CodeforcesB implements Runnable { final boolean ONLINE_JUDGE = System.getProperty("ONLINE_JUDGE") != null; BufferedReader in; PrintWriter 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; bool sort_second(const pair<int, int>& left, const pair<int, int>& right) { return (left.second < right.second); } int main() { if (false) { freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); } int n, m; cin >> n >> m; int len = 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
import java.io.*; import java.util.*; public class B { BufferedReader br; PrintWriter out; StringTokenizer st; boolean eof; void solve() throws IOException { int n = nextInt(); int m = nextInt(); int[] low = new int[m]; int[] high = new int[m]; int[] val = new int[m]; for (int i = 0; i < m; 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
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; public class Main { public static int N, M; public static int[][] delta, value, prefixes, inputs; public static int[] res; public static void main(String[] args) throws IOException { 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
//package CF; import java.io.*; import java.util.*; public class B{ public static void main(String[] args) throws Exception { Scanner bf = new Scanner(System.in); PrintWriter out = new PrintWriter(System.out); int n = bf.nextInt(); int m = bf.nextInt(); int N = 1; while(N < n) N <<= 1; 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.awt.Dimension; import java.awt.Point; import java.io.*; import static java.lang.Character.*; import static java.lang.Math.*; import java.math.BigDecimal; import java.math.BigInteger; import static java.math.BigInteger.*; import java.util.*; import static java.util.Arrays.*; import java.util.logging.Level;...
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 tree[400005]; long long ans[100005]; long long n, MAXBIT = 30; void build(long long tl, long long tr, long long nd) { if (tl == tr) { tree[nd] = ans[tl]; return; } long long mid = (tl + tr) / 2; build(tl, mid, 2 * nd); build(mid + 1, tr, 2 * nd +...
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 + 10; const int M = 1e5 + 10; int n, m; int l[M], r[M], q[M]; int d[30][N]; int sum[30][N]; 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 i = 0; i < m; ++i) { bitset<30> 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
#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.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.StringTokenizer; public class InterestingArray { private static int[] segmentTree; private static int[] num; private static final int MAX_BITS = 30; private 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> #pragma comment(linker, "/STACK:512000000") using namespace std; int n, m; int l, r, q; int mas[100005]; int nm[31][100005]; const int magic = 1 << 17; int tree[magic * 2]; const int ret = (1 << 30) - 1; int lg[100005]; int rg[100005]; int qq[100005]; int get(int vl, int trl, int trr, 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
import java.util.*; import java.io.*; import java.text.*; public class B482 { 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; sTree = 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.util.*; import java.io.*; public class abc{ static void Construct(int seg[],int l,int r,int pos,int a[]){ if(l==r){ seg[pos]=a[l]; return; } int m=(l+r)/2; Const...
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.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; int n, m; int tree[400005]; bool flag; struct q { int l, r, q; } q[100005]; void add(int l, int r, int q, int L, int R, int i) { if (l == L && r == R) { tree[i] = tree[i] | q; return; } int M = (L + R) / 2; if (r <= M) add(l, r, q, L, M, i * 2); else...
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
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); int n = sc.nextInt(); int N = 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 static java.lang.Math.*; public class B { private static class T1 { private final T1 L, R; private final int from, to, m; private long X = 0; public void or(long X, int from, int to) { assert(from >= this.from && to <= this.to && from < to); if (from == this.from && to == this.to) this.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; const long long N = 1 << 17; long long bg[40][N]; long long en[40][N]; long long st[2 * N]; long long getAnd(int a, int b) { a += N; b += N; long long ans = (1ll << 40) - 1; for (; a <= b; a /= 2, b /= 2) { if (a & 1) { ans &= st[a++]; } if (~b & 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 MAXN = 100010 * 4; const int MAXM = 100010 * 8; const int INF = 1e9 + 7; const double pi = acos(0.0) * 2.0; const double eps = 1e-12; inline int read(int &x) { scanf("%d", &x); return x; } inline long long read(long long &x) { scanf("%I64d", &x); return x;...
CPP
506_B. Mr. Kitayuta's Technology
Shuseki Kingdom is the world's leading nation for innovation and technology. There are n cities in the kingdom, numbered from 1 to n. Thanks to Mr. Kitayuta's research, it has finally become possible to construct teleportation pipes between two cities. A teleportation pipe will connect two cities unidirectionally, tha...
2
8
#include <bits/stdc++.h> using namespace std; int n, m, ans, x, y, nrIN[100005]; vector<int> v[100005], N, ord[100005]; unordered_set<long long> S; bool viz[100005], viz2[100005]; long long to_ll(int x, int y) { return 1LL * x * 1e6 + y; } void dfs(int nod) { N.push_back(nod); viz[nod] = 1; for (auto it : v[nod])...
CPP
506_B. Mr. Kitayuta's Technology
Shuseki Kingdom is the world's leading nation for innovation and technology. There are n cities in the kingdom, numbered from 1 to n. Thanks to Mr. Kitayuta's research, it has finally become possible to construct teleportation pipes between two cities. A teleportation pipe will connect two cities unidirectionally, tha...
2
8
#include <bits/stdc++.h> using namespace std; const int N = 3e5 + 100; const long long int mod = 998244353; const int inf = 1e7 + 100; bool mark[N]; vector<int> v, to, adj[N], g[N]; int ind[N]; void dfs(int u) { v.push_back(u); mark[u] = true; for (auto x : adj[u]) { if (!mark[x]) dfs(x); } } void dfs2(int ...
CPP
506_B. Mr. Kitayuta's Technology
Shuseki Kingdom is the world's leading nation for innovation and technology. There are n cities in the kingdom, numbered from 1 to n. Thanks to Mr. Kitayuta's research, it has finally become possible to construct teleportation pipes between two cities. A teleportation pipe will connect two cities unidirectionally, tha...
2
8
#include <bits/stdc++.h> using namespace std; static const int N = 100000; struct node { int data; node *next; }; node *a[N]; int done[N]; int onst[N]; int gk = 1; int br = 0; int component[N]; int ciklus[N]; int done2[N]; void dfs(int c) { done[c] = 1; onst[c] = 1; node *tmp = a[c]; while (tmp) { if (!...
CPP
506_B. Mr. Kitayuta's Technology
Shuseki Kingdom is the world's leading nation for innovation and technology. There are n cities in the kingdom, numbered from 1 to n. Thanks to Mr. Kitayuta's research, it has finally become possible to construct teleportation pipes between two cities. A teleportation pipe will connect two cities unidirectionally, tha...
2
8
#include <bits/stdc++.h> template <typename T> void scan(T &x) { x = 0; bool _ = 0; T c = getchar(); _ = c == 45; c = _ ? getchar() : c; while (c < 48 || c > 57) c = getchar(); for (; c < 48 || c > 57; c = getchar()) ; for (; c > 47 && c < 58; c = getchar()) x = (x << 3) + (x << 1) + (c & 15); x =...
CPP
506_B. Mr. Kitayuta's Technology
Shuseki Kingdom is the world's leading nation for innovation and technology. There are n cities in the kingdom, numbered from 1 to n. Thanks to Mr. Kitayuta's research, it has finally become possible to construct teleportation pipes between two cities. A teleportation pipe will connect two cities unidirectionally, tha...
2
8
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 5; vector<int> g[N], edge[N], temp; bool done[N], vis[N]; int got[N]; void dfs(int now) { if (done[now]) return; done[now] = 1; temp.emplace_back(now); for (int i = 0; i < g[now].size(); i++) { dfs(g[now][i]); } } int main() { int n, m; ...
CPP
506_B. Mr. Kitayuta's Technology
Shuseki Kingdom is the world's leading nation for innovation and technology. There are n cities in the kingdom, numbered from 1 to n. Thanks to Mr. Kitayuta's research, it has finally become possible to construct teleportation pipes between two cities. A teleportation pipe will connect two cities unidirectionally, tha...
2
8
import java.io.*; import java.math.*; import java.util.*; public class Main { public static int[] cnt = new int[100009]; public void run() { int n = reader.nextInt(), m = reader.nextInt(); ArrayList<Integer>[] E = new ArrayList[n]; for(int i = 0; i < n; +...
JAVA
506_B. Mr. Kitayuta's Technology
Shuseki Kingdom is the world's leading nation for innovation and technology. There are n cities in the kingdom, numbered from 1 to n. Thanks to Mr. Kitayuta's research, it has finally become possible to construct teleportation pipes between two cities. A teleportation pipe will connect two cities unidirectionally, tha...
2
8
#include <bits/stdc++.h> using namespace std; const int mxn = 1e5 + 10; vector<int> adj[mxn]; vector<int> tps[mxn]; vector<int> comp[mxn]; int sz[mxn] = {}; int initsz[mxn] = {}; int vis[mxn] = {}; int comind[mxn]; int mark = 0; stack<int> st; int n; int par[mxn]; int cyc[mxn] = {}; void dfs(int u) { vis[u] = 1; fo...
CPP
506_B. Mr. Kitayuta's Technology
Shuseki Kingdom is the world's leading nation for innovation and technology. There are n cities in the kingdom, numbered from 1 to n. Thanks to Mr. Kitayuta's research, it has finally become possible to construct teleportation pipes between two cities. A teleportation pipe will connect two cities unidirectionally, tha...
2
8
#include <bits/stdc++.h> using namespace std; int n, m; vector<int> Colors, temp; vector<vector<int>> G, C, GForBfs; long long ans; bool dfs(int x); void bfs(int x); int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cin >> n >> m; G.assign(n, vector<int>(0, 0)); GForBfs.assign(n,...
CPP
506_B. Mr. Kitayuta's Technology
Shuseki Kingdom is the world's leading nation for innovation and technology. There are n cities in the kingdom, numbered from 1 to n. Thanks to Mr. Kitayuta's research, it has finally become possible to construct teleportation pipes between two cities. A teleportation pipe will connect two cities unidirectionally, tha...
2
8
#include <bits/stdc++.h> using namespace std; bool flag[100005]; int n, m, x, y; vector<int> a[100005], b[100005]; int d[100005]; int sum, num, ans, dq; queue<int> q; int dfs(int x) { int sum = 1; flag[x] = true; if (d[x] == 0) q.push(x); for (int i = 0; i < a[x].size(); ++i) { int y = a[x][i]; if (flag...
CPP
506_B. Mr. Kitayuta's Technology
Shuseki Kingdom is the world's leading nation for innovation and technology. There are n cities in the kingdom, numbered from 1 to n. Thanks to Mr. Kitayuta's research, it has finally become possible to construct teleportation pipes between two cities. A teleportation pipe will connect two cities unidirectionally, tha...
2
8
#include <bits/stdc++.h> using namespace std; struct DisjointSet { vector<int> label; DisjointSet(int n) { label.assign(n, -1); } int get(int u) { return label[u] < 0 ? u : label[u] = get(label[u]); } void join(int u, int v) { u = get(u); v = get(v); if (u == v) return; if (label[u] < label[v]) ...
CPP
506_B. Mr. Kitayuta's Technology
Shuseki Kingdom is the world's leading nation for innovation and technology. There are n cities in the kingdom, numbered from 1 to n. Thanks to Mr. Kitayuta's research, it has finally become possible to construct teleportation pipes between two cities. A teleportation pipe will connect two cities unidirectionally, tha...
2
8
#include <bits/stdc++.h> using namespace std; const int Maxn = 200000; int n, m, mark[Maxn]; bool res[Maxn], flag[Maxn], u[Maxn]; vector<int> nei[Maxn], rnei[Maxn], adj[Maxn]; vector<int> l; void dfs(int u, int c) { mark[u] = c; for (auto v : adj[u]) if (!mark[v]) dfs(v, c); } void Dfs(int u) { flag[u] = true...
CPP
506_B. Mr. Kitayuta's Technology
Shuseki Kingdom is the world's leading nation for innovation and technology. There are n cities in the kingdom, numbered from 1 to n. Thanks to Mr. Kitayuta's research, it has finally become possible to construct teleportation pipes between two cities. A teleportation pipe will connect two cities unidirectionally, tha...
2
8
import java.util.*; import java.io.*; public class MrKitayutasTechnology { public static void main(String[] args) throws Exception { FastScanner in = new FastScanner(System.in); int n = in.nextInt(); int m = in.nextInt(); ArrayList<Integer>[] adj = new ArrayList[n]; for(int x = 0; x < adj.length; x++)...
JAVA
506_B. Mr. Kitayuta's Technology
Shuseki Kingdom is the world's leading nation for innovation and technology. There are n cities in the kingdom, numbered from 1 to n. Thanks to Mr. Kitayuta's research, it has finally become possible to construct teleportation pipes between two cities. A teleportation pipe will connect two cities unidirectionally, tha...
2
8
import java.io.*; import java.util.*; public class B { FastScanner in; PrintWriter out; List<Integer>[] graph, revGraph; List<Integer> order; int[] comp; void dfs(int u) { comp[u] = 0; for (int v : graph[u]) { if (comp[v] == -1) { dfs(v); ...
JAVA
506_B. Mr. Kitayuta's Technology
Shuseki Kingdom is the world's leading nation for innovation and technology. There are n cities in the kingdom, numbered from 1 to n. Thanks to Mr. Kitayuta's research, it has finally become possible to construct teleportation pipes between two cities. A teleportation pipe will connect two cities unidirectionally, tha...
2
8
#include <bits/stdc++.h> using namespace std; const int MAXN = 100100; vector<int> g[MAXN]; vector<int> gd[MAXN]; bool mk[MAXN]; int cnt; vector<int> tmp; void dfs(int u) { if (mk[u]) { return; } mk[u] = true; tmp.push_back(u); for (int i = 0; i < g[u].size(); i++) { int v = g[u][i]; dfs(v); } }...
CPP
506_B. Mr. Kitayuta's Technology
Shuseki Kingdom is the world's leading nation for innovation and technology. There are n cities in the kingdom, numbered from 1 to n. Thanks to Mr. Kitayuta's research, it has finally become possible to construct teleportation pipes between two cities. A teleportation pipe will connect two cities unidirectionally, tha...
2
8
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 50; const int mod = 1e9 + 7; const int inf = (1 << 30); vector<int> v[maxn][5], tpl; int ted[maxn], com[maxn], tmp = 1; bool visited[maxn]; bool dfs(int u, int d) { visited[u] = 1; bool rz = (ted[com[u]] == 1); if (d == 1) { com[u] = tmp; ...
CPP
506_B. Mr. Kitayuta's Technology
Shuseki Kingdom is the world's leading nation for innovation and technology. There are n cities in the kingdom, numbered from 1 to n. Thanks to Mr. Kitayuta's research, it has finally become possible to construct teleportation pipes between two cities. A teleportation pipe will connect two cities unidirectionally, tha...
2
8
#include <bits/stdc++.h> using namespace std; const int MAXN = 1e5 + 10; int n, m, ans, l; int mark[MAXN], comp[MAXN], scc[MAXN], cyc[MAXN]; vector<int> edge[MAXN], adj[MAXN], radj[MAXN]; deque<int> dq; void dfs(int source) { mark[source]++; ans++, comp[source] = l; for (auto &u : edge[source]) if (!mark[u]) ...
CPP
506_B. Mr. Kitayuta's Technology
Shuseki Kingdom is the world's leading nation for innovation and technology. There are n cities in the kingdom, numbered from 1 to n. Thanks to Mr. Kitayuta's research, it has finally become possible to construct teleportation pipes between two cities. A teleportation pipe will connect two cities unidirectionally, tha...
2
8
import java.util.*; import java.io.*; public class _0505_D_MrKitayutasTechnology { static ArrayList<Integer> dgraph[]; public static void main(String[] args) throws IOException { int N = readInt(), M = readInt(); dgraph = new ArrayList[N+1]; ArrayList<Integer> graph[] = new ArrayList[N+1]; for(int i= 1;...
JAVA
506_B. Mr. Kitayuta's Technology
Shuseki Kingdom is the world's leading nation for innovation and technology. There are n cities in the kingdom, numbered from 1 to n. Thanks to Mr. Kitayuta's research, it has finally become possible to construct teleportation pipes between two cities. A teleportation pipe will connect two cities unidirectionally, tha...
2
8
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.ArrayDeque; import java.util.ArrayList; import java.util.Arrays; import java.util.StringTokenizer; public class KitayutaTechnology { int[] in; int[] low; int[] group; ...
JAVA
506_B. Mr. Kitayuta's Technology
Shuseki Kingdom is the world's leading nation for innovation and technology. There are n cities in the kingdom, numbered from 1 to n. Thanks to Mr. Kitayuta's research, it has finally become possible to construct teleportation pipes between two cities. A teleportation pipe will connect two cities unidirectionally, tha...
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) retu...
JAVA
506_B. Mr. Kitayuta's Technology
Shuseki Kingdom is the world's leading nation for innovation and technology. There are n cities in the kingdom, numbered from 1 to n. Thanks to Mr. Kitayuta's research, it has finally become possible to construct teleportation pipes between two cities. A teleportation pipe will connect two cities unidirectionally, tha...
2
8
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 5; const int maxm = 1e5 + 5; bool vst[maxn], p[maxn]; int n, m, cnt, scc, timer, ans, tot; int tail[maxn], d[maxn], l[maxn], f[maxn], id[maxn], size[maxn]; struct edge { int u, v, next; } a[maxm]; stack<int> st; int find(int x) { return f[x] == x ? ...
CPP
506_B. Mr. Kitayuta's Technology
Shuseki Kingdom is the world's leading nation for innovation and technology. There are n cities in the kingdom, numbered from 1 to n. Thanks to Mr. Kitayuta's research, it has finally become possible to construct teleportation pipes between two cities. A teleportation pipe will connect two cities unidirectionally, tha...
2
8
import java.util.*; import java.io.*; public class Main{ static int n,m; static boolean isCycle=false; public static void main(String args[]) { InputReader in = new InputReader(System.in); ArrayList<ArrayList<Integer>> list = new ArrayList<ArrayList<Integer>>(); ArrayList<ArrayList<Integer>> rlist = new Arra...
JAVA
506_B. Mr. Kitayuta's Technology
Shuseki Kingdom is the world's leading nation for innovation and technology. There are n cities in the kingdom, numbered from 1 to n. Thanks to Mr. Kitayuta's research, it has finally become possible to construct teleportation pipes between two cities. A teleportation pipe will connect two cities unidirectionally, tha...
2
8
#include <bits/stdc++.h> using namespace std; vector<int> adj[100005], radj[100005]; vector<int> con[100005]; int chk[100005], cnt, vis[100005]; int val[100005], size[100005]; int T; int N, M, g[100005]; int ans; void DFS(int u) { chk[u] = 1; int i, v; for (i = 0; i < adj[u].size(); i++) { v = adj[u][i]; ...
CPP
506_B. Mr. Kitayuta's Technology
Shuseki Kingdom is the world's leading nation for innovation and technology. There are n cities in the kingdom, numbered from 1 to n. Thanks to Mr. Kitayuta's research, it has finally become possible to construct teleportation pipes between two cities. A teleportation pipe will connect two cities unidirectionally, tha...
2
8
#include <bits/stdc++.h> using namespace std; class SCC { private: int n, comp_sz; vector<vector<int> > g, gt; vector<int> seq, vis; void dfs(int u, const vector<vector<int> > &adj) { for (int v : adj[u]) { if (vis[v] == -1) { vis[v] = comp_sz; dfs(v, adj); } } seq.push_...
CPP
506_B. Mr. Kitayuta's Technology
Shuseki Kingdom is the world's leading nation for innovation and technology. There are n cities in the kingdom, numbered from 1 to n. Thanks to Mr. Kitayuta's research, it has finally become possible to construct teleportation pipes between two cities. A teleportation pipe will connect two cities unidirectionally, tha...
2
8
#include <bits/stdc++.h> using namespace std; const int N = 100000; int n, m, t; vector<int> adj[N], radj[N], component; vector<pair<int, int> > finishing; bool undir_visit[N], visit[N], strongly_connected; void undir_dfs(int u) { undir_visit[u] = true; component.push_back(u); for (const int &v : adj[u]) { if...
CPP