pages:
- 1
MehrdadSComputer SAYS
I thought that my code will work fine on any testcases, but i have a wrong answer, can anyone tell why?
import java.util.Iterator;
import java.util.Scanner;
import java.util.TreeSet;
public class Main {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int n1=sc.nextInt();
int n2;
TreeSet mySet=new TreeSet();
while(n1!=0)
{
System.out.print("\n");
n2=sc.nextInt();
int x[]=new int[n2];
int y[]=new int[n2];
int z[]=new int[n2];
for(int i=0;i<n2;i++)
{
x[i]=sc.nextInt();
y[i]=sc.nextInt();
z[i]=sc.nextInt();
}
for(int i=0;i<n2;i++)
{
for(int j=0;j<n2;j++)
{
if(x[j]>=x[i]) mySet.add(j);
}
for(int j=0;j<n2;j++)
{
if(mySet.contains(j))
if(y[j]<y[i]) mySet.remove(j);
}
for(int j=0;j<n2;j++)
{
if(mySet.contains(j))
if(z[j]<z[i]) mySet.remove(j);
}
if(mySet.size()==1) System.out.print("Yes\n");else System.out.print("No\n");
mySet.clear();
}
n1--;
}
}
}
Login please!
In order to post something you must login first. You can use the form in the top of this page.