output
stringlengths
52
181k
instruction
stringlengths
296
182k
#include <bits/stdc++.h> using namespace std; inline int read() { int num = 0; char c = getchar(); if (c == '-') return -read(); while (c >= '0' && c <= '9') { num = (num << 3) + (num << 1) + c - '0'; c = getchar(); } return num; } inline long long READ() { long long num = 0; char c = getchar();...
### Prompt Please create a solution in cpp to the following problem: Roman is a young mathematician, very famous in Uzhland. Unfortunately, Sereja doesn't think so. To make Sereja change his mind, Roman is ready to solve any mathematical problem. After some thought, Sereja asked Roma to find, how many numbers are clo...
#include <bits/stdc++.h> using namespace std; const int MASK = (1 << 18) + 15, M = 128; long long dp[MASK][M]; long long fact[M], cnt[M]; int m; string a; int32_t main() { ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL); cerr << "HELLO WORLD :)\n"; cin >> a >> m; fact[0] = 1; for (auto u : a) ...
### Prompt Your task is to create a Cpp solution to the following problem: Roman is a young mathematician, very famous in Uzhland. Unfortunately, Sereja doesn't think so. To make Sereja change his mind, Roman is ready to solve any mathematical problem. After some thought, Sereja asked Roma to find, how many numbers a...
#include <bits/stdc++.h> using namespace std; const int N = 100 + 10; const int M = 3e5 + 100; const long long int mod = 1e9 + 7; const long long int inf = 1e16; long long int pw[22], dp[M][N], a[22]; bool mark[10]; int main() { ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0); long long int k; int m; ...
### Prompt Please provide a CPP coded solution to the problem described below: Roman is a young mathematician, very famous in Uzhland. Unfortunately, Sereja doesn't think so. To make Sereja change his mind, Roman is ready to solve any mathematical problem. After some thought, Sereja asked Roma to find, how many numbe...
#include <bits/stdc++.h> using namespace std; int len; int mo; string n; long long dp[1 << 18][100]; long long coun[10]; int fastmod[10004]; void pre() { for (int i = (1); i <= (10004 - 1); ++i) { fastmod[i] = i % mo; } } long long solve(int mask, int m) { if (mask == (1 << len) - 1) return m == 0; if (dp[m...
### Prompt Develop a solution in cpp to the problem described below: Roman is a young mathematician, very famous in Uzhland. Unfortunately, Sereja doesn't think so. To make Sereja change his mind, Roman is ready to solve any mathematical problem. After some thought, Sereja asked Roma to find, how many numbers are clo...
#include <bits/stdc++.h> using namespace std; string s; int n, m; long long dp[1 << 18][105]; long long power(int x, int p) { if (p == 0) return 1; return x * power(x, p - 1); } long long getCount(int mask, int mod, int c) { if (mask == (1 << n) - 1) if (mod == 0) return 1; else return 0; lo...
### Prompt Generate a cpp solution to the following problem: Roman is a young mathematician, very famous in Uzhland. Unfortunately, Sereja doesn't think so. To make Sereja change his mind, Roman is ready to solve any mathematical problem. After some thought, Sereja asked Roma to find, how many numbers are close to nu...
#include <bits/stdc++.h> using namespace std; long long dp[1 << 18][100]; int co[1 << 18]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); string s; cin >> s; long long m; cin >> m; long long n = s.size(); long long c[10]; memset(c, 0, sizeof c); for (long long i = 0; i < n; i++) c[s[i] - '0'...
### Prompt Construct a CPP code solution to the problem outlined: Roman is a young mathematician, very famous in Uzhland. Unfortunately, Sereja doesn't think so. To make Sereja change his mind, Roman is ready to solve any mathematical problem. After some thought, Sereja asked Roma to find, how many numbers are close ...
#include <bits/stdc++.h> using namespace std; long long setBit(long long num, long long i) { return num | (1 << i); } long long unsetBit(long long num, long long i) { num ^= 1 << i; return num; } bool checkBit(long long num, long long i) { if (num & 1 << i) return true; else return false; } long long bp...
### Prompt Generate a CPP solution to the following problem: Roman is a young mathematician, very famous in Uzhland. Unfortunately, Sereja doesn't think so. To make Sereja change his mind, Roman is ready to solve any mathematical problem. After some thought, Sereja asked Roma to find, how many numbers are close to nu...
#include <bits/stdc++.h> using namespace std; char s[20]; int m; long long dp[1 << 18][110]; int cnt[20]; int main() { ios::sync_with_stdio(false); cin >> s >> m; memset(dp, 0, sizeof(dp)); memset(cnt, 0, sizeof(cnt)); dp[0][0] = 1; int l = strlen(s); long long x = 1 << l, d = 1; for (int i = 0; i < l; ...
### Prompt Construct a Cpp code solution to the problem outlined: Roman is a young mathematician, very famous in Uzhland. Unfortunately, Sereja doesn't think so. To make Sereja change his mind, Roman is ready to solve any mathematical problem. After some thought, Sereja asked Roma to find, how many numbers are close ...
#include <bits/stdc++.h> using namespace std; long long v; int n, m; long long dp[1 << 18][100]; int num[100], cnt[100]; int N; void solve() { N = 1 << n; dp[0][0] = 1; for (int i = 0; i < n; i++) { if (num[i] > 0) dp[1 << i][num[i] % m] += 1; } for (int i = 1; i < N; i++) { for (int j = 0; j < m; j++...
### Prompt Construct a CPP code solution to the problem outlined: Roman is a young mathematician, very famous in Uzhland. Unfortunately, Sereja doesn't think so. To make Sereja change his mind, Roman is ready to solve any mathematical problem. After some thought, Sereja asked Roma to find, how many numbers are close ...
#include <bits/stdc++.h> using namespace std; const int MAX = 1e5 + 15; const int inf = 1e9 + 7; const long long MOD = 1e9 + 7; double eps = 1e-9; long long f[20]; int digit[20]; int a[20]; long long dp[1 << 18][105]; int m; void init() { f[0] = 1; for (int i = 1; i <= 18; i++) { f[i] = f[i - 1] * i; } mems...
### Prompt Please formulate a Cpp solution to the following problem: Roman is a young mathematician, very famous in Uzhland. Unfortunately, Sereja doesn't think so. To make Sereja change his mind, Roman is ready to solve any mathematical problem. After some thought, Sereja asked Roma to find, how many numbers are clo...
#include <bits/stdc++.h> using namespace std; const int INF = 0x3f3f3f3f; long long n, x, dp[1 << 18][100]; int m, p[20], len; long long dfs(int pos, int status, bool zero, int rev) { if (!pos) return rev == 0; if (!zero && dp[status][rev] != -1) return dp[status][rev]; long long ans = 0; int f[10]; memset(f,...
### Prompt Please formulate a Cpp solution to the following problem: Roman is a young mathematician, very famous in Uzhland. Unfortunately, Sereja doesn't think so. To make Sereja change his mind, Roman is ready to solve any mathematical problem. After some thought, Sereja asked Roma to find, how many numbers are clo...
#include <bits/stdc++.h> using namespace std; map<pair<vector<int>, int>, long long> ma; long long dp[(1 << 18)][101]; int main() { srand((unsigned int)time(NULL)); long long n, m; int dig[20], id = 0, ten[20], cnt[10] = {}; ten[0] = 1; cin >> n >> m; for (int i = 1; i <= 19; i++) ten[i] = (ten[i - 1] * 10)...
### Prompt Develop a solution in cpp to the problem described below: Roman is a young mathematician, very famous in Uzhland. Unfortunately, Sereja doesn't think so. To make Sereja change his mind, Roman is ready to solve any mathematical problem. After some thought, Sereja asked Roma to find, how many numbers are clo...
#include <bits/stdc++.h> using namespace std; long long n; int m; long long dp[1 << 18][101]; int num[20]; int c[10]; int digitLen; long long Fac(int x) { return x == 0 ? 1 : Fac(x - 1) * x; } int main() { cin >> n >> m; while (n) { int t = (int)(n % 10); num[digitLen++] = t; c[t]++; n /= 10; } ...
### Prompt Please formulate a cpp solution to the following problem: Roman is a young mathematician, very famous in Uzhland. Unfortunately, Sereja doesn't think so. To make Sereja change his mind, Roman is ready to solve any mathematical problem. After some thought, Sereja asked Roma to find, how many numbers are clo...
#include <bits/stdc++.h> using namespace std; ifstream fin("A.in"); ofstream fout("A.out"); long long n; int m, t; int a[20]; bool upd[10]; long long dp[300000][101]; int main() { cin >> n >> m; while (n) { a[t++] = n % 10; n /= 10; } sort(a, a + t); for (int i = 0; i < t; ++i) { if (a[i] && (i ==...
### Prompt Your task is to create a Cpp solution to the following problem: Roman is a young mathematician, very famous in Uzhland. Unfortunately, Sereja doesn't think so. To make Sereja change his mind, Roman is ready to solve any mathematical problem. After some thought, Sereja asked Roma to find, how many numbers a...
#include <bits/stdc++.h> using namespace std; int n, m; string s; long long mem[(1 << 18)][105]; long long DP(int cur, int rem) { if (cur == (1 << n) - 1) return rem == 0; if (mem[cur][rem] == -1) { long long ans = 0; for (int i = 0; i < n; i++) { if (!(cur & (1 << i))) { ans += DP(cur | (1 <<...
### Prompt Generate a cpp solution to the following problem: Roman is a young mathematician, very famous in Uzhland. Unfortunately, Sereja doesn't think so. To make Sereja change his mind, Roman is ready to solve any mathematical problem. After some thought, Sereja asked Roma to find, how many numbers are close to nu...
#include <bits/stdc++.h> using namespace std; string num; long long dp[1 << 18][101]; long long mx; int sz, m; long long solve(long long mask, int md) { if (mask == mx) { if (md % m == 0) return 1; return 0; } long long &ret = dp[mask][md]; if (ret != -1) return ret; ret = 0; bool vis[10]; memset(...
### Prompt Your task is to create a Cpp solution to the following problem: Roman is a young mathematician, very famous in Uzhland. Unfortunately, Sereja doesn't think so. To make Sereja change his mind, Roman is ready to solve any mathematical problem. After some thought, Sereja asked Roma to find, how many numbers a...
#include <bits/stdc++.h> using namespace std; bool Check(long long n, long long pos) { return (n & (1 << pos)); } long long Set(long long n, long long pos) { return (n | (1 << pos)); } string s; long long n, mod; long long dp[(1 << 18) + 2][102]; long long call(long long mask, long long val) { if (mask == (1 << n) - ...
### Prompt Construct a cpp code solution to the problem outlined: Roman is a young mathematician, very famous in Uzhland. Unfortunately, Sereja doesn't think so. To make Sereja change his mind, Roman is ready to solve any mathematical problem. After some thought, Sereja asked Roma to find, how many numbers are close ...
#include <bits/stdc++.h> using namespace std; const long long N = 20; long long n, m; long long f[11]; vector<long long> v; long long dp[1 << 18][100]; long long fact[N]; void precompute() { fact[0] = fact[1] = 1; for (long long i = 2; i < N; i++) { fact[i] = fact[i - 1] * i; } } void work(long long k) { wh...
### Prompt Your task is to create a cpp solution to the following problem: Roman is a young mathematician, very famous in Uzhland. Unfortunately, Sereja doesn't think so. To make Sereja change his mind, Roman is ready to solve any mathematical problem. After some thought, Sereja asked Roma to find, how many numbers a...
#include <bits/stdc++.h> using namespace std; vector<int> p, g; long long n, f[2][27000][105]; int m, cnt[10]; int toInt(vector<int>& state) { int res = 0; for (int i = 0; i < int(p.size()); i++) { if (state[i] == 0) continue; res += state[i] * g[i + 1]; } return res; } vector<int> toState(int s) { ve...
### Prompt Construct a Cpp code solution to the problem outlined: Roman is a young mathematician, very famous in Uzhland. Unfortunately, Sereja doesn't think so. To make Sereja change his mind, Roman is ready to solve any mathematical problem. After some thought, Sereja asked Roma to find, how many numbers are close ...
#include <bits/stdc++.h> using namespace std; int dX[] = {0, 0, 1, -1}; int dY[] = {1, -1, 0, 0}; string alpha = "abcdefghijklmnopqrstuvwxyz"; int MOD = 1000000007; const int N = 200100; string s; int m, arr[20], n; long long dp[(1 << 18) + 5][100]; long long solve(int mask, int rem, bool f) { if (mask == (1 << n) - ...
### Prompt Please formulate a Cpp solution to the following problem: Roman is a young mathematician, very famous in Uzhland. Unfortunately, Sereja doesn't think so. To make Sereja change his mind, Roman is ready to solve any mathematical problem. After some thought, Sereja asked Roma to find, how many numbers are clo...
#include <bits/stdc++.h> using namespace std; bool Check(long long n, long long pos) { return (n & (1 << pos)); } long long Set(long long n, long long pos) { return (n | (1 << pos)); } string s; long long n, mod; long long dp[(1 << 18) + 2][102]; long long call(long long mask, long long val) { if (mask == (1 << n) - ...
### Prompt Please formulate a CPP solution to the following problem: Roman is a young mathematician, very famous in Uzhland. Unfortunately, Sereja doesn't think so. To make Sereja change his mind, Roman is ready to solve any mathematical problem. After some thought, Sereja asked Roma to find, how many numbers are clo...
#include <bits/stdc++.h> using namespace std; string s; int n, m; long long dp[1 << 18][105]; long long power(int x, int p) { if (p == 0) return 1; return x * power(x, p - 1); } long long getCount(int mask, int mod) { if (mask == (1 << n) - 1) if (mod == 0) return 1; else return 0; long long...
### Prompt Your task is to create a CPP solution to the following problem: Roman is a young mathematician, very famous in Uzhland. Unfortunately, Sereja doesn't think so. To make Sereja change his mind, Roman is ready to solve any mathematical problem. After some thought, Sereja asked Roma to find, how many numbers a...
#include <bits/stdc++.h> using namespace std; long long lp, numb[20], u; long long dp[300000][105]; long long dmc(long long msk, long long mod) { if (msk + 1 == (1 << u) && !(mod % lp)) return 1; if (msk + 1 == (1 << u)) return 0; if (dp[msk][mod] != -1) return dp[msk][mod]; long long i, j, res = 0, ty = 0; f...
### Prompt Your challenge is to write a Cpp solution to the following problem: Roman is a young mathematician, very famous in Uzhland. Unfortunately, Sereja doesn't think so. To make Sereja change his mind, Roman is ready to solve any mathematical problem. After some thought, Sereja asked Roma to find, how many numbe...
#include <bits/stdc++.h> using namespace std; void _fill_int(int* p, int val, int rep) { int i; for (i = 0; i < rep; i++) p[i] = val; } signed long long GETi() { signed long long i; scanf("%lld", &i); return i; } signed long long N, M; vector<signed long long> V; signed long long powd[10][20]; signed long lon...
### Prompt Your challenge is to write a cpp solution to the following problem: Roman is a young mathematician, very famous in Uzhland. Unfortunately, Sereja doesn't think so. To make Sereja change his mind, Roman is ready to solve any mathematical problem. After some thought, Sereja asked Roma to find, how many numbe...
#include <bits/stdc++.h> const int N = 3000000 + 7; int n, m; int l[N], r[N]; int e[N]; std::vector<std::pair<int, int>> g[N]; int t[N]; int ans[N]; void dfs(int s); int main() { scanf("%d", &n); for (int i = 1; i <= n; ++i) scanf("%d%d", l + i, r + i), e[i] = l[i], e[i + n] = ++r[i]; std::sort(e + 1, e + n *...
### Prompt Generate a cpp solution to the following problem: Iahub isn't well prepared on geometry problems, but he heard that this year there will be a lot of geometry problems on the IOI selection camp. Scared, Iahub locked himself in the basement and started thinking of new problems of this kind. One of them is th...
#include <bits/stdc++.h> using namespace std; inline int get() { char c; while (!isdigit(c = getchar())) ; int v = c - 48; while (isdigit(c = getchar())) v = v * 10 + c - 48; return v; } int n; pair<int, int> a[200005]; bool vis[200005], c[200005]; vector<int> G[200005]; void dfs(int x, int col) { vis[x...
### Prompt Your task is to create a cpp solution to the following problem: Iahub isn't well prepared on geometry problems, but he heard that this year there will be a lot of geometry problems on the IOI selection camp. Scared, Iahub locked himself in the basement and started thinking of new problems of this kind. One...
#include <bits/stdc++.h> using namespace std; const int maxn = 2e5 + 5; int head[maxn], deg[maxn], ans[maxn], tot = 1; struct edge { int v, nex, id; bool f; } e[maxn << 4]; void add(int u, int v, int id) { e[++tot] = {v, head[u], id, 0}, head[u] = tot; e[++tot] = {u, head[v], id, 0}, head[v] = tot; } struct Q {...
### Prompt Create a solution in cpp for the following problem: Iahub isn't well prepared on geometry problems, but he heard that this year there will be a lot of geometry problems on the IOI selection camp. Scared, Iahub locked himself in the basement and started thinking of new problems of this kind. One of them is ...
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 5; int n, cl[N], l, r; set<pair<pair<int, int>, int> > q; vector<int> g[N]; void dfs(int v, int c = 0) { cl[v] = c; for (auto to : g[v]) { if (cl[to] == -1) { dfs(to, (c ^ 1)); } } } int main() { ios_base::sync_with_stdio(0); cin....
### Prompt Please formulate a Cpp solution to the following problem: Iahub isn't well prepared on geometry problems, but he heard that this year there will be a lot of geometry problems on the IOI selection camp. Scared, Iahub locked himself in the basement and started thinking of new problems of this kind. One of th...
#include <bits/stdc++.h> using namespace std; template <typename _tp> inline void read(_tp& x) { char c11 = getchar(), ob = 0; x = 0; while (c11 != '-' && !isdigit(c11)) c11 = getchar(); if (c11 == '-') ob = 1, c11 = getchar(); while (isdigit(c11)) x = x * 10 + c11 - '0', c11 = getchar(); if (ob) x = -x; } ...
### Prompt Please create a solution in CPP to the following problem: Iahub isn't well prepared on geometry problems, but he heard that this year there will be a lot of geometry problems on the IOI selection camp. Scared, Iahub locked himself in the basement and started thinking of new problems of this kind. One of th...
#include <bits/stdc++.h> using namespace std; const int MAXN = 200010; bool cmp(int *a, int *b) { return *a < *b; } int n; int l[MAXN], r[MAXN]; int *ts[MAXN * 2]; vector<pair<int, int> > ls[MAXN * 2]; bool u[MAXN * 2]; bool sol[MAXN]; void tour(int a) { for (pair<int, int> &e : ls[a]) if (!u[e.second]) { i...
### Prompt Your challenge is to write a Cpp solution to the following problem: Iahub isn't well prepared on geometry problems, but he heard that this year there will be a lot of geometry problems on the IOI selection camp. Scared, Iahub locked himself in the basement and started thinking of new problems of this kind....
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; const int M = 1e5; const int N = 2 * 1e6 + 5; struct node { int ver, next; } e[N]; int tot, head[N]; int v[N]; int n, m; multimap<int, int> h; void add(int x, int y) { e[++tot].ver = y; e[tot].next = head[x]; head[x] = tot; } void dfs(int x,...
### Prompt Construct a CPP code solution to the problem outlined: Iahub isn't well prepared on geometry problems, but he heard that this year there will be a lot of geometry problems on the IOI selection camp. Scared, Iahub locked himself in the basement and started thinking of new problems of this kind. One of them ...
#include <bits/stdc++.h> using namespace std; const int MAX_N = int(2e5) + 10; int n; vector<int> E[MAX_N]; void addEdge(int u, int v) { E[u].push_back(v), E[v].push_back(u); } int col[MAX_N]; void dfs(int u, int c) { if (col[u] != -1) return; col[u] = c; for (vector<int>::iterator e = E[u].begin(); e != E[u].end...
### Prompt Your task is to create a CPP solution to the following problem: Iahub isn't well prepared on geometry problems, but he heard that this year there will be a lot of geometry problems on the IOI selection camp. Scared, Iahub locked himself in the basement and started thinking of new problems of this kind. One...
#include <bits/stdc++.h> long long gi() { long long x = 0, f = 1; char ch = getchar(); while (!isdigit(ch)) f ^= ch == '-', ch = getchar(); while (isdigit(ch)) x = x * 10 + ch - '0', ch = getchar(); return f ? x : -x; } int fir[200010], dis[1000010], nxt[1000010], w[1000010], dir[1000010], id = 1; void link(i...
### Prompt Your challenge is to write a cpp solution to the following problem: Iahub isn't well prepared on geometry problems, but he heard that this year there will be a lot of geometry problems on the IOI selection camp. Scared, Iahub locked himself in the basement and started thinking of new problems of this kind....
#include <bits/stdc++.h> using namespace std; const int maxn = 100007; const int maxm = 200007; const int maxe = 400007; struct node { int from, to, nxt, id; } e[maxe]; int l[maxn], r[maxn], a[maxm], head[maxm], vis[maxm], used[maxm], d[maxm], c[maxm], top, tot; void add(int u, int v, int id) { e[tot].nxt = hea...
### Prompt Construct a CPP code solution to the problem outlined: Iahub isn't well prepared on geometry problems, but he heard that this year there will be a lot of geometry problems on the IOI selection camp. Scared, Iahub locked himself in the basement and started thinking of new problems of this kind. One of them ...
#include <bits/stdc++.h> using namespace std; inline int read() { int ans = 0, fh = 1; char ch = getchar(); while (ch < '0' || ch > '9') { if (ch == '-') fh = -1; ch = getchar(); } while (ch >= '0' && ch <= '9') ans = ans * 10 + ch - '0', ch = getchar(); return ans * fh; } const int maxn = 4e5; int ...
### Prompt Please provide a CPP coded solution to the problem described below: Iahub isn't well prepared on geometry problems, but he heard that this year there will be a lot of geometry problems on the IOI selection camp. Scared, Iahub locked himself in the basement and started thinking of new problems of this kind....
#include <bits/stdc++.h> using namespace std; const int N = 510000; struct node { int to, next, id; } a[N * 2]; int n, l[N], r[N], x[N], ls[N], tot = 1, ans[N], in[N], cnt; bool V[N], v[N]; void addl(int x, int y, int id) { a[++tot].to = y; a[tot].next = ls[x]; a[tot].id = id; ls[x] = tot; in[y]++; } void d...
### Prompt Construct a cpp code solution to the problem outlined: Iahub isn't well prepared on geometry problems, but he heard that this year there will be a lot of geometry problems on the IOI selection camp. Scared, Iahub locked himself in the basement and started thinking of new problems of this kind. One of them ...
#include <bits/stdc++.h> using namespace std; long long c[300100], l[300100], r[300100], acc[300100]; set<long long> gr[300100]; void dfs(long long v) { if (!gr[v].empty()) { long long e = *gr[v].begin(); long long u = r[e] ^ l[e] ^ v; gr[v].erase(e); gr[u].erase(e); if (v < u) c[e] = 1; dfs(u...
### Prompt Construct a CPP code solution to the problem outlined: Iahub isn't well prepared on geometry problems, but he heard that this year there will be a lot of geometry problems on the IOI selection camp. Scared, Iahub locked himself in the basement and started thinking of new problems of this kind. One of them ...
#include <bits/stdc++.h> using namespace std; inline int read() { int first = 0, f = 1; char ch = getchar(); for (; !isdigit(ch); ch = getchar()) { if (ch == '-') f = -1; } for (; isdigit(ch); ch = getchar()) { first = first * 10 + ch - 48; } return first * f; } const int mxN = 2e5; int n, en; vec...
### Prompt Please provide a Cpp coded solution to the problem described below: Iahub isn't well prepared on geometry problems, but he heard that this year there will be a lot of geometry problems on the IOI selection camp. Scared, Iahub locked himself in the basement and started thinking of new problems of this kind....
#include <bits/stdc++.h> using namespace std; const int MAXN = 190010; bool cmp(int *a, int *b) { return *a < *b; } int n; int l[MAXN], r[MAXN]; int *ts[MAXN * 2]; vector<pair<int, int> > ls[MAXN * 2]; bool u[MAXN * 2]; bool sol[MAXN]; void tour(int a) { for (pair<int, int> &e : ls[a]) if (!u[e.second]) { i...
### Prompt Your task is to create a CPP solution to the following problem: Iahub isn't well prepared on geometry problems, but he heard that this year there will be a lot of geometry problems on the IOI selection camp. Scared, Iahub locked himself in the basement and started thinking of new problems of this kind. One...
#include <bits/stdc++.h> using namespace std; struct inter { int l, r; } I[600050]; struct point { int next, to, w; } ar[600050]; bool is[600050]; int a[600050], at, head[600050], art(1); inline int lower(int, int, int, int*); inline void read(int&), link(int, int, int), dfs(int); int main() { int n; read(n); ...
### Prompt Please create a solution in CPP to the following problem: Iahub isn't well prepared on geometry problems, but he heard that this year there will be a lot of geometry problems on the IOI selection camp. Scared, Iahub locked himself in the basement and started thinking of new problems of this kind. One of th...
#include <bits/stdc++.h> using namespace std; const int maxn = 2 * 100005; bool vis[maxn], par[maxn]; vector<int> edge[maxn]; pair<int, int> seg[maxn]; int n; void add(int a, int b) { edge[a].push_back(b), edge[b].push_back(a); } void dfs(int x, int cur) { if (vis[x]) return; vis[x] = true; par[x] = cur; for (i...
### Prompt In Cpp, your task is to solve the following problem: Iahub isn't well prepared on geometry problems, but he heard that this year there will be a lot of geometry problems on the IOI selection camp. Scared, Iahub locked himself in the basement and started thinking of new problems of this kind. One of them is...
#include <bits/stdc++.h> using namespace std; const int maxn = 2e5 + 55; int V[maxn], U[maxn]; unordered_map<int, int> M; vector<int> comp; bitset<maxn> mark, emark, ans; vector<int> adj[maxn]; void dfs(int v, int E = -1) { mark[v] = 1; for (auto e : adj[v]) { if (!emark[e]) { emark[e] = 1; dfs(V[e]...
### Prompt Your task is to create a CPP solution to the following problem: Iahub isn't well prepared on geometry problems, but he heard that this year there will be a lot of geometry problems on the IOI selection camp. Scared, Iahub locked himself in the basement and started thinking of new problems of this kind. One...
#include <bits/stdc++.h> using namespace std; const int iinf = 1e9 + 7; const long long linf = 1ll << 60; const double dinf = 1e60; template <typename T> inline void scf(T &x) { bool f = 0; x = 0; char c = getchar(); while ((c < '0' || c > '9') && c != '-') c = getchar(); if (c == '-') { f = 1; c = ge...
### Prompt Generate a Cpp solution to the following problem: Iahub isn't well prepared on geometry problems, but he heard that this year there will be a lot of geometry problems on the IOI selection camp. Scared, Iahub locked himself in the basement and started thinking of new problems of this kind. One of them is th...
#include <bits/stdc++.h> using namespace std; const int SIZE = 1e5 + 5; const int IN = 1; const int OUT = 0; struct data { int id, x, io; data(int _id = 0, int _x = 0, int _io = 0) : id(_id), x(_x), io(_io) {} bool operator<(const data& b) const { return x < b.x; } } a[SIZE * 2]; int m = 0; int to[SIZE * 2], an[S...
### Prompt Please formulate a CPP solution to the following problem: Iahub isn't well prepared on geometry problems, but he heard that this year there will be a lot of geometry problems on the IOI selection camp. Scared, Iahub locked himself in the basement and started thinking of new problems of this kind. One of th...
#include <bits/stdc++.h> using namespace std; const int Maxn = 600005; int n, ct, cnt, e[Maxn], l[Maxn], r[Maxn], tmp[Maxn], deg[Maxn], head[Maxn]; struct edg { int nxt, to; bool dir; } edge[2 * Maxn]; void add(int x, int y) { deg[x]++; edge[++cnt] = (edg){head[x], y}; head[x] = cnt; } void dfs(int u) { for...
### Prompt Construct a CPP code solution to the problem outlined: Iahub isn't well prepared on geometry problems, but he heard that this year there will be a lot of geometry problems on the IOI selection camp. Scared, Iahub locked himself in the basement and started thinking of new problems of this kind. One of them ...
#include <bits/stdc++.h> using namespace std; const int MAXN = 4e5 + 10; struct edge { int y; list<edge>::iterator rev; edge(int y) : y(y) {} }; list<edge> g[MAXN]; int pa[MAXN]; int find(int x) { return pa[x] = pa[x] == x ? x : find(pa[x]); } void join(int x, int y) { pa[find(x)] = find(y); } void add_edge(int a...
### Prompt Construct a cpp code solution to the problem outlined: Iahub isn't well prepared on geometry problems, but he heard that this year there will be a lot of geometry problems on the IOI selection camp. Scared, Iahub locked himself in the basement and started thinking of new problems of this kind. One of them ...
#include <bits/stdc++.h> using namespace std; const double pi = acos(-1); int P[2 * 110000], X[110000], Y[110000], use[2 * 110000], n, tot, vis[2 * 110000], du[2 * 110000]; vector<pair<int, int> > E[2 * 110000]; void dfs(int x) { vis[x] = 1; for (auto i : E[x]) if (!use[i.second]) { if (i.first > x) ...
### Prompt Create a solution in cpp for the following problem: Iahub isn't well prepared on geometry problems, but he heard that this year there will be a lot of geometry problems on the IOI selection camp. Scared, Iahub locked himself in the basement and started thinking of new problems of this kind. One of them is ...
#include <bits/stdc++.h> using namespace std; template <class T> void dbs(string str, T t) { cerr << str << " : " << t << "\n"; } template <class T, class... S> void dbs(string str, T t, S... s) { int idx = str.find(','); cerr << str.substr(0, idx) << " : " << t << ","; dbs(str.substr(idx + 1), s...); } templat...
### Prompt Generate a CPP solution to the following problem: Iahub isn't well prepared on geometry problems, but he heard that this year there will be a lot of geometry problems on the IOI selection camp. Scared, Iahub locked himself in the basement and started thinking of new problems of this kind. One of them is th...
#include <bits/stdc++.h> using namespace std; struct node { int x, id, op; } a[200002]; struct edge { int to, nxxt; } e[200002 << 3]; int n, tot, js, head[200002 << 2], cnt = 2, dfn[200002], low[200002], f[200002], cn, an; bool inq[200002]; stack<int> s; inline void ins(int u, int...
### Prompt Please create a solution in CPP to the following problem: Iahub isn't well prepared on geometry problems, but he heard that this year there will be a lot of geometry problems on the IOI selection camp. Scared, Iahub locked himself in the basement and started thinking of new problems of this kind. One of th...
#include <bits/stdc++.h> using namespace std; template <typename T> bool chkmax(T &a, T b) { return a < b ? a = b, 1 : 0; } template <typename T> bool chkmin(T &a, T b) { return a > b ? a = b, 1 : 0; } const int maxn = 2e5 + 1e2; struct node { int l, r; } s[maxn]; struct Edge { int to, nxt, id; } e[maxn << 1]; ...
### Prompt Your challenge is to write a CPP solution to the following problem: Iahub isn't well prepared on geometry problems, but he heard that this year there will be a lot of geometry problems on the IOI selection camp. Scared, Iahub locked himself in the basement and started thinking of new problems of this kind....
#include <bits/stdc++.h> using namespace std; int head[200001], col[200001]; struct { int v, link; } e[2 * 200001]; int n, m; void addEdge(int u, int v) { e[m] = {v, head[u]}; head[u] = m++; } void dfs(int u, int c) { if (col[u] != -1) return; col[u] = c; for (int i = head[u]; i != -1; i = e[i].link) dfs(e[...
### Prompt In Cpp, your task is to solve the following problem: Iahub isn't well prepared on geometry problems, but he heard that this year there will be a lot of geometry problems on the IOI selection camp. Scared, Iahub locked himself in the basement and started thinking of new problems of this kind. One of them is...
#include <bits/stdc++.h> using namespace std; const int N = 3e5 + 10; int i, j, k, n, m; struct Section { int l, r; } z[N]; int store[N * 2], tot; bool cmp(int a, int b) { return a < b; } int disva = 0; map<int, int> s; struct Edge { int y, l, id; bool enable; } f[N * 4]; int g[N * 2], In[N * 2], T; void Ins(int ...
### Prompt Please formulate a cpp solution to the following problem: Iahub isn't well prepared on geometry problems, but he heard that this year there will be a lot of geometry problems on the IOI selection camp. Scared, Iahub locked himself in the basement and started thinking of new problems of this kind. One of th...
#include <bits/stdc++.h> using namespace std; const int N = 1e5; int n, cnt, now, id; int l[N + 10], r[N + 10], a[(N << 1) + 10], degree[(N << 1) + 10], ans[N + 10]; bool vis[(N << 1) + 10], vis2[(N << 1) + 10]; struct edge { int v, id; edge(int v_, int id_) : v(v_), id(id_) {} }; vector<edge> g[(N << 1) + 10]; voi...
### Prompt Develop a solution in Cpp to the problem described below: Iahub isn't well prepared on geometry problems, but he heard that this year there will be a lot of geometry problems on the IOI selection camp. Scared, Iahub locked himself in the basement and started thinking of new problems of this kind. One of th...
#include <bits/stdc++.h> #pragma comment(linker, "/STACK:640000000") using namespace std; const double eps = 1e-9; const double pi = acos(-1.0); const int maxn = (int)2e5 + 10; int l[maxn], r[maxn], x[maxn]; bool used[maxn], edge[maxn]; int col[maxn]; vector<pair<int, int> > g[maxn]; void dfs(int v) { for (int i = 0;...
### Prompt Create a solution in Cpp for the following problem: Iahub isn't well prepared on geometry problems, but he heard that this year there will be a lot of geometry problems on the IOI selection camp. Scared, Iahub locked himself in the basement and started thinking of new problems of this kind. One of them is ...
#include <bits/stdc++.h> #pragma GCC optimize("O2,Ofast,inline,unroll-all-loops,-ffast-math") #pragma GCC target("avx,sse2,sse3,sse4,popcnt") using namespace std; struct data { int x, id; bool operator<(const data &rhs) const { return x < rhs.x; } } ds[200010]; int val[200010], lef[200010], righ[200010], n; bool vi...
### Prompt In cpp, your task is to solve the following problem: Iahub isn't well prepared on geometry problems, but he heard that this year there will be a lot of geometry problems on the IOI selection camp. Scared, Iahub locked himself in the basement and started thinking of new problems of this kind. One of them is...
#include <bits/stdc++.h> using namespace std; int n, tot, sum[200010]; int b[200010], l[200010], r[200010]; struct Node { int to, nxt, id; } Edge[200010 << 1]; int Head[200010], cnt_Edge = 1; void Add_Edge(int u, int v, int id) { Edge[++cnt_Edge] = (Node){v, Head[u], id}; Head[u] = cnt_Edge; } int ans[200010], vi...
### Prompt Create a solution in Cpp for the following problem: Iahub isn't well prepared on geometry problems, but he heard that this year there will be a lot of geometry problems on the IOI selection camp. Scared, Iahub locked himself in the basement and started thinking of new problems of this kind. One of them is ...
#include <bits/stdc++.h> using namespace std; const int T = 1e5 + 5; pair<pair<int, int>, int> d[T]; map<int, int> M; int f[T], id[T], col[T]; int l; vector<long long> g[T]; void DFS(int v, int c) { col[v] = c; for (int i = 0; i < g[v].size(); i++) { int to = g[v][i]; if (col[to] == col[v]) { cout << ...
### Prompt Construct a cpp code solution to the problem outlined: Iahub isn't well prepared on geometry problems, but he heard that this year there will be a lot of geometry problems on the IOI selection camp. Scared, Iahub locked himself in the basement and started thinking of new problems of this kind. One of them ...
#include <bits/stdc++.h> int n, tot = 1, cnt; int head[200001], ver[400001], next[400001], id[400001]; int l[100001], r[100001], deg[200001]; int vp[200001], ve[400001]; int x[200001]; int ans[100001]; void add(int u, int v) { ver[++tot] = v; next[tot] = head[u]; head[u] = tot; } void dfs(int p) { vp[p] = 1; ...
### Prompt Please provide a cpp coded solution to the problem described below: Iahub isn't well prepared on geometry problems, but he heard that this year there will be a lot of geometry problems on the IOI selection camp. Scared, Iahub locked himself in the basement and started thinking of new problems of this kind....
#include <bits/stdc++.h> using namespace std; int Read() { char c; while (c = getchar(), (c != '-') && (c < '0' || c > '9')) ; bool neg = (c == '-'); int ret = (neg ? 0 : c - 48); while (c = getchar(), c >= '0' && c <= '9') ret = ret * 10 + c - 48; return neg ? -ret : ret; } const int MAXN = 200005; pai...
### Prompt Please create a solution in CPP to the following problem: Iahub isn't well prepared on geometry problems, but he heard that this year there will be a lot of geometry problems on the IOI selection camp. Scared, Iahub locked himself in the basement and started thinking of new problems of this kind. One of th...
#include <bits/stdc++.h> struct Range { int left, right; } seg[100000]; struct Edge { int to, idx; Edge() {} Edge(int a, int b) : to(a), idx(b) {} }; std::vector<Edge> g[2 * 100000]; int color[2 * 100000] = {}; void draw(int now) { for (int i = 0; i < g[now].size(); i++) { Edge e = g[now][i]; if (colo...
### Prompt In Cpp, your task is to solve the following problem: Iahub isn't well prepared on geometry problems, but he heard that this year there will be a lot of geometry problems on the IOI selection camp. Scared, Iahub locked himself in the basement and started thinking of new problems of this kind. One of them is...
#include <bits/stdc++.h> using namespace std; const int L = 200100; int n; vector<int> a[L]; vector<pair<int, int> > b; int col[L]; void ins(int x, int y) { a[x].push_back(y); a[y].push_back(x); } void dfs(int x, int c) { if (col[x] != -1) return; col[x] = c; for (vector<int>::iterator e = a[x].begin(); e != ...
### Prompt Your task is to create a cpp solution to the following problem: Iahub isn't well prepared on geometry problems, but he heard that this year there will be a lot of geometry problems on the IOI selection camp. Scared, Iahub locked himself in the basement and started thinking of new problems of this kind. One...
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 100; const int E = 2e5 + 100; int n; int l[N], r[N]; vector<int> x; vector<int> g[N]; vector<int> tour; int to[E], mark[E], ecnt; int from[E], c[E]; void add(int u, int v) { from[ecnt] = u, to[ecnt] = v; g[u].push_back(ecnt); g[v].push_back(ecnt); ...
### Prompt Generate a CPP solution to the following problem: Iahub isn't well prepared on geometry problems, but he heard that this year there will be a lot of geometry problems on the IOI selection camp. Scared, Iahub locked himself in the basement and started thinking of new problems of this kind. One of them is th...
#include <bits/stdc++.h> using namespace std; vector<int> ed[401000], odd, cod[401000]; pair<int, int> e[401000]; int pathlen, x, y, n, m, tot, st[401000], pathedge[401000], b[401000], path[401000], pr[401000]; bool don[401000], vis[402000]; void dfs(int x) { don[x] = true; for (int i = 0; i < (int)ed[x].size()...
### Prompt Develop a solution in Cpp to the problem described below: Iahub isn't well prepared on geometry problems, but he heard that this year there will be a lot of geometry problems on the IOI selection camp. Scared, Iahub locked himself in the basement and started thinking of new problems of this kind. One of th...
#include <bits/stdc++.h> using namespace std; constexpr int N = 1e5 + 10; constexpr int LG = 20; constexpr int MOD = 1e9 + 7; constexpr int MOD2 = 1e9 + 9; int n, l, r, cl[N]; set<pair<int, pair<int, int>>> st; void solve() { if ((int)st.size() <= 1) return; pair<int, pair<int, int>> aval = *st.begin(); st.erase(...
### Prompt Construct a CPP code solution to the problem outlined: Iahub isn't well prepared on geometry problems, but he heard that this year there will be a lot of geometry problems on the IOI selection camp. Scared, Iahub locked himself in the basement and started thinking of new problems of this kind. One of them ...
#include <bits/stdc++.h> using namespace std; const double dInf = 1E90; const long long lInf = (long long)1E16; const int Inf = 0x23333333; const int N = 300005; struct edge { int x, y, used, num, next; } e[N << 1]; int a[N]; int cnt[N], ret[N]; bool vis[N]; int n, m, T = 2; pair<int, int> A[N]; void mke(int x, int y...
### Prompt Generate a CPP solution to the following problem: Iahub isn't well prepared on geometry problems, but he heard that this year there will be a lot of geometry problems on the IOI selection camp. Scared, Iahub locked himself in the basement and started thinking of new problems of this kind. One of them is th...
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 10; int n, c, B[N], T[N]; pair<int, int> A[N]; map<int, int> M; vector<int> Odd; vector<pair<int, int> > V[N]; void Add(int v, int u, int i) { V[v].push_back({u, i}); V[u].push_back({v, i}); } void DFS(int v) { while (V[v].size()) { auto X = V[...
### Prompt Create a solution in CPP for the following problem: Iahub isn't well prepared on geometry problems, but he heard that this year there will be a lot of geometry problems on the IOI selection camp. Scared, Iahub locked himself in the basement and started thinking of new problems of this kind. One of them is ...
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 5; vector<int> adj[N]; vector<int> cur; int l[N], r[N]; int d[N]; vector<int> fard; bool mark[N]; vector<int> tour; unordered_map<int, int> nist[N]; unordered_map<int, bool> ans[N]; void dfs(int x) { mark[x] = 1; for (int p : adj[x]) { if (nist[x...
### Prompt Develop a solution in Cpp to the problem described below: Iahub isn't well prepared on geometry problems, but he heard that this year there will be a lot of geometry problems on the IOI selection camp. Scared, Iahub locked himself in the basement and started thinking of new problems of this kind. One of th...
#include <bits/stdc++.h> using namespace std; const int maxn = 100010; int p[maxn], w[maxn]; vector<pair<pair<int, int>, int>> a; int find(int x) { if (p[x] == x) return x; else { int ret = find(p[x]); w[x] ^= w[p[x]]; return p[x] = ret; } } int main() { int l, r, n; cin >> n; for (int i = 0...
### Prompt Develop a solution in Cpp to the problem described below: Iahub isn't well prepared on geometry problems, but he heard that this year there will be a lot of geometry problems on the IOI selection camp. Scared, Iahub locked himself in the basement and started thinking of new problems of this kind. One of th...
#include <bits/stdc++.h> using namespace std; inline int read() { int x = 0; bool t = false; char ch = getchar(); while ((ch < '0' || ch > '9') && ch != '-') ch = getchar(); if (ch == '-') t = true, ch = getchar(); while (ch <= '9' && ch >= '0') x = x * 10 + ch - 48, ch = getchar(); return t ? -x : x; } i...
### Prompt Create a solution in cpp for the following problem: Iahub isn't well prepared on geometry problems, but he heard that this year there will be a lot of geometry problems on the IOI selection camp. Scared, Iahub locked himself in the basement and started thinking of new problems of this kind. One of them is ...
#include <bits/stdc++.h> using namespace std; const int N = 1e6 + 7; vector<int> g[N]; int col[N], u[N], v[N], mark[N], vis[N]; void dfs(int x, int y) { if (y != -1) vis[y] = true; mark[x] = true; for (auto i : g[x]) if (!vis[i]) dfs(u[i] ^ v[i] ^ x, i); if (y != -1) { int o = u[y] ^ v[y] ^ x; if (o...
### Prompt Please formulate a cpp solution to the following problem: Iahub isn't well prepared on geometry problems, but he heard that this year there will be a lot of geometry problems on the IOI selection camp. Scared, Iahub locked himself in the basement and started thinking of new problems of this kind. One of th...
#include <bits/stdc++.h> using namespace std; const int iinf = 1e9 + 7; const long long linf = 1ll << 60; const double dinf = 1e60; template <typename T> inline void scf(T &x) { bool f = 0; x = 0; char c = getchar(); while ((c < '0' || c > '9') && c != '-') c = getchar(); if (c == '-') { f = 1; c = ge...
### Prompt Create a solution in cpp for the following problem: Iahub isn't well prepared on geometry problems, but he heard that this year there will be a lot of geometry problems on the IOI selection camp. Scared, Iahub locked himself in the basement and started thinking of new problems of this kind. One of them is ...
#include <bits/stdc++.h> using namespace std; const int N = 100005; int n; int id[N + N]; int a[N + N]; int where[N + N], color[N + N]; vector<int> E[N + N]; bool cmp(int i, int j) { return a[i] < a[j]; } void dfs(int u, int c) { if (color[u] == -1) { color[u] = c; } else { return; } for (int v : E[u]) ...
### Prompt Your task is to create a CPP solution to the following problem: Iahub isn't well prepared on geometry problems, but he heard that this year there will be a lot of geometry problems on the IOI selection camp. Scared, Iahub locked himself in the basement and started thinking of new problems of this kind. One...
#include <bits/stdc++.h> using namespace std; int n, l[100015], r[100015], o[100015 << 1], tot, cnt, ans[100015], ind[100015 << 1], head[100015 << 1]; struct edge { int to, next, w; edge() {} edge(int u, int v, int x) { to = u; next = v; w = x; } } e[100015 << 2]; bool vis[100015 << 2], gkp[1000...
### Prompt In cpp, your task is to solve the following problem: Iahub isn't well prepared on geometry problems, but he heard that this year there will be a lot of geometry problems on the IOI selection camp. Scared, Iahub locked himself in the basement and started thinking of new problems of this kind. One of them is...
#include <bits/stdc++.h> using namespace std; const int MAXN = 200200; int fs[MAXN]; int sc[MAXN]; int color[MAXN]; vector<int> g[MAXN]; bool dfs(int v, int c) { if (color[v] != -1) { return color[v] == c; } color[v] = c; for (int i = 0; i < (int)g[v].size(); i++) { if (!dfs(g[v][i], c ^ 1)) { ret...
### Prompt Develop a solution in CPP to the problem described below: Iahub isn't well prepared on geometry problems, but he heard that this year there will be a lot of geometry problems on the IOI selection camp. Scared, Iahub locked himself in the basement and started thinking of new problems of this kind. One of th...
#include <bits/stdc++.h> using namespace std; struct edge { int to, nxt, w; } e[400001]; int edge_num = -1; int head[200001]; void add(int u, int v) { e[++edge_num].nxt = head[u]; e[edge_num].to = v; head[u] = edge_num; } void add_edge(int u, int v) { add(u, v); add(v, u); } struct node { int l, r; } q[20...
### Prompt Please create a solution in Cpp to the following problem: Iahub isn't well prepared on geometry problems, but he heard that this year there will be a lot of geometry problems on the IOI selection camp. Scared, Iahub locked himself in the basement and started thinking of new problems of this kind. One of th...
#include <bits/stdc++.h> using namespace std; const int MAXN = 1e5 + 10; pair<int, int> l[MAXN], r[MAXN], tot[MAXN * 2]; int n, cnt; vector<int> G[MAXN * 2]; int col[MAXN * 2]; void dfs(int u, int c) { if (col[u] != -1) return; col[u] = c; for (int i = 0; i < (int)G[u].size(); i++) dfs(G[u][i], c ^ 1); } int main...
### Prompt Please formulate a CPP solution to the following problem: Iahub isn't well prepared on geometry problems, but he heard that this year there will be a lot of geometry problems on the IOI selection camp. Scared, Iahub locked himself in the basement and started thinking of new problems of this kind. One of th...
#include <bits/stdc++.h> using namespace std; int n, m, i, j, px[100005], py[100005], ans[100005], deg[200005], vis[200005], vis2[400005]; vector<int> all; vector<pair<int, int> > e[200005]; void dfs(int x) { vis[x] = 1; while (!e[x].empty()) { if (vis2[e[x].back().second]) { e[x].pop_back(); co...
### Prompt Please formulate a Cpp solution to the following problem: Iahub isn't well prepared on geometry problems, but he heard that this year there will be a lot of geometry problems on the IOI selection camp. Scared, Iahub locked himself in the basement and started thinking of new problems of this kind. One of th...
#include <bits/stdc++.h> using namespace std; struct edge { int to, nxt, w; } e[400001]; int edge_num = -1; int head[400001]; void add(int u, int v) { e[++edge_num].nxt = head[u]; e[edge_num].to = v; head[u] = edge_num; } void add_edge(int u, int v) { add(u, v); add(v, u); } struct node { int l, r; } q[20...
### Prompt Construct a CPP code solution to the problem outlined: Iahub isn't well prepared on geometry problems, but he heard that this year there will be a lot of geometry problems on the IOI selection camp. Scared, Iahub locked himself in the basement and started thinking of new problems of this kind. One of them ...
#include <bits/stdc++.h> using namespace std; multimap<int, int> mp; int n, L, R, head[200005], tot; struct ccf { int to, nxt; } e[1000005]; void add(int a, int b) { tot++; e[tot].to = b; e[tot].nxt = head[a]; head[a] = tot; } int vis[200005]; void dfs(int now, int se) { if (vis[now]) return; vis[now] = s...
### Prompt Please create a solution in CPP to the following problem: Iahub isn't well prepared on geometry problems, but he heard that this year there will be a lot of geometry problems on the IOI selection camp. Scared, Iahub locked himself in the basement and started thinking of new problems of this kind. One of th...
#include <bits/stdc++.h> using namespace std; const int maxn = 200005; inline int gi() { char c = getchar(); while (c < '0' || c > '9') c = getchar(); int sum = 0; while ('0' <= c && c <= '9') sum = sum * 10 + c - 48, c = getchar(); return sum; } int n, l[maxn], r[maxn], ans[maxn], *q[maxn], num, cnt; struct ...
### Prompt Create a solution in Cpp for the following problem: Iahub isn't well prepared on geometry problems, but he heard that this year there will be a lot of geometry problems on the IOI selection camp. Scared, Iahub locked himself in the basement and started thinking of new problems of this kind. One of them is ...
#include <bits/stdc++.h> using namespace std; namespace FGF { const int N = 5e5 + 5; struct edg { int to, nxt; } e[N]; int cnt = 1, l[N], r[N], c[N], n, tot, tp, st[N], vis[N], col[N], head[N], du[N]; void add(int u, int v) { cnt++; e[cnt].to = v; e[cnt].nxt = head[u]; head[u] = cnt; du[u]++; } void dfs...
### Prompt Develop a solution in CPP to the problem described below: Iahub isn't well prepared on geometry problems, but he heard that this year there will be a lot of geometry problems on the IOI selection camp. Scared, Iahub locked himself in the basement and started thinking of new problems of this kind. One of th...
#include <bits/stdc++.h> using namespace std; const int maxn = 2e5 + 5; pair<int, int> e[maxn]; int n; int vis[maxn]; int deg[maxn]; vector<int> adj[maxn]; void dfs(int u) { while (adj[u].size()) { int tmp = adj[u].back(); adj[u].pop_back(); if (vis[tmp] == 0) { if (deg[u] > 0) vis[tmp] = 1 ...
### Prompt Create a solution in CPP for the following problem: Iahub isn't well prepared on geometry problems, but he heard that this year there will be a lot of geometry problems on the IOI selection camp. Scared, Iahub locked himself in the basement and started thinking of new problems of this kind. One of them is ...
#include <bits/stdc++.h> using namespace std; using pii = pair<int, int>; const int N = 200 * 1000 + 10; int n, cnt_e; vector<int> adj[N], vec, ans, odd, tour; vector<pii> ed; map<pii, int> mp; map<int, int> mp_ed; set<int> vis; void add_edge(int u, int v) { cnt_e++; mp_ed[cnt_e] = mp_ed[cnt_e] = u ^ v; adj[u].pu...
### Prompt Please provide a cpp coded solution to the problem described below: Iahub isn't well prepared on geometry problems, but he heard that this year there will be a lot of geometry problems on the IOI selection camp. Scared, Iahub locked himself in the basement and started thinking of new problems of this kind....
#include <bits/stdc++.h> using namespace std; vector<int> e[210000]; int col[210000], n; pair<int, int> p[210000]; void dfs(int u, int color) { if (col[u] != -1) return; col[u] = color; for (int i = 0; i < (int)e[u].size(); ++i) dfs(e[u][i], color ^ 1); } void solve() { for (int i = 0; i <= n * 2; ++i) e[i].cle...
### Prompt Your challenge is to write a CPP solution to the following problem: Iahub isn't well prepared on geometry problems, but he heard that this year there will be a lot of geometry problems on the IOI selection camp. Scared, Iahub locked himself in the basement and started thinking of new problems of this kind....
#include <bits/stdc++.h> using namespace std; int n; struct aa { int l, r; } pp[201000]; vector<pair<int, int> > _hash; vector<pair<int, int> >::iterator it; int color[201000]; struct node { int t, nxt; } edge[201000 << 3]; int headline[201000], E; inline void add(int f, int t) { edge[E].t = t; edge[E].nxt = he...
### Prompt Please formulate a cpp solution to the following problem: Iahub isn't well prepared on geometry problems, but he heard that this year there will be a lot of geometry problems on the IOI selection camp. Scared, Iahub locked himself in the basement and started thinking of new problems of this kind. One of th...
#include <bits/stdc++.h> using namespace std; int n, m; struct E { int x, o, i; } e[100010 << 1]; int cnt; struct _E { int ed, o, i, ne; } _e[100010 << 3]; int in[100010 << 1], he[100010 << 1], en = 1; bool vis[100010 << 3]; int path[100010 << 2], tot; int ans[100010]; bool cmp1(E a, E b) { return a.x < b.x; } bool...
### Prompt Generate a cpp solution to the following problem: Iahub isn't well prepared on geometry problems, but he heard that this year there will be a lot of geometry problems on the IOI selection camp. Scared, Iahub locked himself in the basement and started thinking of new problems of this kind. One of them is th...
#include <bits/stdc++.h> int n; struct pii { int p, t; } P[1111111]; bool operator<(const pii x, const pii y) { return (x.p != y.p) ? x.p < y.p : x.t > y.t; } std::vector<pii> v[1111111]; void ins(int x, int y, int z) { if (x < 0) x = -x; if (y < 0) y = -y; v[x].push_back(pii{y, z}), v[y].push_back(pii{x, z})...
### Prompt Please formulate a cpp solution to the following problem: Iahub isn't well prepared on geometry problems, but he heard that this year there will be a lot of geometry problems on the IOI selection camp. Scared, Iahub locked himself in the basement and started thinking of new problems of this kind. One of th...
#include <bits/stdc++.h> using namespace std; int read() { int x = 0, sgn = 1; char ch = getchar(); for (; !isdigit(ch); ch = getchar()) if (ch == '-') sgn = -1; for (; isdigit(ch); ch = getchar()) x = (x << 1) + (x << 3) + (ch ^ 48); return x * sgn; } const int N = 1e5 + 10; int n, b[N << 1], tot, l[N], ...
### Prompt Generate a cpp solution to the following problem: Iahub isn't well prepared on geometry problems, but he heard that this year there will be a lot of geometry problems on the IOI selection camp. Scared, Iahub locked himself in the basement and started thinking of new problems of this kind. One of them is th...
#include <bits/stdc++.h> using namespace std; char buf[100000], *p1 = buf, *p2 = buf; inline int gi() { int x = 0, f = 1; char ch = getchar(); while (ch > '9' || ch < '0') { if (ch == '-') f = -1; ch = getchar(); } while (ch >= '0' && ch <= '9') { x = (x << 3) + (x << 1) + (ch ^ 48), ch = getchar(...
### Prompt Construct a CPP code solution to the problem outlined: Iahub isn't well prepared on geometry problems, but he heard that this year there will be a lot of geometry problems on the IOI selection camp. Scared, Iahub locked himself in the basement and started thinking of new problems of this kind. One of them ...
#include <bits/stdc++.h> using namespace std; const int N = 400050; int a[N], b[N], w[N], Id, d[N], nn[N][2], o[N], head[N], top, tot, bl[N], cnt, vis[N], st[N], bj[N]; void dfs(int x) { vis[x] = 1; for (int i = head[x], y; i; i = nn[i][0]) if (!bj[bl[i]]) { bj[bl[i]] = 1, dfs(y = nn[i][1]); if ...
### Prompt Construct a Cpp code solution to the problem outlined: Iahub isn't well prepared on geometry problems, but he heard that this year there will be a lot of geometry problems on the IOI selection camp. Scared, Iahub locked himself in the basement and started thinking of new problems of this kind. One of them ...
#include <bits/stdc++.h> using namespace std; vector<pair<int, pair<int, int> > > v; vector<pair<int, int> > e[100005]; int n, c[100005]; void dfs(int v, int n) { c[v] = n; for (int i = 0; i < e[v].size(); i++) { if (c[e[v][i].first] == -1) { dfs(e[v][i].first, (n ^ e[v][i].second)); } } } int main(...
### Prompt Please provide a Cpp coded solution to the problem described below: Iahub isn't well prepared on geometry problems, but he heard that this year there will be a lot of geometry problems on the IOI selection camp. Scared, Iahub locked himself in the basement and started thinking of new problems of this kind....
#include <bits/stdc++.h> using namespace std; int read() { char ch = getchar(); int x = 0, fl = 1; for (; !isdigit(ch); ch = getchar()) if (ch == '-') fl = -1; for (; isdigit(ch); ch = getchar()) x = (x << 3) + (x << 1) + (ch - '0'); return x * fl; } const int N = 400005; int n, l[N], r[N], num[N], len, d...
### Prompt Please formulate a Cpp solution to the following problem: Iahub isn't well prepared on geometry problems, but he heard that this year there will be a lot of geometry problems on the IOI selection camp. Scared, Iahub locked himself in the basement and started thinking of new problems of this kind. One of th...
#include <bits/stdc++.h> using namespace std; namespace io { const int SIZE = (1 << 21) + 1; char ibuf[SIZE], *iS, *iT, obuf[SIZE], *oS = obuf, *oT = oS + SIZE - 1, c, qu[55]; int f, qr; inline void flush() { fwrite(obuf, 1, oS - obuf, stdout); oS = obuf; } inline void putc(ch...
### Prompt Please create a solution in CPP to the following problem: Iahub isn't well prepared on geometry problems, but he heard that this year there will be a lot of geometry problems on the IOI selection camp. Scared, Iahub locked himself in the basement and started thinking of new problems of this kind. One of th...
#include <bits/stdc++.h> using namespace std; const int N = 500010; int tt = 1; bool w[N], c[N]; int head[N], to[N], nxt[N], in[N], a[N], b[N], v[N]; inline int gi() { int x = 0, o = 1; char ch = getchar(); while (ch != '-' && (ch < '0' || ch > '9')) ch = getchar(); if (ch == '-') o = -1, ch = getchar(); whil...
### Prompt Create a solution in CPP for the following problem: Iahub isn't well prepared on geometry problems, but he heard that this year there will be a lot of geometry problems on the IOI selection camp. Scared, Iahub locked himself in the basement and started thinking of new problems of this kind. One of them is ...
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 10; inline long long rd() { long long x = 0, w = 1; char ch = 0; while (ch < '0' || ch > '9') { if (ch == '-') w = -1; ch = getchar(); } while (ch >= '0' && ch <= '9') { x = (x << 3) + (x << 1) + (ch ^ 48); ch = getchar(); } ...
### Prompt In Cpp, your task is to solve the following problem: Iahub isn't well prepared on geometry problems, but he heard that this year there will be a lot of geometry problems on the IOI selection camp. Scared, Iahub locked himself in the basement and started thinking of new problems of this kind. One of them is...
#include <bits/stdc++.h> using namespace std; const long long mx = 2e5 + 10; set<pair<long long, long long> > ad[mx]; vector<long long> ver; long long ans[mx], l[mx], r[mx]; void dfst(long long v) { while ((long long)ad[v].size()) { long long u = ad[v].begin()->first, yal = ad[v].begin()->second; ad[v].erase(...
### Prompt Develop a solution in Cpp to the problem described below: Iahub isn't well prepared on geometry problems, but he heard that this year there will be a lot of geometry problems on the IOI selection camp. Scared, Iahub locked himself in the basement and started thinking of new problems of this kind. One of th...
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 10; inline long long rd() { long long x = 0, w = 1; char ch = 0; while (ch < '0' || ch > '9') { if (ch == '-') w = -1; ch = getchar(); } while (ch >= '0' && ch <= '9') { x = (x << 3) + (x << 1) + (ch ^ 48); ch = getchar(); } ...
### Prompt Your task is to create a Cpp solution to the following problem: Iahub isn't well prepared on geometry problems, but he heard that this year there will be a lot of geometry problems on the IOI selection camp. Scared, Iahub locked himself in the basement and started thinking of new problems of this kind. One...
#include <bits/stdc++.h> using namespace std; const int maxn = 200005; inline int gi() { char c = getchar(); while (c < '0' || c > '9') c = getchar(); int sum = 0; while ('0' <= c && c <= '9') sum = sum * 10 + c - 48, c = getchar(); return sum; } int n, l[maxn], r[maxn], ans[maxn], *q[maxn], num, cnt; struct ...
### Prompt Please formulate a cpp solution to the following problem: Iahub isn't well prepared on geometry problems, but he heard that this year there will be a lot of geometry problems on the IOI selection camp. Scared, Iahub locked himself in the basement and started thinking of new problems of this kind. One of th...
#include <bits/stdc++.h> using namespace std; const int _ = 1e5 + 5; inline int read() { char ch = '!'; int z = 1, num = 0; while (ch != '-' && (ch < '0' || ch > '9')) ch = getchar(); if (ch == '-') z = -1, ch = getchar(); while (ch <= '9' && ch >= '0') num = (num << 3) + (num << 1) + ch - '0', ch = getch...
### Prompt In Cpp, your task is to solve the following problem: Iahub isn't well prepared on geometry problems, but he heard that this year there will be a lot of geometry problems on the IOI selection camp. Scared, Iahub locked himself in the basement and started thinking of new problems of this kind. One of them is...
#include <bits/stdc++.h> using namespace std; const int maxn = 3e5 + 10; int n; int l[maxn]; int r[maxn]; int clr[maxn]; bool mark[maxn]; vector<int> cmp; map<int, int> compress; stack<pair<int, int>> adj[maxn]; void in(); void solve(); void dfs(int u); void out(); int main() { ios::sync_with_stdio(false); cout.tie...
### Prompt Your challenge is to write a cpp solution to the following problem: Iahub isn't well prepared on geometry problems, but he heard that this year there will be a lot of geometry problems on the IOI selection camp. Scared, Iahub locked himself in the basement and started thinking of new problems of this kind....