//Given two - dimensional points in space, determine whether they lie on some vertical or horizontal line.If yes, print YES; otherwise, print NO. // //Input Format // //The first line contains a single positive integer, , denoting the number of points. //Each line of subsequent lines contain two space - separated integers detailing the respective values of and (i.e., the coordinates of the point). // //Constraints // //Output Format // //Print YES if all points lie on some horizontal or vertical line; otherwise, print NO. // //Sample Input 0 // //5 //0 1 //0 2 //0 3 //0 4 //0 5 //Sample Output 0 // //YES //Explanation 0 // //All points lie on a vertical line. // //Sample Input 1 // //5 //0 1 //0 2 //1 3 //0 4 //0 5 //Sample Output 1 // //NO //Explanation 1 // //The points do not all form a horizontal or vertical line. #include int main() { int n; scanf("%d", &n); int firstX, firstY; scanf("%d %d", &firstX, &firstY); bool allHorizontal = true; bool allVertical = true; for (int i = 1; i < n; ++i) { int x, y; scanf("%d %d", &x, &y); allHorizontal &= x == firstX; allVertical &= y == firstY; } puts(allHorizontal || allVertical ? "YES" : "NO"); return 0; }