output
stringlengths
52
181k
instruction
stringlengths
296
182k
#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 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 MAXN = 3e5 + 10; int n, l[MAXN], r[MAXN], sec[MAXN], sz; int ptr[MAXN]; vector<int> adj[MAXN]; short used[MAXN], cur = 1; void dfs(int v, int p = -1) { for (; ptr[v] < adj[v].size();) { int e = adj[v][ptr[v]++]; if (!used[e]) { used[e] = 1; d...
### 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 = 222222; int n, p[N], c[N], a, b, i; pair<int, int> s[N]; int dp(int x, int t) { if (c[x]) return c[x]; c[x] = t; dp(p[x << 1] >> 1, p[x << 1] & 1 ^ t ^ 1); dp(p[x << 1 | 1] >> 1, p[x << 1 | 1] & 1 ^ t); return t; } int main() { scanf("%d", &n); f...
### 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 MAXN = 2e5 + 10; int n, fir[MAXN], nxt[MAXN << 1], to[MAXN << 1], ans[MAXN << 1], vis[MAXN << 1], tot = 1, d[MAXN << 1]; int d1[MAXN << 1], d2[MAXN << 1]; int l[MAXN], r[MAXN], t[MAXN << 1], cnt; void add(int u, int v) { to[++tot] = v; nxt[tot] = fir[u]; ...
### 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> const int maxn = 1e6 + 9; int Read() { int x(0), f(1); char c = getchar(); while (c < '0' || c > '9') { if (c == '-') f = -1; c = getchar(); } while (c >= '0' && c <= '9') { x = (x << 3ll) + (x << 1ll) + c - '0'; c = getchar(); } return x * f; } struct node { int...
### 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 = 101000 * 2; const int maxM = maxN * 4; int n, m; int num, Num[maxN], L[maxN], R[maxN], Dg[maxN]; int edgecnt = -1, Hd[maxN], Nt[maxM], V[maxM], vis[maxM]; void Add_Edge(int u, int v); void dfs(int u); int main() { memset(Hd, -1, sizeof(Hd)); scanf("%d",...
### 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 = 100030; pair<int, int> l[N], r[N], tot[N * 2]; int n, cnt; vector<int> mp[N << 1]; int vis[N << 1]; int read() { char c = getchar(); int k = 0; for (; c < 48 || c > 57; c = getchar()) ; for (; c > 47 && c < 58; c = getchar()) k = (k << 3) + (k << 1...
### 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> const int N = 400050; int l[N], r[N], num[N], nk; int n, tot; int id(int v) { int L = 1, R = nk, mid; while (L <= R) { mid = (L + R) / 2; if (num[mid] == v) return mid; if (num[mid] < v) L = mid + 1; else R = mid - 1; } } int first[2 * N], to[4 * N], next[4 * N...
### 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; struct sweep { pair<int, int> P; int idx; }; int N, L; sweep B[2 * 100005]; vector<int> G[2 * 100005]; int color[2 * 100005]; bool qx(sweep a, sweep b) { return a.P < b.P; } void doIt(int node) { for (auto it : G[node]) if (!color[it]) color[it] = -1 * color[node]...
### 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 main() { long long q, t, n, k, d1, d2, x, y; cin >> t; while (t--) { cin >> n >> k >> d1 >> d2; q = k; k = n - k; if (k - (d1 + d2) >= 0) { x = (d1 + d2 + q) / 3; y = (q - d1 - d2) / 3; if ((k - (d1 + d2)) % 3 == 0 && (d1 + d2 + q...
### Prompt Generate a Cpp solution to the following problem: There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these...
#include <bits/stdc++.h> using namespace std; long long n, k, d1, d2, ave, x; int main() { int T; cin >> T; while (T--) { cin >> n >> k >> d1 >> d2; if (n % 3) { puts("no"); continue; } ave = n / 3; bool flag = false; if ((k - d1 - 2 * d2) % 3 == 0 && (k - d1 - 2 * d2) >= 0) { ...
### Prompt Please provide a CPP coded solution to the problem described below: There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of you...
#include <bits/stdc++.h> int inf = 1e9 + 7; using namespace std; long long n, k, d1, d2; long long a[4]; int judge() { long long r = n - k, sum = 0; sort(a, a + 3); if (a[0] < 0) { long long ad = -a[0]; for (int i = 0; i < (3); i++) a[i] += ad; } for (int i = 0; i < (3); i++) sum += a[i]; if (sum > ...
### Prompt Generate a Cpp solution to the following problem: There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these...
#include <bits/stdc++.h> using namespace std; int check(long long int n, long long int k, long long int d1, long long int d2) { long long int A[4] = {1, -1, -1, 1}, B[4] = {1, -1, 1, -1}, x, a, b, c, D1, D2; x = n / 3; if (n % 3 != 0) return 0; for (int i = (0); i < (4); ++i) { D1 ...
### Prompt Construct a cpp code solution to the problem outlined: There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for ...
#include <bits/stdc++.h> int t; long long n, k, x, y, z; int chk(long long d1, long long d2) { y = (k + d2 - d1); if (y % 3 != 0) { return 0; } y /= 3; x = y + d1; z = y - d2; if (x < 0 || y < 0 || z < 0) { return 0; } if (x > n || y > n || z > n) { return 0; } return 1; } int main() {...
### Prompt Develop a solution in cpp to the problem described below: There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend f...
#include <bits/stdc++.h> using namespace std; bool solve(int64_t n, int64_t k, int64_t d1, int64_t d2) { if (n % 3 != 0) return false; for (int i = -1; i <= 1; i++) { for (int j = -1; j <= 1; j++) { if (i == 0 || j == 0) continue; int64_t D1 = d1 * i; int64_t D2 = d2 * j; int64_t x2 = (k...
### Prompt Your task is to create a CPP solution to the following problem: There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your fr...
#include <bits/stdc++.h> using namespace std; int main() { int t; scanf("%d", &t); while (t--) { long long n, k, d1, d2; scanf("%lld%lld%lld%lld", &n, &k, &d1, &d2); if (n % 3 != 0) { cout << "no\n"; continue; } long long gamesRem = n - k; bool poss = false; for (int sign1 ...
### Prompt Create a solution in Cpp for the following problem: There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for the...
#include <bits/stdc++.h> using namespace std; long long num; long long n, k, d1, d2; bool solve() { if (n % 3) return false; long long aim = n / 3; bool res = false; if ((k + d1 + d2) % 3 == 0) { long long x2 = (k + d1 + d2) / 3; long long x1 = x2 - d1; long long x3 = x2 - d2; if (x1 <= aim && x...
### Prompt Generate a Cpp solution to the following problem: There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these...
#include <bits/stdc++.h> using namespace std; long long G(long long a, long long b) { if (b == 0) return a; return G(b, a % b); } int main() { int t; cin >> t; while (t--) { long long n, k, d1, d2, a, b, c, t, kk; cin >> n >> k >> d1 >> d2; kk = k - d1 - d1 - d2; if (kk >= 0 && kk % 3 == 0) { ...
### Prompt Please provide a Cpp coded solution to the problem described below: There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of you...
#include <bits/stdc++.h> using namespace std; long long d1, d2; bool res(long long n, long long k, long long a, long long b, long long c) { long long maxi = max(max(a, b), c), still = (n - k) + (a + b + c); if (((a + b + c) > k) || (a < 0) || (b < 0) || (c < 0) || (n % 3 != 0) || ((k - a - b - c) % 3 != 0)) {...
### Prompt Your challenge is to write a cpp solution to the following problem: There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of you...
#include <bits/stdc++.h> using namespace std; long long n, k, d1, d2; bool f(long long a, long long b) { long long c = k - a - b * 2; if (c < 0 || c % 3) return 0; return n / 3 >= a + b + c / 3; } int main() { int t; cin >> t; for (int i = 1; i <= t; i++) { cin >> n >> k >> d1 >> d2; if (n % 3) { ...
### Prompt Please formulate a cpp solution to the following problem: There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend f...
#include <bits/stdc++.h> using namespace std; long long t, n, k, d1, d2; bool solve(long long t1, long long t2, long long t3) { long long sum = t1 + t2 + t3; if (k < sum || (k - sum) % 3) return false; long long t = n - k - (3 * max(max(t1, t2), t3) - sum); if (t < 0 || t % 3) return false; return true; } int...
### Prompt Please formulate a CPP solution to the following problem: There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend f...
#include <bits/stdc++.h> using namespace std; inline void Boost() { ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); } long long n, k, d1, d2, T; bool solve(long long &n, long long &k, long long &d1, long long &d2) { if (n % 3 != 0) return 0; short sign, sign2; long long x1, x2, x3, dd1, dd2, v[3...
### Prompt Develop a solution in CPP to the problem described below: There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend f...
#include <bits/stdc++.h> using namespace std; long long t, n, k, d1, d2, a, b, c; bool make(long long n, long long k, long long d1, long long d2) { long long a, b, c; a = (k + d1 + d1 + d2) / 3; b = a - d1; c = a - d1 - d2; if (a >= b && b >= c && a >= 0 && b >= 0 && c >= 0 && a <= n / 3 && a + b + c ==...
### Prompt Please formulate a Cpp solution to the following problem: There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend f...
#include <bits/stdc++.h> using namespace std; int main() { long long int t, n, k, d1, d2; cin >> t; while (t--) { cin >> n >> k >> d1 >> d2; if (n % 3 != 0) { cout << "no\n"; continue; } long long int x, y, z; y = k + d1 - d2; if (y % 3 == 0 && y >= 0 && y - d1 >= 0) { y ...
### Prompt Please provide a Cpp coded solution to the problem described below: There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of you...
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 10; long long n, k, d1, d2; int solve(long long d1, long long d2) { long long x, y, z; y = (k - d1 + d2) / 3; if ((k - d1 + d2) % 3 != 0) return 0; x = y + d1; z = y - d2; if (x >= 0 && x <= n / 3 && y >= 0 && y <= n / 3 && z >= 0 && z <= n /...
### Prompt Please formulate a Cpp solution to the following problem: There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend f...
#include <bits/stdc++.h> using namespace std; int calc(long long n, long long k, long long a1, long long a2, long long a3) { long long sum; if (a2 < a3) { swap(a2, a3); } if (a1 < a2) { swap(a1, a2); } if (a2 < a3) { swap(a2, a3); } if (a1 < 0 || a2 < 0 || a3 < 0) { return 0; } sum =...
### Prompt Your task is to create a CPP solution to the following problem: There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your fr...
#include <bits/stdc++.h> using namespace std; int main() { long long int t; scanf("%lld", &t); while (t--) { long long int n, k, d1, d2, x, y, z; scanf("%lld", &n); scanf("%lld", &k); scanf("%lld", &d1); scanf("%lld", &d2); x = (k + 2 * d1 + d2) / 3; y = x - d1; z = y - d2; if ...
### Prompt Create a solution in Cpp for the following problem: There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for the...
#include <bits/stdc++.h> using namespace std; int main() { long long T, n, k, d1, d2, x, y, z; scanf("%lld", &T); while (T--) { scanf("%lld%lld%lld%lld", &n, &k, &d1, &d2); int flag = 0; if ((k - d1 - d2) % 3 == 0 && k - d1 - d2 >= 0) { y = (k - d1 - d2) / 3; x = y + d1; z = y + d2; ...
### Prompt Please provide a CPP coded solution to the problem described below: There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of you...
#include <bits/stdc++.h> using namespace std; int t; long long n, k, d1, d2; long long A, W; long long add1, add2, add3; bool moze; bool try1() { A = k - d1 - d2 - d2; if (A % 3 != 0 || A < 0) return false; A /= 3; if (A + d1 + d2 > W) return false; if (A + d2 > W) return false; if (A > W) return false; a...
### Prompt Please create a solution in cpp to the following problem: There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend f...
#include <bits/stdc++.h> using namespace std; long long a[10], b[10]; int main() { long long t, n, k, d1, d2; scanf("%I64d", &t); for (int i = 1; i <= t; i++) { scanf("%I64d%I64d%I64d%I64d", &n, &k, &d1, &d2); if (d1 > d2) { swap(d1, d2); } a[1] = d1 * 2 + d2; a[2] = d1 + d2 * 2; a[3...
### Prompt Your task is to create a Cpp solution to the following problem: There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your fr...
#include <bits/stdc++.h> bool solve(long long k, long long y, long long z, long long &x1, long long &x2, long long &x3) { if ((k - y - 2 * z) % 3 != 0) return (false); x3 = (k - y - 2 * z) / 3; x2 = x3 + z; x1 = x2 + y; return (x1 >= 0 && x2 >= 0 && x3 >= 0); } bool canwin(long long n, long long x1...
### Prompt Construct a CPP code solution to the problem outlined: There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for ...
#include <bits/stdc++.h> using namespace std; const int INF = (1 << 30) - 1; const int mod = 1000000007; const int maxn = 1000005; int flag; long long n, k, d1, d2; void f(long long a, long long b, long long c) { if (n % 3 || a % 3 || b % 3 || c % 3) { flag = 0; return; } long long ans = n / 3; a = a / ...
### Prompt Please formulate a Cpp solution to the following problem: There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend f...
#include <bits/stdc++.h> using namespace std; bool checking(long long x, long long y, long long z, long long n, long long k) { if (x < 0 || y < 0 || z < 0) return false; if ((x + y + z + n - k) % 3) return false; else { long long q = (x + y + z + n - k) / 3; if (q >= x && q >= y && q >= z) retur...
### Prompt Please provide a cpp coded solution to the problem described below: There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of you...
#include <bits/stdc++.h> using namespace std; bool check(long long n, long long k, long long d1, long long d2) { long long b = k; long long a = b - d1; long long c = b + d2; long long sum = a + b + c; if (sum % 3 != k % 3) { return false; } a -= (sum - k) / 3; b -= (sum - k) / 3; c -= (sum - k) / ...
### Prompt Generate a CPP solution to the following problem: There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these...
#include <bits/stdc++.h> using namespace std; long long n, k, d1, d2; long long valid(long long w1, long long w2, long long w3) { if (w1 < 0 || w2 < 0 || w3 < 0) { return 0; } if (w1 + w2 + w3 != k) { return 0; } if (n % 3 != 0) { return 0; } long long d = n / 3; if (w1 > d || w2 > d || w3 >...
### Prompt Please formulate a Cpp solution to the following problem: There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend f...
#include <bits/stdc++.h> using namespace std; void FastIO() { ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL); } int64_t modpow(int64_t a, int64_t p, int64_t mod) { int64_t ret = 1; while (p) { if (p & 1) ret = (ret * a) % mod; a = (a * a) % mod; p /= 2; } return ret; } int64_t pow...
### Prompt Your task is to create a cpp solution to the following problem: There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your fr...
#include <bits/stdc++.h> using namespace std; struct comp { bool operator()(const pair<int, int> &a, const pair<int, int> &b) { return a.second > b.second; } }; struct myclass { bool operator()(const pair<int, int> &a, const pair<int, int> &b) { return a.first > b.first; } } myobject; inline void in(int...
### Prompt Construct a CPP code solution to the problem outlined: There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for ...
#include <bits/stdc++.h> using namespace std; int main() { long long n, k, d1, d2; int t; scanf("%d", &t); while (t--) { cin >> n >> k >> d1 >> d2; long long left = n - k; long long d = d1 + 2 * d2; long long twins = d1 + d1 + d2; if (d <= left && twins <= k && (k - twins) % 3 == 0) { ...
### Prompt Create a solution in CPP for the following problem: There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for the...
#include <bits/stdc++.h> using namespace std; int main() { long long T, n, k, a, b; cin >> T; while (T--) { cin >> n >> k >> a >> b; n -= k; bool flag = 0; if (a < b) swap(a, b); if ((2 * a + b) <= n && (n - 2 * a - b) % 3 == 0 && (2 * b + a) <= k && (k - 2 * b - a) % 3 == 0) fla...
### Prompt Your task is to create a cpp solution to the following problem: There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your fr...
#include <bits/stdc++.h> using namespace std; const double pi = acos(-1.0); const double eps = 1e-11; const int INFINITE = 0x3f3f3f3f; template <class T> inline void checkmin(T &a, T b) { if (b < a) a = b; } template <class T> inline void checkmax(T &a, T b) { if (b > a) a = b; } template <class T> inline T sqr(T x...
### Prompt Please provide a CPP coded solution to the problem described below: There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of you...
#include <bits/stdc++.h> using namespace std; bool cond(long long num, long long lim) { if (num <= lim && num >= 0 && num % 3 == 0) return true; return false; } int main() { int t; scanf("%d", &t); while (t--) { long long n, x, y, z, a, b, c; bool ans = false; cin >> n >> x >> y >> z; if (n % ...
### Prompt Construct a Cpp code solution to the problem outlined: There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for ...
#include <bits/stdc++.h> using namespace std; int check(long long n, long long k, long long d1, long long d2) { return (k - d1 - d2 - d2) >= 0 && (k - d1 - d2 - d2) % 3 == 0 && (n - k - d1 - d1 - d2) >= 0 && (n - k - d1 - d1 - d2) % 3 == 0; } int main() { int ca; long long n, k, d1, d2; while (~scanf("...
### Prompt Please create a solution in cpp to the following problem: There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend f...
#include <bits/stdc++.h> using namespace std; const int LIM = 100005; int main(int argc, char* argv[]) { long long T, n, k, d1, d2, t1, t2, t3; long long m; int r; bool flag; cin >> T; while (T-- > 0LL) { cin >> n >> k >> d1 >> d2; if (n % 3 != 0) { printf("no\n"); continue; } m ...
### Prompt Please create a solution in cpp to the following problem: There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend f...
#include <bits/stdc++.h> using namespace std; int main() { int t; scanf("%d", &t); for (int i = 0; i < t; i++) { long long n, k, d1, d2; long long x1, x2, x3, av; bool tag = false; cin >> n >> k >> d1 >> d2; if (n % 3) { printf("no\n"); continue; } av = n / 3; if ((2 * ...
### Prompt Generate a Cpp solution to the following problem: There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these...
#include <bits/stdc++.h> #pragma comment(linker, "/STACK:100000000000000") using namespace std; const long long int INF = 2e9 + 1; int main() { int T; cin >> T; for (int(Q) = 0; (Q) < (T); (Q)++) { long long int n, k, d1, d2; cin >> n >> k >> d1 >> d2; bool can = false; for (int(i) = 0; (i) < (2);...
### Prompt Your challenge is to write a cpp solution to the following problem: There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of you...
#include <bits/stdc++.h> using namespace std; long long n, k, d1, d2; bool isok(long long d1, long long d2) { long long x, y, z; if (k - 2 * d2 - d1 < 0) return false; if ((k - 2 * d2 - d1) % 3) return false; z = (k - 2 * d2 - d1) / 3; y = d2 + z; x = d1 + y; if (x < 0 || y < 0) return false; long long ...
### Prompt Generate a CPP solution to the following problem: There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these...
#include <bits/stdc++.h> using namespace std; bool check(long long n, long long k, long long d1, long long d2) { if (n % 3) return 0; long long win = n / 3; for (long long sgn1 = -1; sgn1 <= 1; sgn1++) { for (long long sgn2 = -1; sgn2 <= 1; sgn2++) { if (sgn1 == 0 || sgn2 == 0) continue; long long...
### Prompt Develop a solution in Cpp to the problem described below: There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend f...
#include <bits/stdc++.h> using namespace std; long long n, k, d1, d2; bool Possibility(long long n, long long k, long long d1, long long d2) { if (n % 3) return false; if (d1 + d2 > k) return false; if (n - k - 3 * max(d1, d2) + d1 + d2 < 0) return false; if ((n - k - 3 * max(d1, d2) + d1 + d2) % 3 > 0) return ...
### Prompt Create a solution in CPP for the following problem: There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for the...
#include <bits/stdc++.h> using namespace std; long long t, n, k, d1, d2; bool _(long long a, long long b) { return (a / 3 >= b && a / 3 * 3 == a && a <= n); } bool x() { if (n % 3) return false; if (_(n - k + d1 + d2 * 2, d1 + d2)) return true; if (_(n - k + d2 + d1 * 2, d1 + d2)) return true; if (_(n - k + d...
### Prompt Construct a Cpp code solution to the problem outlined: There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for ...
#include <bits/stdc++.h> using namespace std; long long n, k, d1, d2; bool check(long long ofsa, long long ofsb) { long long c_3 = (k - ofsa - ofsb); if (c_3 % 3 != 0) return 0; long long c = c_3 / 3, a = c + ofsa, b = c + ofsb; if (a < 0 || b < 0 || c < 0) return 0; if (a > n / 3 || b > n / 3 || c > n / 3) r...
### Prompt Your challenge is to write a cpp solution to the following problem: There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of you...
#include <bits/stdc++.h> using namespace std; int main() { long long tc, n, k, d1, d2; cin >> tc; while (tc--) { cin >> n >> k >> d1 >> d2; if (false) { printf("no\n"); } else { if (false) { printf("no\n"); } else { const long long r = n - k; long long x; ...
### Prompt Your challenge is to write a Cpp solution to the following problem: There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of you...
#include <bits/stdc++.h> using namespace std; long long Max(long long a, long long b) { return a > b ? a : b; } int main() { long long t, n, k, d1, d2, m; int flag; cin >> t; while (t--) { flag = 1; cin >> n >> k >> d1 >> d2; if (n % 3 != 0) { cout << "no\n"; continue; } if (k < ...
### Prompt In CPP, your task is to solve the following problem: There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for th...
#include <bits/stdc++.h> using namespace std; long long n, k, d1, d2, t, a, b, c; void solve() { scanf("%I64d%I64d%I64d%I64d", &n, &k, &d1, &d2); if (n % 3) { printf("no\n"); return; } t = n / 3; bool ok = false; if ((d1 * 2 + d2 + k) % 3 == 0) { a = (k + d1 * 2 + d2) / 3; b = a - d1; c ...
### Prompt Please create a solution in Cpp to the following problem: There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend f...
#include <bits/stdc++.h> using namespace std; int main() { int T, i, j, ok; long long n, k, d1, d2, r, a, b, c; for (scanf("%d", &T); T--;) { scanf("%I64d%I64d%I64d%I64d", &n, &k, &d1, &d2); if (n % 3) { puts("no"); continue; } ok = 0; for (i = -1; i <= 1; i += 2) for (j = -1...
### Prompt Construct a Cpp code solution to the problem outlined: There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for ...
#include <bits/stdc++.h> using namespace std; long long int max(long long int a, long long int b) { if (a > b) return a; else return b; } long long int min(long long int a, long long int b) { if (a < b) return a; else return b; } const int dx[4] = {-1, 1, 0, 0}; const int dy[4] = {0, 0, -1, 1}; ...
### Prompt Please formulate a Cpp solution to the following problem: There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend f...
#include <bits/stdc++.h> using namespace std; long long n, k; inline bool Solve(const long long d1, const long long d2) { long long p = k + 2 * d1 + d2; if (p % 3) return 0; long long x1 = p / 3; if (x1 < 0 || x1 > n / 3) return 0; long long x2 = x1 - d1; if (x2 < 0 || x2 > n / 3) return 0; long long x3 =...
### Prompt Develop a solution in CPP to the problem described below: There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend f...
#include <bits/stdc++.h> using namespace std; void calc() { long long n, k, d1, d2; cin >> n >> k >> d1 >> d2; if (n % 3 != 0) { cout << "no" << endl; return; } long long a[3]; for (int i = 0; i < 2; i++) for (int j = 1; j < 3; j++) { a[0] = a[1] = a[2] = 0; if (i == j) { a[0...
### Prompt In CPP, your task is to solve the following problem: There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for th...
#include <bits/stdc++.h> using namespace std; long long n, k, d1, d2, a, b, ans; void work() { scanf("%I64d %I64d %I64d %I64d", &n, &k, &d1, &d2), ans = 0; a = k + 2 * d1 + d2, b = k - d1 - 2 * d2; if ((n >= a) && ((n - a) % 3 == 0) && (b >= 0) && (b % 3 == 0)) ans++; a = k + 2 * max(d1, d2) - min(d1, d2), b = ...
### Prompt Please formulate a cpp solution to the following problem: There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend f...
#include <bits/stdc++.h> using namespace std; int main() { long long int t, n, k, d1, d2, i, j; cin >> t; while (t--) { cin >> n >> k >> d1 >> d2; for (i = 0; i < 2; i++) { for (j = 0; j < 2; j++) { long long int cd1 = d1 * (i == 0 ? 1 : -1); long long int cd2 = d2 * (j == 0 ? 1 : -1...
### Prompt Generate a Cpp solution to the following problem: There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these...
#include <bits/stdc++.h> using namespace std; long long n; bool solve(long long k, long long d1, long long d2, long long m) { long long t2 = (k + d2 - d1) / 3; if ((k + d2 - d1) % 3 != 0) return false; long long t1 = d1 + t2; long long t3 = t2 - d2; long long maxV = max(t1, max(t2, t3)); long long need = 0;...
### Prompt Generate a cpp solution to the following problem: There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these...
#include <bits/stdc++.h> using namespace std; long long d1, d2, tests, n, k, d, ans; long long tob; long long v1, v2, v3, has, need; long long up, dwn; void check() { long long temp = k - has; if (temp < 0 || temp % 3 > 0) return; long long rem = n - k; rem -= need; if (rem < 0) return; if (rem % 3) return;...
### Prompt Your task is to create a Cpp solution to the following problem: There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your fr...
#include <bits/stdc++.h> using namespace std; long long n, k, d1, d2; bool check(long long a, long long b, long long c) { if (a > b) swap(a, b); if (b > c) swap(b, c); if (a > b) swap(a, b); if (a < 0) { b -= a, c -= a; a = 0; } if (a + b + c > k) return 0; if ((k - (a + b + c)) % 3) return 0; l...
### Prompt Please provide a CPP coded solution to the problem described below: There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of you...
#include <bits/stdc++.h> #pragma GCC optimize("O2") using namespace std; const int MAX = 2e5 + 5; const long long MAX2 = 11; const int MOD = 1000000000 + 7; const long long INF = 20000; const int dr[] = {1, 0, -1, 0, 1, 1, -1, -1}; const int dc[] = {0, 1, 0, -1, 1, -1, 1, -1}; const double pi = acos(-1); long long tc, ...
### Prompt Construct a cpp code solution to the problem outlined: There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for ...
#include <bits/stdc++.h> using namespace std; long long n, k; bool yes(long long a, long long b) { long long x; x = k - 2 * a - b; if (x < 0 || x % 3) return false; x /= 3; if (x < 0 || x + a < 0 || x + a + b < 0) return false; if (n % 3) return false; if (x > n / 3 || x + a > n / 3 || x + a + b > n / 3) ...
### Prompt Please create a solution in Cpp to the following problem: There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend f...
#include <bits/stdc++.h> using namespace std; long long t, n, k, d1, d2; int solve(long long a, long long b, long long c) { long long m = min(min(a, b), c); a -= m; b -= m; c -= m; if (a + b + c > k || (a + b + c - k) % 3) return 0; m = max(max(a, b), c); long long x = m - a + m - b + m - c; if (x <= n ...
### Prompt Please create a solution in CPP to the following problem: There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend f...
#include <bits/stdc++.h> using namespace std; inline long long read() { long long x = 0, f = 1; char ch = getchar(); while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); } while (ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); } return x * f; } long long n...
### Prompt Please create a solution in CPP to the following problem: There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend f...
#include <bits/stdc++.h> #pragma comment(linker, "/STACK:102400000,102400000") using namespace std; bool judge(long long k, long long x) { if (k >= x && (k - x) % 3 == 0) return true; return false; } int main() { int T; scanf("%d", &T); while (T--) { long long n, k, d1, d2, a, b, c, flag = 0; scanf("%...
### Prompt Develop a solution in cpp to the problem described below: There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend f...
#include <bits/stdc++.h> using namespace std; const double eps(1e-8); int t; long long n, k, d1, d2, x1, x2, x3; bool check(long long x) { if (0 <= x && x <= n / 3) { return true; } return false; } int main() { cin >> t; while (t--) { cin >> n >> k >> d1 >> d2; if (n % 3) { cout << "no" << e...
### Prompt Please create a solution in cpp to the following problem: There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend f...
#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; } int T; signed long long N, K, D1, D2; void solve() { int f, i, j, k, l, x, y; cin >> T; for (i = 0; i < T; i++) { cin >> N >> K >> D1 >> D2; int ok = 0; for (j = ...
### Prompt Please create a solution in CPP to the following problem: There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend f...
#include <bits/stdc++.h> using namespace std; int main() { int T; long long n, k, d1, d2; for (scanf("%d", &T); T--;) { scanf("%I64d%I64d%I64d%I64d", &n, &k, &d1, &d2); if (n % 3 != 0) { printf("no\n"); continue; } bool flag = false; if ((k - (d1 + d2)) % 3 == 0) { long long ...
### Prompt Generate a cpp solution to the following problem: There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these...
#include <bits/stdc++.h> using namespace std; int main() { int i, j, _; long long n, k, d1, d2; long long win[3]; scanf("%d", &_); while (_--) { scanf("%I64d%I64d%I64d%I64d", &n, &k, &d1, &d2); if (n % 3 != 0) { printf("no\n"); continue; } int flag = 0; for (i = 0; i < 4; i++) ...
### Prompt Please formulate a CPP solution to the following problem: There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend f...
#include <bits/stdc++.h> using namespace std; long long n, k; bool f(long long a, long long b) { long long p[3] = {}; long long r = k - b - a - b; if (r % 3 != 0) return false; p[2] = r / 3; p[1] = p[2] + b; p[0] = p[1] + a; if (p[1] < 0 || p[2] < 0 || p[0] < 0) return false; if (n % 3 != 0) return fals...
### Prompt Create a solution in CPP for the following problem: There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for the...
#include <bits/stdc++.h> using namespace std; int dx[] = {1, 1, -1, -1}; int dy[] = {1, -1, -1, 1}; long long int n, k, d1, d2, rem; bool _solve(long long int w1, long long int w2, long long int w3) { long long int tar = n / 3; if (w1 < 0 || w2 < 0 || w3 < 0) return false; if (tar >= w1 && tar >= w2 && tar >= w3 ...
### Prompt Please provide a CPP coded solution to the problem described below: There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of you...
#include <bits/stdc++.h> using namespace std; int main() { long long t, i, j, n, k, d1, d2; while (cin >> t) { while (t--) { scanf("%lld %lld %lld %lld", &n, &k, &d1, &d2); if (n % 3) { puts("no"); continue; } int f = 0; if (d1 + 2 * d2 <= k) if ((k - (d1 + ...
### Prompt Construct a Cpp code solution to the problem outlined: There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for ...
#include <bits/stdc++.h> using namespace std; bool solve(long long n, long long k, long long d1, long long d2) { n -= k; long long tmp = k - d1 - d1 - d2; if (tmp % 3 || tmp < 0) return false; long long a[3] = {tmp / 3, tmp / 3 + d1, tmp / 3 + d1 + d2}; sort(a, a + 3); if (a[0] < 0) return false; long lon...
### Prompt Generate a CPP solution to the following problem: There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these...
#include <bits/stdc++.h> using namespace std; vector<long long int> bin_s(long long int k, long long int d1, long long int d2, long long int a, long long int b) { long long int lo = 0, hi = k + 1; while (lo < hi) { long long int mid = (lo + hi) / 2; long long int x = mid + (a * d...
### Prompt In Cpp, your task is to solve the following problem: There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for th...
#include <bits/stdc++.h> using namespace std; bool isPossible(long long n, long long k, long long d1, long long d2) { int i, j; if (n % 3 != 0) return false; for (i = -1; i <= 1; i += 2) for (j = -1; j <= 1; j += 2) { long long D1 = d1 * i; long long D2 = d2 * j; if ((k - 2 * D2 - D1) % 3 !=...
### Prompt Your task is to create a Cpp solution to the following problem: There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your fr...
#include <bits/stdc++.h> using namespace std; int main() { int T; scanf("%d", &T); for (int tt = 0; tt < (T); ++tt) { long long n, k, d1, d2; cin >> n, cin >> k, cin >> d1, cin >> d2; long long cur; bool ok = false; cur = 2 * d1 + d2; if (k - cur >= 0 and (k - cur) % 3 == 0) { long l...
### Prompt Your task is to create a cpp solution to the following problem: There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your fr...
#include <bits/stdc++.h> using namespace std; const int dx[] = {-1, 0, 0, 1}; const int dy[] = {0, -1, 1, 0}; int main() { int t; cin >> t; for (int i = 0, _n = (t); i < _n; i++) { long long n, k, d1, d2; cin >> n >> k; cin >> d1 >> d2; long long t1, t2, t3; t2 = k - d1 + d2; if (t2 >= 0 &...
### Prompt In Cpp, your task is to solve the following problem: There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for th...
#include <bits/stdc++.h> using namespace std; int ans; long long n, k, d1, d2, a, b, c; void gettin(long long x, long long y) { if (n % 3) return; long long aa, bb, cc; if ((k - x - y) < 0) return; if ((k - x - y) % 3) return; aa = (k - x - y) / 3; bb = aa + x; cc = aa + y; if (aa > n / 3) return; if ...
### Prompt Please create a solution in cpp to the following problem: There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend f...
#include <bits/stdc++.h> using namespace std; long long n, k, d1, d2; void solve() { scanf("%lld%lld%lld%lld", &n, &k, &d1, &d2); if (d1 < d2) swap(d1, d2); long long mi[] = {d1 + d2, d1 + 2 * d2, d1 * 2 - d2, d2 + 2 * d1}; long long ned[] = {d1 * 2 - d2, d1 * 2 + d2, d1 + d2, d2 * 2 + d1}; long long has = n ...
### Prompt Please provide a cpp coded solution to the problem described below: There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of you...
#include <bits/stdc++.h> using namespace std; long long total, n, k, d1, d2; int main() { cin >> total; while (total--) { cin >> n >> k >> d1 >> d2; if (n % 3 != 0) { cout << "no\n"; continue; } long long tar = n / 3; if ((d2 + k - d1) % 3 == 0) { long long x1 = (d2 + k - d1) /...
### Prompt Construct a CPP code solution to the problem outlined: There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for ...
#include <bits/stdc++.h> using namespace std; long long t, n, k, d1, d2; int main() { cin >> t; for (__typeof(t) i = 0; i < (t); i++) { cin >> n >> k >> d1 >> d2; if (n % 3 != 0) { cout << "no\n"; continue; } bool flag = false; for (int i = -1; i <= 1; i++) { for (int j = -1; j...
### Prompt Your task is to create a Cpp solution to the following problem: There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your fr...
#include <bits/stdc++.h> using namespace std; const long long N = 10; bool valid(long long x, long long y, long long z) { if (x < 0) return false; if (y < 0) return false; if (z < 0) return false; return true; } int main() { long long t; cin >> t; while (t--) { long long n, k, d1, d2, diff, sum, mx; ...
### Prompt Generate a cpp solution to the following problem: There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these...
#include <bits/stdc++.h> using namespace std; class C_ {}; template <typename T> C_& operator<<(C_& __m, const T& __s) { if (!1) cerr << "\E[91m" << __s << "\E[0m"; return __m; } C_ merr; struct __s { __s() { if (1) { ios_base::Init i; cin.sync_with_stdio(0); cin.tie(0); } } ~__s() {...
### Prompt Please create a solution in cpp to the following problem: There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend f...
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { long long n, k, d1, d2; cin >> n >> k >> d1 >> d2; if (d1 < d2) swap(d1, d2); if (k >= d1 + d1 + d2 && (k - (d1 + d1 + d2)) % 3 == 0 && n - k >= d2 + d1 + d2 && (n - k - (d2 + d1 + d2)) % 3 == 0) { ...
### Prompt Please provide a Cpp coded solution to the problem described below: There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of you...
#include <bits/stdc++.h> using namespace std; template <class T> inline T gcd(T a, T b) { return (b) == 0 ? (a) : gcd((b), ((a) % (b))); } template <class T> inline T lcm(T a, T b) { return ((a) / gcd((a), (b)) * (b)); } template <class T> inline T BigMod(T Base, T power, T M = 1000000007) { if (power == 0) retur...
### Prompt Generate a Cpp solution to the following problem: There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these...
#include <bits/stdc++.h> using namespace std; const int inf = 2000000000; static inline int Rint() { struct X { int dig[256]; X() { for (int i = '0'; i <= '9'; ++i) dig[i] = 1; dig['-'] = 1; } }; static X fuck; int s = 1, v = 0, c; for (; !fuck.dig[c = getchar()];) ; if (c == '-'...
### Prompt In cpp, your task is to solve the following problem: There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for th...
#include <bits/stdc++.h> using namespace std; long long t, ti, d1, d2, n, k, p, ok = 0, maxim, v; int check(long long s1, long long s2, long long s3) { if (s1 + s2 + s3 > k) return 0; if ((k - s1 - s2 - s3) % 3 != 0) return 0; maxim = s1; if (s2 > maxim) maxim = s2; if (s3 > maxim) maxim = s3; v = 3 * maxim...
### Prompt Generate a CPP solution to the following problem: There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these...
#include <bits/stdc++.h> using namespace std; int t, i; long long n, k, d1, d2; bool solve(long long _d1, long long _d2) { long long y = k - _d1 - _d2; if (y % 3) return false; long long x = y; if (x < 0 || x > n) return false; x = 3 * _d1 + y; if (x < 0 || x > n) return false; x = 3 * _d2 + y; if (x < ...
### Prompt Please create a solution in CPP to the following problem: There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend f...
#include <bits/stdc++.h> using namespace std; long long n, k, d1, d2; int T; bool check(long long a, long long b, long long c) { if (a + b + c > k) return 0; if ((k - a - b - c) % 3) return 0; if (a < b) swap(a, b); if (a < c) swap(a, c); long long nd = a - b + a - c; if (nd > n - k) return 0; if ((n - k ...
### Prompt Generate a Cpp solution to the following problem: There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these...
#include <bits/stdc++.h> using namespace std; class Codeforce { public: bool task(long long n, long long k, long long d1, long long d2) { if (n % 3 != 0) return false; long long t = n / 3; if (d1 > t || d2 > t) return false; if (((k - d1 + d2) % 3 == 0 && (k - d1 + d2) / 3 >= 0 && (k - d1 + ...
### Prompt Develop a solution in cpp to the problem described below: There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend f...
#include <bits/stdc++.h> #pragma warning(disable : 4996) using namespace std; const int IT_MAX = 131072; const long long MOD = 1000000007; const int INF = 2034567891; const long long LL_INF = 1234567890123456789ll; int main() { int T; scanf("%d", &T); for (int tc = 1; tc <= T; tc++) { long long N, K, d1, d2, ...
### Prompt Develop a solution in Cpp to the problem described below: There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend f...
#include <bits/stdc++.h> using namespace std; bool Check(long long n, long long k, long long d1, long long d2) { if ((k + d1 + d2) % 3) return false; long long w2 = (k + d1 + d2) / 3, w1 = w2 - d1, w3 = w2 - d2; return w1 >= 0 && w1 <= n && w2 >= 0 && w2 <= n && w3 >= 0 && w3 <= n; } int main() { int cas; cin...
### Prompt In Cpp, your task is to solve the following problem: There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for th...
#include <bits/stdc++.h> using namespace std; int f[4][2] = {{1, 1}, {1, -1}, {-1, 1}, {-1, -1}}; int main() { int t; scanf("%d", &t); while (t--) { long long n, k, _d1, _d2; scanf("%I64d%I64d%I64d%I64d", &n, &k, &_d1, &_d2); if (n % 3 != 0) { printf("no\n"); continue; } bool flag ...
### Prompt Please create a solution in Cpp to the following problem: There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend f...
#include <bits/stdc++.h> using namespace std; template <class T1, class T2> ostream& operator<<(ostream& out, pair<T1, T2> pair) { return out << "(" << pair.first << ", " << pair.second << ")"; } long long N, K, D1, D2; bool check(long long a, long long b, long long c) { if (N % 3) return false; long long temp = ...
### Prompt Please formulate a Cpp solution to the following problem: There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend f...
#include <bits/stdc++.h> using namespace std; int main() { int T; long long n, k, d1, d2, a, b, c, fuck; scanf("%d", &T); while (T--) { scanf("%I64d%I64d%I64d%I64d", &n, &k, &d1, &d2); if (n % 3 != 0) { printf("no\n"); continue; } long long ave = n / 3; a = d1; b = 0; c =...
### Prompt Please formulate a Cpp solution to the following problem: There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend f...
#include <bits/stdc++.h> using namespace std; int main() { int t; scanf("%d", &t); while (t--) { long long n, k, d1, d2; cin >> n >> k >> d1 >> d2; long long p = n - k; if (p >= 2 * d1 + d2 && k >= d1 + 2 * d2) { if ((p - (2 * d1 + d2)) % 3 == 0 && (k - d1 - 2 * d2) % 3 == 0) { print...
### Prompt In Cpp, your task is to solve the following problem: There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for th...
#include <bits/stdc++.h> using namespace std; long long n, K, d1, d2, x, y, z, tmp, r; void doit() { scanf("%I64d%I64d%I64d%I64d", &n, &K, &d1, &d2); if (n % 3) { printf("no\n"); return; } for (int key1 = -1; key1 <= 1; key1 += 2) for (int key2 = -1; key2 <= 1; key2 += 2) { tmp = K - key1 * d1...
### Prompt Create a solution in CPP for the following problem: There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for the...
#include <bits/stdc++.h> const int mod = 1000000007; using namespace std; long long x, y, z, t, n, k, d1, d2; ; bool check() { if (x >= 0 && y >= 0 && z >= 0 && x % 3 == 0 && y % 3 == 0 && z % 3 == 0) { x /= 3; y /= 3; z /= 3; long long mx = max(max(x, y), z); if ((n - (mx - x) - (mx - y) - (mx - ...
### Prompt Create a solution in CPP for the following problem: There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for the...