Chef and Football Match CodeChef Solution

Problem -Chef and Football Match CodeChef Solution

This website is dedicated for CodeChef solution where we will publish right solution of all your favourite CodeChef problems along with detailed explanatory of different competitive programming concepts and languages.

Chef and Football Match CodeChef Solution in C++14

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;

typedef vector<int> vi;

#define f(i,x,n) for(ll i=x;i<n;i++)
#define all(a) a.begin() , a.end()

#define fast_io() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

#define print(a) cout << a << ' '
#define println(a) cout << a << '\n'
#define line() cout << '\n'


inline void solve() {
    int n; cin >> n;
    
    int type,a,b;
    int a1 = -1,b1;
    string ans;
    
    while(n--) {
        ans = "NO";
        cin >> type >> a >> b;
        
        if(type == 1) {
            ans = "YES";
            a1 = a;
            b1 = b;
        }
        else {
            if(a == b) {
                ans = "YES";
                a1 = a;
                b1 = b;
            } 
            else if( a1 != -1 )  {
                if( min(a,b) < max(a1,b1) ) {
                    if(a1 > b1) {
                        a1 = max(a,b);
                        b1 = min(a,b);
                    } else {
                        a1 = min(a,b);
                        b1 = max(a,b);
                    }
                    
                    ans = "YES";
                }
            }
            else a1 = -1;
        }
        println(ans);
    }
}

signed main() {
    fast_io();

    int t = 1;
    cin >> t;
    while(t--) solve();

    return 0;
}

Chef and Football Match CodeChef Solution in PYTH 3

# cook your dish here
SPECIFIC = 1
UNKNOWN = 2

T = int(input())
for _ in range(T):
    N = int(input())
    t1 = 0
    t2 = 0
    for _ in range(N):
        rtype, a, b = map(int, input().split(" "))
        if rtype == SPECIFIC:
            t1, t2 = a, b
            print("YES")
        else:
            way1 = (a >= t1 and b >= t2)
            way2 = (b >= t1 and a >= t2)
            if way1 != way2 or a == b:
                t1, t2 = (a, b) 
                print("YES")
            else:
                print("NO")

Chef and Football Match CodeChef Solution in C

#include <stdio.h>

int main(void) 
{
	int T;
	scanf("%d", &T);
	for (int i=0; i<T; i++)
	{
	    int N, t, p1, p2, g1, g2, c, a;
	    scanf("%d", &N);
	    scanf("%d %d %d", &t, &p1, &p2);
	    if (p1<p2)
	    {
	        a=p1;
	        p1=p2;
	        p2=a;
	    }
	    if (t==1 || p1==p2)
	    {
	        printf("YES\n");
	        c=1;
	    }
	    else
	    {
	        printf("NO\n");
	        c=0;
	    }
	    for (int j=0; j<N-1; j++)
	    {
	        scanf("%d %d %d", &t, &g1, &g2);
	        if(g1<g2)
	        {
	            a=g1;
	            g1=g2;
	            g2=a;
	        }
            if(t==1 || g1==g2 || (c==1 && p1>g2))
            {
                printf("YES\n");
                c=1;
            }
	        else
	        {
	            printf("NO\n");
	            c=0;
	        }
	        p1=g1;
	        p2=g2;
	    }
	}
	
	return 0;
}

Chef and Football Match CodeChef Solution in JAVA


import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.*;
class Codechef
{
	public static void main (String[] args) throws java.lang.Exception
	{
		Kattio io = new Kattio();
		int t = io.nextInt();
		for(int i = 0; i < t; i++) {
		    int n = io.nextInt();
		    int scorea = 0;
		    int scoreb = 0;
		    for(int j = 0; j < n; j++) {
		    	int a = io.nextInt();
		    	int b = io.nextInt();
		    	int c = io.nextInt();
		    	int max = Math.max(b, c);
		    	int min = Math.min(b, c);
		    	if(a == 1) {
		    		scorea = b;
		    		scoreb = c;
		    		io.println("YES");
		    	}
		    	else {
		    		if(scorea <= min && scoreb <= min) {
		    			if(min == max) {
		    				scorea = min;
		    				scoreb = min;
		    				io.println("YES");
		    			}
		    			else {
		    				io.println("NO");
		    			}
		    		}
		    		else {
		    			io.println("YES");
			    		if(scorea >= min && scoreb <= min) {
			    			scorea = max;
			    			scoreb = min;
			    		}
			    		else if(scorea <= min && scoreb >= min) {
			    			scorea = min;
			    			scoreb = max;
			    		}
		    		}
		    	}
		    }
		}
		io.close();
	}
	static class Kattio extends PrintWriter {
		private BufferedReader r;
		private StringTokenizer st;
		// standard input
		public Kattio() { this(System.in, System.out); }
		public Kattio(InputStream i, OutputStream o) {
			super(o);
			r = new BufferedReader(new InputStreamReader(i));
		}
		// USACO-style file input
		public Kattio(String problemName) throws IOException {
			super(problemName + ".out");
			r = new BufferedReader(new FileReader(problemName + ".in"));
		}
		// returns null if no more input
		public String next() {
			try {
				while (st == null || !st.hasMoreTokens())
					st = new StringTokenizer(r.readLine());
				return st.nextToken();
			} catch (Exception e) { }
			return null;
		}
		public int nextInt() { return Integer.parseInt(next()); }
		public double nextDouble() { return Double.parseDouble(next()); }
		public long nextLong() { return Long.parseLong(next()); }
	}
}

