Sort by

recency

|

47 Discussions

|

  • + 0 comments

    !/bin/python3

    import math import os import random import re import sys

    if name == 'main': n = int(input()) H = [] V = []

    for n_itr in range(n):
        xy = input().split()
    
        x = int(xy[0])
    
        y = int(xy[1])
    
        H.append(xy[0])
        V.append(xy[1])
    setH = set(H)
    setV = set(V)
    if len(setH) == 1 or len(setV) == 1:
        print("YES")
    else:
        print("NO")
    
  • + 0 comments

    My javascript solution (two liner, could easily be one):

    function main() {
        const points = Array(+readLine()).fill().map(_ => readLine().split(' ').map(x => +x));
        console.log([0, 1].some(x => points.every((y, _, arr) => y[x] == arr[0][x])) ? 'YES' : 'NO');
    }
    
  • + 1 comment

    int main() { int n,x,y,x1,y1,cx=0,cy=0,flag=0,num; scanf("%d",&n); num=n; while(n--) { if(flag==0) { scanf("%d%d",&x,&y); x1=x; y1=y; flag=1; } else if(flag==1) { scanf("%d%d",&x,&y); if(x==x1) { cx++; } else if(y==y1) { cy++; } } } if(cx==num-1 || cy==num-1) { printf("YES"); } else { printf("NO"); } }

    • + 0 comments

      The program reads an integer n, which represents the number of points to be checked.

      It initializes variables num to store the original number of points, cx (count in x-direction), cy (count in y-direction), and flag to 0.

      It enters a loop that iterates n times to read the coordinates of the points.

      In the loop, if flag is 0, it reads the first set of coordinates (x, y), stores them in x1 and y1, and sets flag to 1 to indicate the first point has been read.

      In subsequent iterations (when flag is 1), it reads the coordinates of the next point (x, y).

      It checks if the x-coordinates of the points are the same, incrementing cx if they are. It checks if the y-coordinates of the points are the same, incrementing cy if they are.

      After processing all points, it checks whether either cx (all points are on a horizontal line) or cy (all points are on a vertical line) is equal to num - 1. If either of these conditions is met, it prints "YES." Otherwise, it prints "NO."

      The program determines if the given points lie on a straight line, either horizontally or vertically, and then provides the appropriate "YES" or "NO" output based on that determination.

  • + 0 comments
    x = []
    y = []
    n = int(input())
    for i in range(n):
        xy = input().split()
        x.append(xy[0])
        y.append(xy[1])
    print ("YES" if (len(set(x)) == 1 or len(set(y)) == 1 ) else "NO")
    
  • + 0 comments
    import math
    import os
    import random
    import re
    import sys
    
    def line(arr_x,arr_y):
        if len(set(arr_x)) == 1:
            return "YES"
        elif len(set(arr_y)) == 1:
            return "YES"
        else:
            return "NO"
        
    if __name__ == '__main__':
        n = int(input())
        arr_x = []
        arr_y = []
        for n_itr in range(n):
            xy = input().split()
            x = int(xy[0])
            y = int(xy[1])
            arr_x.append(x)
            arr_y.append(y)
        print(line(arr_x,arr_y))