-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmoop.java
More file actions
48 lines (46 loc) · 1.38 KB
/
moop.java
File metadata and controls
48 lines (46 loc) · 1.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import java.io.*;
import java.util.StringTokenizer;
public class moop {
public static void main(String[] args) throws IOException {
BufferedReader reader = new BufferedReader(new FileReader("moop.in"));
PrintWriter writer = new PrintWriter(new BufferedWriter(new FileWriter("moop.out")));
//Scanner reader = new Scanner(System.in);
int N = Integer.parseInt(reader.readLine());
StringTokenizer st;
int[] x = new int[N];
int[] y = new int[N];
for(int i = 0; i < N; i++)
{
st = new StringTokenizer(reader.readLine());
x[i] = Integer.parseInt(st.nextToken());
y[i] = Integer.parseInt(st.nextToken());
}
int components = 0;
boolean visited[] = new boolean[N];
for(int i = 0; i < N; i++)
{
if(!visited[i])
{
components++;
for(int j = 0; j < N; j++)
{
if((x[i] >= x[j] && y[i] >= y[j]) || (x[i] <= x[j] && y[i] <= y[j])) {
visited[j] = true;
}
}
}
}
writer.println(components);
reader.close();
writer.close();
}
}
class Particle
{
int x, y;
public Particle(int a, int b)
{
x = a;
y = b;
}
}