Search is not available for this dataset
name
stringlengths
2
112
description
stringlengths
29
13k
source
int64
1
7
difficulty
int64
0
25
solution
stringlengths
7
983k
language
stringclasses
4 values
451_C. Predict Outcome of the Game
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 k games. Your friend did not tell exact number of wins of each...
2
9
for t in xrange(input()): n, k, d1, d2 = map(int, raw_input().split()) def p(n,k,d1,d2): if n % 3 == 0: x2 = (k-d1+d2)/3 if (k-d1+d2) % 3 == 0 and x2 >= 0 and x2 <= k: x1, x3 = d1+x2, x2-d2 if x1 >= 0 and x1 <= k and x3 >= 0 and x3 <= k: if x1 <= n/3 and x2 <= n/3 and x3 <= n/3: return 1 ...
PYTHON
451_C. Predict Outcome of the Game
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 k games. Your friend did not tell exact number of wins of each...
2
9
#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...
CPP
451_C. Predict Outcome of the Game
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 k games. Your friend did not tell exact number of wins of each...
2
9
import java.io.*; import java.util.*; import java.math.*; public class Main { FastScanner in; PrintWriter out; static class FastScanner { BufferedReader br; StringTokenizer st; FastScanner(InputStream in) { br = new BufferedReader(new InputStreamReader(in)); ...
JAVA
451_C. Predict Outcome of the Game
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 k games. Your friend did not tell exact number of wins of each...
2
9
def test(a, k, n): mn = abs(min(a)) a = [x + mn for x in a] s = sum(a) if k - s < 0 or (k - s) % 3 != 0: return False mx = max(a) s = sum([mx - x for x in a]) return n - s >= 0 and (n - s) % 3 == 0; t = int(raw_input()) for i in xrange(t): n, k, d0, d1 = map(int, raw_input().sp...
PYTHON
451_C. Predict Outcome of the Game
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 k games. Your friend did not tell exact number of wins of each...
2
9
import java.util.ArrayList; import java.util.List; import java.util.Scanner; public class SortingArr { public static void main(String[] args) { Scanner in = new Scanner(System.in); int t = in.nextInt(); for(int i = 0; i < t; ++i) { long m = in.nextLong(); ...
JAVA
451_C. Predict Outcome of the Game
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 k games. Your friend did not tell exact number of wins of each...
2
9
#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...
CPP
451_C. Predict Outcome of the Game
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 k games. Your friend did not tell exact number of wins of each...
2
9
#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; ...
CPP
451_C. Predict Outcome of the Game
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 k games. Your friend did not tell exact number of wins of each...
2
9
#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 < ...
CPP
451_C. Predict Outcome of the Game
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 k games. Your friend did not tell exact number of wins of each...
2
9
#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 ...
CPP
451_C. Predict Outcome of the Game
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 k games. Your friend did not tell exact number of wins of each...
2
9
q = int(input()) while q > 0: n, k, d1, d2 = map(int, input().split()) if d1 > d2: d1, d2 = d2, d1 if k - 2 * d1 - d2 >= 0 and (k - 2 * d1 - d2) % 3 == 0 and \ (n - k) - d1 - 2 * d2 >= 0 and ((n - k) - d1 - 2 * d2) % 3 == 0: print('yes') elif k - 2 * d2 - d1 >= 0 and (k - 2 ...
PYTHON3
451_C. Predict Outcome of the Game
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 k games. Your friend did not tell exact number of wins of each...
2
9
import sys lines = sys.stdin.readlines() ''' (n, p) = map(int, lines[0].strip().split(" ")) ranges = [] for i in range(1, n+1): (l, r) = map(int, lines[i].strip().split(" ")) ranges.append((l,r)) probs = [] for lr in ranges: poss = lr[1]//p - (lr[0]-1)//p probs.append(poss/(lr[1]-lr[0]+1)) res = 0 fo...
PYTHON3
451_C. Predict Outcome of the Game
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 k games. Your friend did not tell exact number of wins of each...
2
9
#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...
CPP
451_C. Predict Outcome of the Game
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 k games. Your friend did not tell exact number of wins of each...
2
9
#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}; ...
CPP
451_C. Predict Outcome of the Game
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 k games. Your friend did not tell exact number of wins of each...
2
9
#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 =...
CPP
451_C. Predict Outcome of the Game
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 k games. Your friend did not tell exact number of wins of each...
2
9
import java.io.InputStreamReader; import java.io.IOException; import java.util.InputMismatchException; import java.io.BufferedReader; import java.io.OutputStream; import java.io.PrintWriter; import java.io.Reader; import java.io.Writer; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution ...
JAVA
451_C. Predict Outcome of the Game
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 k games. Your friend did not tell exact number of wins of each...
2
9
#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...
CPP
451_C. Predict Outcome of the Game
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 k games. Your friend did not tell exact number of wins of each...
2
9
#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 = ...
CPP
451_C. Predict Outcome of the Game
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 k games. Your friend did not tell exact number of wins of each...
2
9
def check(x,a,b,c): #print(x,a,b,c) n1=n//3 if n%3!=0 or (abs(n1-a)+abs(n1-b)+abs(n1-c))!=(n-k) or a+b+c!=k or a>n1 or b>n1 or c>n1 or a<0 or b<0 or c<0: return(False) #print(x,a,b,c) return(True) def fun(d1,d2,k): return((k+(2*d1)+d2)//3) for t in range(int(input())): n,k,...
PYTHON3
451_C. Predict Outcome of the Game
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 k games. Your friend did not tell exact number of wins of each...
2
9
t = int( raw_input() ) for i in range( t ): n, k, d1, d2 = map( int, raw_input().split() ) if ( n % 3 == 0 ): r = n - k xs = [ ( 2 * d2 + d1, 2 * d1 + d2 ), ( max( d1, d2 ) + abs( d1 - d2 ), d1 + d2 ), ( d1 + d2, max( d1, d2 ) + abs( d1 - d2 ) ), ( 2 * d1 + d2, 2 * d2 + d1 ) ] ok = False...
PYTHON
451_C. Predict Outcome of the Game
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 k games. Your friend did not tell exact number of wins of each...
2
9
#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...
CPP
451_C. Predict Outcome of the Game
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 k games. Your friend did not tell exact number of wins of each...
2
9
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.StringTokenizer; public class Temp { FastScanner in; PrintWriter out; BufferedReader bf; class FastScanner { public boolean can(long a, long b,...
JAVA
451_C. Predict Outcome of the Game
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 k games. Your friend did not tell exact number of wins of each...
2
9
import java.util.*; public class predict_outcome_of_the_game { static int t; static long n, k, d1, d2, a, b, c; static boolean w = false; public static void main( String[] args ) { Scanner in = new Scanner( System.in ); t = in.nextInt(); for ( int i = 0; i < t; i++ ) ...
JAVA
451_C. Predict Outcome of the Game
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 k games. Your friend did not tell exact number of wins of each...
2
9
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.lang.reflect.Constructor; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.InputMismatchException; import java.util.StringTokenizer; pub...
JAVA
451_C. Predict Outcome of the Game
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 k games. Your friend did not tell exact number of wins of each...
2
9
#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;...
CPP
451_C. Predict Outcome of the Game
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 k games. Your friend did not tell exact number of wins of each...
2
9
#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;...
CPP
451_C. Predict Outcome of the Game
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 k games. Your friend did not tell exact number of wins of each...
2
9
import java.util.*; import java.lang.*; import java.io.*; import java.awt.Point; // SHIVAM GUPTA : //NSIT //decoder_1671 // STOP NOT TILL IT IS DONE OR U DIE . // U KNOW THAT IF THIS DAY WILL BE URS THEN NO ONE CAN DEFEAT U HERE................ // ASCII = 48 + i ;// 2^28 = 268,435,456 > 2* 10^8 // log 10 base 2 = ...
JAVA
451_C. Predict Outcome of the Game
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 k games. Your friend did not tell exact number of wins of each...
2
9
import java.util.*; public class c { public static boolean solve(long total, long already, long firstD, long secondD) { if(total%3!=0) return false; //we know that a is (b plus or minus firstD) //and that c is (b plus or minus secondD) //this gives four cases //only test for success long a, b, c, ...
JAVA
451_C. Predict Outcome of the Game
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 k games. Your friend did not tell exact number of wins of each...
2
9
#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...
CPP
451_C. Predict Outcome of the Game
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 k games. Your friend did not tell exact number of wins of each...
2
9
#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, ...
CPP
451_C. Predict Outcome of the Game
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 k games. Your friend did not tell exact number of wins of each...
2
9
def getAns(n, k, x, y): if n % 3 != 0: return 'no' if y < x: x, y = y, x # now y > x smallest = float('inf') temp = None for i in [-1, 1]: for j in [-1, 1]: if i == -1 and j == -1: if 2*y - x <= k and (((2*y - x) % 3) == (k % 3)): ...
PYTHON
451_C. Predict Outcome of the Game
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 k games. Your friend did not tell exact number of wins of each...
2
9
#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) ...
CPP
451_C. Predict Outcome of the Game
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 k games. Your friend did not tell exact number of wins of each...
2
9
#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 ...
CPP
451_C. Predict Outcome of the Game
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 k games. Your friend did not tell exact number of wins of each...
2
9
#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...
CPP
451_C. Predict Outcome of the Game
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 k games. Your friend did not tell exact number of wins of each...
2
9
#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("%...
CPP
451_C. Predict Outcome of the Game
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 k games. Your friend did not tell exact number of wins of each...
2
9
#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...
CPP
451_C. Predict Outcome of the Game
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 k games. Your friend did not tell exact number of wins of each...
2
9
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Scanner; public class Main { /** * @param args * @throws IOException */ public static void main(String[] args) throws IOException { Scanner sc = new Scanner(new BufferedReader(...
JAVA
451_C. Predict Outcome of the Game
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 k games. Your friend did not tell exact number of wins of each...
2
9
t=int(input()) for j in range(t): inp=[int(n) for n in input().split()] n=inp[0] k=inp[1] d1=inp[2] d2=inp[3] if d2<d1: s=d1 d1=d2 d2=s if ((k>=2*d1+d2) and ((k-2*d1-d2)%3==0) and (n-k>=d1+2*d2) and ((n-k-d1-2*d2)%3==0)): print('yes') elif ((k>=2*d2+d1) and ((k-2*d2-d1)%3==0) and ...
PYTHON3
451_C. Predict Outcome of the Game
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 k games. Your friend did not tell exact number of wins of each...
2
9
import java.io.InputStream; import java.io.InputStreamReader; import java.io.BufferedReader; import java.math.BigInteger; import java.io.OutputStream; import java.io.PrintWriter; import java.io.IOException; import java.util.StringTokenizer; /** * Built using CHelper plug-in * Actual solution is at the top * @author...
JAVA
451_C. Predict Outcome of the Game
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 k games. Your friend did not tell exact number of wins of each...
2
9
#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 = ...
CPP
451_C. Predict Outcome of the Game
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 k games. Your friend did not tell exact number of wins of each...
2
9
import java.io.BufferedReader; import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.Arrays; import java.util.HashMap; import java.util.StringTokenizer; /** * 10 * * Y4 B1 R3 G5 R5 W3 W5 W2 R1 Y1 * * * @author pttrung */...
JAVA
451_C. Predict Outcome of the Game
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 k games. Your friend did not tell exact number of wins of each...
2
9
import java.io.InputStream; import java.io.InputStreamReader; import java.io.BufferedReader; import java.io.OutputStream; import java.io.PrintWriter; import java.io.IOException; import java.util.StringTokenizer; /** * Built using CHelper plug-in * Actual solution is at the top * @author Bat-Orgil */ public class M...
JAVA
451_C. Predict Outcome of the Game
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 k games. Your friend did not tell exact number of wins of each...
2
9
import java.io.*; import java.util.*; public class CF_451C { public static void main(String[] args) throws IOException { new CF_451C().solve(); } boolean gameExist(long n, long k, long d1, long d2){ ArrayList<Long> al=new ArrayList<Long>(); long min=Math.min(d1, d2), max=Math.max(d1,...
JAVA
451_C. Predict Outcome of the Game
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 k games. Your friend did not tell exact number of wins of each...
2
9
import java.io.*; import java.util.*; public class Main { static FastScanner in; public static void main(String[] args) throws IOException { // System.setOut(new PrintStream(new BufferedOutputStream(new FileOutputStream("output.out")), true)); in = new FastScanner(System.in); // ...
JAVA
451_C. Predict Outcome of the Game
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 k games. Your friend did not tell exact number of wins of each...
2
9
import static java.lang.System.in; import java.io.IOException; public class C258 { static byte[] buffer = new byte[8192]; static int offset = 0; static int bufferSize = 0; public static void main(String args[])throws IOException { long t= readLong(); while(t-->0) { long n = readLong(); long k = read...
JAVA
451_C. Predict Outcome of the Game
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 k games. Your friend did not tell exact number of wins of each...
2
9
#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 ...
CPP
451_C. Predict Outcome of the Game
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 k games. Your friend did not tell exact number of wins of each...
2
9
#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++) ...
CPP
451_C. Predict Outcome of the Game
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 k games. Your friend did not tell exact number of wins of each...
2
9
#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...
CPP
451_C. Predict Outcome of the Game
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 k games. Your friend did not tell exact number of wins of each...
2
9
#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 ...
CPP
451_C. Predict Outcome of the Game
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 k games. Your friend did not tell exact number of wins of each...
2
9
#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 + ...
CPP
451_C. Predict Outcome of the Game
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 k games. Your friend did not tell exact number of wins of each...
2
9
def check(n, k, d1, d2): if (k - d1 - d2) % 3 != 0: return False y = (k - d1 - d2) // 3 return min(y+d1, y, y+d2) >= 0 and max(y+d1, y, y+d2) <= n//3 t = int(input()) all_res = [] for _ in range(t): n, k, d1, d2 = map(int, input().split()) if n % 3 != 0: all_res += ['no'] elif c...
PYTHON3
451_C. Predict Outcome of the Game
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 k games. Your friend did not tell exact number of wins of each...
2
9
t = int(raw_input()) for i in range(t): n, k, d1, d2 = raw_input().split() n, k, d1, d2 = int(n), int(k), int(d1), int(d2) if n % 3 == 0: r = n - k vs = [ (2*d2 + d1, 2*d1 + d2), (max(d1, d2) + abs(d1 - d2), d1 + d2), (d1 + d2, max(d1, d2) + ...
PYTHON
451_C. Predict Outcome of the Game
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 k games. Your friend did not tell exact number of wins of each...
2
9
#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...
CPP
451_C. Predict Outcome of the Game
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 k games. Your friend did not tell exact number of wins of each...
2
9
#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...
CPP
451_C. Predict Outcome of the Game
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 k games. Your friend did not tell exact number of wins of each...
2
9
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.*; public class C { private void solve() throws IOException { int T = ni(); for (int t = 0; t < T; ++t) { long n = nl(); long k = nl(); lo...
JAVA
451_C. Predict Outcome of the Game
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 k games. Your friend did not tell exact number of wins of each...
2
9
#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 !=...
CPP
451_C. Predict Outcome of the Game
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 k games. Your friend did not tell exact number of wins of each...
2
9
#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...
CPP
451_C. Predict Outcome of the Game
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 k games. Your friend did not tell exact number of wins of each...
2
9
t = int(input()) for i in range(t): n, k, a, b = map(int, input().split()) if n % 3 != 0: print("no") else: for i in range(2): for j in range(2): flagf = False if i == 0: a1 = a else: a1 = -a ...
PYTHON3
451_C. Predict Outcome of the Game
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 k games. Your friend did not tell exact number of wins of each...
2
9
#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 &...
CPP
451_C. Predict Outcome of the Game
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 k games. Your friend did not tell exact number of wins of each...
2
9
for _ in xrange(int(raw_input())): n, k, d1, d2 = map(int, raw_input().split()) if n%3 != 0: print "no" continue s = [[1, 1], [1, -1], [-1, 1], [-1, -1]] done = False for i in s: D1 = d1*i[0] D2 = d2*i[1] if (k+2*D1+D2)%3 != 0: continue a ...
PYTHON
451_C. Predict Outcome of the Game
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 k games. Your friend did not tell exact number of wins of each...
2
9
#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 ...
CPP
451_C. Predict Outcome of the Game
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 k games. Your friend did not tell exact number of wins of each...
2
9
#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 ...
CPP
451_C. Predict Outcome of the Game
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 k games. Your friend did not tell exact number of wins of each...
2
9
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.PriorityQueue; import java.util.StringTokenizer; public class c11 { public static void main(String[] args)throws Exception { StringBuilder b=new StringBuilder(); int n=in(); while...
JAVA
451_C. Predict Outcome of the Game
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 k games. Your friend did not tell exact number of wins of each...
2
9
#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) /...
CPP
451_C. Predict Outcome of the Game
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 k games. Your friend did not tell exact number of wins of each...
2
9
#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...
CPP
451_C. Predict Outcome of the Game
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 k games. Your friend did not tell exact number of wins of each...
2
9
def doall(): t = int(input()) def solve(n, k, d1, d2): if n % 3 == 0: r = n - k a = [[0, d1, d1 + d2], [0, d1, d1 - d2], [0, -d1, -d1 + d2], [0, -d1, -d1 - d2]] for now in a: mn = min(now) ...
PYTHON3
451_C. Predict Outcome of the Game
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 k games. Your friend did not tell exact number of wins of each...
2
9
#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; ...
CPP
451_C. Predict Outcome of the Game
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 k games. Your friend did not tell exact number of wins of each...
2
9
#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() {...
CPP
451_C. Predict Outcome of the Game
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 k games. Your friend did not tell exact number of wins of each...
2
9
t = input() def solve(a, b, c, left): if min([a, b, c]) < 0: return False M = max([a, b, c]) left -= (M-a) + (M-b) + (M-c) if left < 0: return False if left == 0: return True if left % 3 != 0: return False return True for test in range(0, t): n, k, d1, d2 = map(int, raw_input().split()) left = n-k a =...
PYTHON
451_C. Predict Outcome of the Game
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 k games. Your friend did not tell exact number of wins of each...
2
9
#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) { ...
CPP
451_C. Predict Outcome of the Game
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 k games. Your friend did not tell exact number of wins of each...
2
9
#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...
CPP
451_C. Predict Outcome of the Game
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 k games. Your friend did not tell exact number of wins of each...
2
9
import java.util.Arrays; import java.util.Scanner; public class Main { private static Scanner scanner = new Scanner(System.in); public static void main(String[] args) { int t = scanner.nextInt(); for(int i = 0; i < t; i++){ Long n, k, d1, d2; n = scanner.nextLong(); ...
JAVA
451_C. Predict Outcome of the Game
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 k games. Your friend did not tell exact number of wins of each...
2
9
#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 == '-'...
CPP
451_C. Predict Outcome of the Game
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 k games. Your friend did not tell exact number of wins of each...
2
9
#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...
CPP
451_C. Predict Outcome of the Game
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 k games. Your friend did not tell exact number of wins of each...
2
9
#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 < ...
CPP
451_C. Predict Outcome of the Game
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 k games. Your friend did not tell exact number of wins of each...
2
9
#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 ...
CPP
451_C. Predict Outcome of the Game
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 k games. Your friend did not tell exact number of wins of each...
2
9
#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 + ...
CPP
451_C. Predict Outcome of the Game
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 k games. Your friend did not tell exact number of wins of each...
2
9
#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, ...
CPP
451_C. Predict Outcome of the Game
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 k games. Your friend did not tell exact number of wins of each...
2
9
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; public class C { static class Scanner{ BufferedReader rd = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer tk; public Scanner(){ rd = new BufferedReader(new ...
JAVA
451_C. Predict Outcome of the Game
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 k games. Your friend did not tell exact number of wins of each...
2
9
#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...
CPP
451_C. Predict Outcome of the Game
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 k games. Your friend did not tell exact number of wins of each...
2
9
#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 ...
CPP
451_C. Predict Outcome of the Game
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 k games. Your friend did not tell exact number of wins of each...
2
9
import java.util.Scanner; public class C implements Runnable { @Override public void run() { try { int[] x = new int[]{1, 1, -1, -1}; int[] y = new int[]{1, -1, 1, -1}; Scanner in = new Scanner(System.in); int testNum = in.nextInt(); for (int...
JAVA
451_C. Predict Outcome of the Game
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 k games. Your friend did not tell exact number of wins of each...
2
9
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.InputMismatchException; import java.util.*; import java.io.*; public class Main{ public static class InputReader { private InputStream stream; private byte[] buf = new byte[1...
JAVA
451_C. Predict Outcome of the Game
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 k games. Your friend did not tell exact number of wins of each...
2
9
#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 = ...
CPP
451_C. Predict Outcome of the Game
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 k games. Your friend did not tell exact number of wins of each...
2
9
import java.io.*; import java.util.*; /** * @author master_j * @version 0.4 * @since May 3, 2014 */ public class Main { long n, k, n3; private void solve() throws IOException { int t = io.nI(); for(int i = 0; i < t; i++){ n = io.nL(); k = io.nL(); n3 = n...
JAVA
451_C. Predict Outcome of the Game
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 k games. Your friend did not tell exact number of wins of each...
2
9
#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 =...
CPP
451_C. Predict Outcome of the Game
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 k games. Your friend did not tell exact number of wins of each...
2
9
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; public class C { /** * @param args * @throws IOException */ public static void main(String[] args) throws IOException { int t = nextInt(); for (in...
JAVA
451_C. Predict Outcome of the Game
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 k games. Your friend did not tell exact number of wins of each...
2
9
#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...
CPP
451_C. Predict Outcome of the Game
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 k games. Your friend did not tell exact number of wins of each...
2
9
#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...
CPP
451_C. Predict Outcome of the Game
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 k games. Your friend did not tell exact number of wins of each...
2
9
#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 - ...
CPP
451_C. Predict Outcome of the Game
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 k games. Your friend did not tell exact number of wins of each...
2
9
#include <bits/stdc++.h> using namespace std; int nxt() { int res; scanf("%d", &res); return res; } long long n, k; bool ok(long long s1, long long s2, long long s3) { if (k - s1 - s2 - s3 < 0 || (k - s1 - s2 - s3) % 3 != 0) { return false; } long long m = max(s1, max(s2, s3)); long long first = n - (...
CPP
451_C. Predict Outcome of the Game
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 k games. Your friend did not tell exact number of wins of each...
2
9
def main(): t = int(input()) for z in range(t): n, k, d1, d2 = map(int, input().split()) if n % 3 != 0: print('no') continue f = 0 for i in [-1, +1]: for j in [-1, +1]: w = (k - i * d1 - j * d2) if f == 0 and (w ...
PYTHON3
451_C. Predict Outcome of the Game
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 k games. Your friend did not tell exact number of wins of each...
2
9
#include <bits/stdc++.h> using namespace std; long long n, k, d1, d2; bool fun(long long t1, long long t2, long long t3) { long long mi = (min(min(t1, t2), t3)); t1 -= mi; t2 -= mi; t3 -= mi; long long ma = (max(max(t1, t2), t3)); if ((t1 + t2 + t3) <= k && (k - (t1 + t2 + t3)) % 3 == 0) { long long kal...
CPP
451_C. Predict Outcome of the Game
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 k games. Your friend did not tell exact number of wins of each...
2
9
#include <bits/stdc++.h> using namespace std; long long n, k, d1, d2; bool DW(long long num, int d) { long long a, b, c; if (num % 3) return false; b = num / 3; if (d == 1) { a = b + d1; c = b - d2; } else if (d == 2) { a = b + d1; c = b + d2; } else if (d == 3) { a = b - d1; c = b -...
CPP
451_C. Predict Outcome of the Game
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 k games. Your friend did not tell exact number of wins of each...
2
9
import math t = int(raw_input()) for i in range(t): found = False tn = raw_input().split() if int(tn[0]) % 3 != 0: print "no" continue d1 = int(tn[2]) d2 = int(tn[3]) for i in range(-1,2,2): for j in range(-1,2,2): D1 = d1 * i D2 = d2 * j x2 = (int(tn[1]) - D1 + D2) / 3 if (int(tn[...
PYTHON
451_C. Predict Outcome of the Game
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 k games. Your friend did not tell exact number of wins of each...
2
9
#include <bits/stdc++.h> using namespace std; bool first(long long n, long long k, long long d1, long long d2) { if ((k + 2 * d1 + d2) % 3 != 0) return false; long long alpha = (k + 2 * d1 + d2) / 3; if (alpha < d1 || alpha < d1 + d2) return false; if (alpha > n / 3) return false; return true; } bool second(l...
CPP
451_C. Predict Outcome of the Game
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 k games. Your friend did not tell exact number of wins of each...
2
9
import java.util.*; public class Invader { public static void main(String [] args){ Scanner in=new Scanner(System.in); int t=in.nextInt(); for(int i=0;i<t;i++){ long n=in.nextLong(); long k=in.nextLong(); long d1=in.nextLong(); long d2=in.nextLong(); boolean flag=false; if(n%3!=0) System.out.println("no"); else{ double...
JAVA
451_C. Predict Outcome of the Game
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 k games. Your friend did not tell exact number of wins of each...
2
9
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStream; import java.io.PrintWriter; import java.math.BigInteger; import java.util.*; public class DZYLovesHash { public static void main(String[] args) { InputStre...
JAVA
451_C. Predict Outcome of the Game
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 k games. Your friend did not tell exact number of wins of each...
2
9
#include <bits/stdc++.h> using namespace std; long long n, k, d1, d2; bool solve(long long cc, long long ss, long long gg) { long long b2ee = n - k, sum = 0, mksb = n / 3; if (cc < mksb) sum += mksb - cc; if (ss < mksb) sum += mksb - ss; if (gg < mksb) sum += mksb - gg; return (cc > mksb || cc < 0 || ss > mks...
CPP
451_C. Predict Outcome of the Game
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 k games. Your friend did not tell exact number of wins of each...
2
9
#include <bits/stdc++.h> using namespace std; long long _, n, k, d1, d2, t, x, y; bool V(long long i, long long j, long long k, long long n, long long m) { long long u = m - i - j - k; if (u % 3) { return 0; } long long g = u / 3; i += g; j += g; k += g; if (i < 0 || j < 0 || k < 0) return 0; x = ...
CPP
451_C. Predict Outcome of the Game
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 k games. Your friend did not tell exact number of wins of each...
2
9
num = raw_input() num=int(num) while num>0: s=raw_input() inp=map(int,s.split()) sign = (-1,1) done = False if inp[0]%3!=0: print "no" else: for i in sign: for j in sign: d1=i*inp[2] d2=j*inp[3] k=inp[1] ...
PYTHON