Sort by

recency

|

49 Discussions

|

  • + 0 comments

    int main() { int n; int xfirst; int yfirst; bool h = true; bool v = true;

    cin >> n;
    vector<pair<int,int>> points(n);
    cin.ignore(numeric_limits<streamsize>::max(), '\n');
    
    for (int n_itr = 0; n_itr < n; n_itr++) 
    {
        string xy_temp;
        getline(cin, xy_temp);
        vector<string> xy = split_string(xy_temp);    
        int x = stoi(xy[0]);
        int y = stoi(xy[1]);
    
        points[n_itr] = {x,y};
        xfirst = points[0].first;
    }
        for (int i = 0; i < n;i++)
        {
            if (points[i].first != xfirst)
            {
                h = false;
                break;
            }
        }
        yfirst = points[0].second;
        for (int j = 0; j < n;j++)
        {
            if (points[j].second != yfirst)
            {
                dprintf(2,"%d <------ -------> %d\n",points[j].second,yfirst);
                v = false;
                break;
            }
        }
    if (h || v)
        cout << "YES";
    else
     cout << "NO";
    return 0;
    

    }

  • + 0 comments

    int main() { char* n_endptr; char* n_str = readline(); int n = strtol(n_str, &n_endptr, 10);

    int xfirst;
    int yfirst;
    int h = true;
    int v = true;
    if (n_endptr == n_str || *n_endptr != '\0') { exit(EXIT_FAILURE); }
    struct point *point_xy = malloc(sizeof(struct point) * n);
    for (int n_itr = 0; n_itr < n; n_itr++) 
    {
        char** xy = split_string(readline());
        char* x_endptr;
        char* x_str = xy[0];
        int x = strtol(x_str, &x_endptr, 10);
        if (x_endptr == x_str || *x_endptr != '\0') { exit(EXIT_FAILURE); }
        char* y_endptr;
        char* y_str = xy[1];
        int y = strtol(y_str, &y_endptr, 10);
        if (y_endptr == y_str || *y_endptr != '\0') { exit(EXIT_FAILURE); } 
    
        point_xy[n_itr].x = x;
        point_xy[n_itr].y = y;
    }
    xfirst = point_xy[0].x;
    yfirst = point_xy[0].y;
    //  dprintf(2,"%d <----xfirst----- -----yfirst------>%d\n",xfirst,yfirst);
     for (int i = 0; i < n;i++)
     {
        //  dprintf(2,"%d <----xfirst----- -----yfirst------>%d\n",xfirst,yfirst);
        // dprintf(2,"%d <----xfirst----- -----points------>%d\n",xfirst,point_xy[i].x);
        if (point_xy[i].x != xfirst)
        {
            h = false;
            break;
        }
     }
     for (int j = 0; j < n;j++)
     {
    
        if (point_xy[j].y != yfirst)
        {
            v = false;
            break;
        }
    
     }
    if (h || v)
        printf("YES");
    else 
        printf("NO");
    return 0;
    

    }

  • + 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"); } }