Four Segments problem
Difference between en2 and en3, changed 45 character(s)
[problem:14C]↵
https://mirror.codeforces.com/contest/14/problem/C↵
------------------------------------------↵
I am getting compilation error. Please help.↵
Thankyou.↵

This is my code.↵
-----------------------------------------------↵

import java.util.*;↵
import java.io.*;↵

public class Main {↵
    ↵
    static StringBuilder sb;↵
    Scanner scan = new Scanner(System.in);↵
    ↵
    static void solve()↵
    {↵
        int[] x1 = new int[4];↵
        int[] y1 = new int[4];↵
        int[] x2 = new int[4];↵
        int[] y2 = new int[4];↵
        ↵
        int hor=0;↵
        int ver=0;↵
        for(int i=0; i<4; i++)↵
        {↵
            x1[i] = scan.nextInt();↵
            y1[i] = scan.nextInt();↵
            x2[i] = scan.nextInt();↵
            y2[i] = scan.nextInt();↵
            ↵
            if(x1[i]-x2[i]==0)↵
            {↵
                ver++;↵
            }↵
            if(y1[i]-y2[i]==0)↵
            {↵
                hor++;↵
            }↵
            ↵
        }↵
        ↵
        int count=0;↵
        for(int i=0; i<3; i++)↵
        {↵
            for(int j=i+1; j<4; j++)↵
            {↵
                if(x1[i]==x2[j] && y1[i]==y2[j])↵
                {↵
                    count++;↵
                }↵
                if(x1[i]==x1[j] && y1[i]==y1[j])↵
                {↵
                    count++;↵
                }↵
                if(x1[i]==x1[j] && y2[i]==y1[j])↵
                {↵
                    count++;↵
                }↵
                if(x2[i]==x2[j] && y2[i]==y2[j])↵
                {↵
                    count++;↵
                }↵
            }↵
        }↵
        ↵
        if(ver==2 && hor==2 && count==4)↵
        {↵
            System.out.println("YES");↵
        }↵
        else↵
        {↵
            System.out.println("NO");↵
        }↵
    }↵
        ↵
    public static int[] readArray(int n)↵
    {↵
        int A[] = new int[n];↵
        for(int i=0; i<n; i++)↵
        {↵
                A[i] = scan.nextInt();↵
        }↵
        return A;↵
    }↵
    ↵
    public static void main(String args[])↵
    {↵
        ↵
        ↵
        try↵
        {↵
            Main obj = new Main();↵
            obj.run (args);↵
        }↵
         catch (Exception e)↵
        {↵
            e.printStackTrace ();↵
        }↵
        ↵
        void run (String[] args)↵
        {↵
            // sb = new StringBuilder();↵
            int test = 1;↵
            while(test-- >0)↵
            {↵
                solve();↵
            }↵
        // System.out.println(sb);↵
        ↵
        }↵
    }    ↵
   ↵
    ↵
}↵

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en6 English curiouscurrent 2023-01-29 15:09:59 242 Reverted to en2
en5 English curiouscurrent 2023-01-29 15:09:29 189 (published)
en4 English curiouscurrent 2023-01-29 15:08:55 8 Tiny change: '------\n\nimport' -> '------\n\n\n\n\n\nimport' (saved to drafts)
en3 English curiouscurrent 2023-01-29 15:08:10 45 (published)
en2 English curiouscurrent 2023-01-29 15:07:23 2441
en1 English curiouscurrent 2023-01-29 15:04:47 120 Initial revision (saved to drafts)