Chef and Football Match CodeChef Solution in PYPY 3

for _ in range(int(input())):
    n = int(input())
    possible_scores = [(0, 0)]
    
    for i in range(n):
        q, a, b = map(int, input().split())
        if q == 1:
            print('YES')
            possible_scores = [(a, b)]
            
        if q == 2:
            if a == b:
                print('YES')
                possible_scores = [(a, b)]
            
            else:
                temp = []
                for next_a, next_b in [(a, b), (b, a)]:
                    for cur_a, cur_b in possible_scores:
                        if (next_a >= cur_a) and (next_b >= cur_b):
                            temp.append((next_a, next_b))
                            break
                if len(temp) == 2:
                    print('NO')
                else:
                    print('YES')
                possible_scores = temp
                

Chef and Football Match CodeChef Solution in PYTH

# cook your code here
T = input()
while T>0:
    N,X,Y,F = input(),0,0,False
    while N>0:
        O,A,B = map(int,raw_input().split())
        if O == 1:
            print "YES"
            F = True
        else:
            if A == B:
                print "YES"
            elif max(X,Y)>min(A,B) and F:
                print "YES"
            else:
                print "NO"
                F= False
        X,Y = A,B        
        N-=1
    T-=1

Chef and Football Match CodeChef Solution in C#

using System;

public class Test
{
	public static void Main()
	{
		int N = int.Parse(Console.ReadLine());
		
		for (int i = 0; i < N; i++) {
		    int events = int.Parse(Console.ReadLine());
		    
            int pastA = 0;
            int pastB = 0;
            bool pastFav = false;
            
		    for (int j = 0; j < events; j++) {
    		    string[] results = Console.ReadLine().Split(' ');
    		    bool fav = int.Parse(results[0]) == 2 ? false : true;
    		    int teamA = int.Parse(results[1]);
    		    int teamB = int.Parse(results[2]);
                
                
                bool print = false;
                if (pastFav) {
                    if (teamA < pastA || teamB < pastB) {
                        print = true;
                        pastA = teamB;
                        pastB = teamA;
                    }
                    else if (teamA < pastB || teamB < pastA) {
                        print = true;
                    }
                }
                
                if (fav || teamA == teamB) {
                    print = true;
                }
                
                pastA = teamA;
                pastB = teamB;
                pastFav = print;
                
                Console.WriteLine(print ? "YES" : "NO");
                
		    }
		}
	}
}

Chef and Football Match CodeChef Solution in GO

package main

import (
	"bufio"
	"fmt"
	"os"
)

var reader *bufio.Reader = bufio.NewReader(os.Stdin)
var writer *bufio.Writer = bufio.NewWriter(os.Stdout)

func printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }
func scanf(f string, a ...interface{})  { fmt.Fscanf(reader, f, a...) }

func main() {

	defer writer.Flush()
	var n, t int
	scanf("%d\n", &t)

	// For each test case
	for i := 0; i < t; i++ {
		scanf("%d\n", &n)
		var highScore int
		initialised := false
		// For each line in test case
		for j := 0; j < n; j++ {
			// Line specific data
			var a, b, lineFormat int
			scanf("%d %d %d\n", &lineFormat, &a, &b)
			// fmt.Println(lineFormat, a, b)
			if lineFormat == 1 {
				initialised = true

				if a >= b {
					highScore = a
				} else if b > a {
					highScore = b
				}
				printf("YES\n")
				continue
			}

			if a == b {
				printf("YES\n")
				highScore = b
				continue
			}

			if initialised == false {
				printf("NO\n")
				continue
			}

			if a < highScore {
				printf("YES\n")
				highScore = b
			} else if b < highScore {
				printf("YES\n")
				highScore = a
			} else {
				printf("NO\n")
			}
		}
	}
}
Chef and Football Match CodeChef Solution Review:

In our experience, we suggest you solve this Chef and Football Match CodeChef Solution and gain some new skills from Professionals completely free and we assure you will be worth it.

If you are stuck anywhere between any coding problem, just visit Queslers to get the Chef and Football Match CodeChef Solution.

Find on CodeChef

Conclusion:

I hope this Chef and Football Match CodeChef Solution would be useful for you to learn something new from this problem. If it helped you then don’t forget to bookmark our site for more Coding Solutions.

This Problem is intended for audiences of all experiences who are interested in learning about Programming Language in a business context; there are no prerequisites.

Keep Learning!

More Coding Solutions >>

Cognitive Class Answer

CodeChef Solution

Microsoft Learn

Leave a Reply

Your email address will not be published. Required fields are marked *