-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy paththere-is-no-spoon-episode-1.java
More file actions
38 lines (32 loc) · 1.19 KB
/
Copy paththere-is-no-spoon-episode-1.java
File metadata and controls
38 lines (32 loc) · 1.19 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
import java.util.*;
import java.io.*;
import java.math.*;
class Player {
public static void main(String args[]) {
Scanner in = new Scanner(System.in);
int width = in.nextInt(); int height = in.nextInt(); in.nextLine();
Vector<Integer> vX = new Vector<Integer>(1,1);
Vector<Integer> vY = new Vector<Integer>(1,1);
for (int y = 0; y < height; y++) //saving coordinates of nodes
{
String line = in.nextLine();
for (int x = 0; x < width; x++) {
if (line.charAt(x) == '0')
{
vX.add(x);
vY.add(y);
}
}
}
for (int i = 0; i < vX.size(); i++)
{
int cX = vX.get(i);
int cY = vY.get(i);
int nY = vY.indexOf(cY,i+1); //index of right neighbour - one with the same Y
int nX = vX.indexOf(cX,i+1); //index of bottom neighbour - one with the same X
System.out.print(cX+" "+cY);
System.out.print(nY > 0 ? " "+vX.get(nY)+" "+cY : " -1 -1");
System.out.println(nX > 0 ? " "+cX+" "+vY.get(nX) : " -1 -1");
}
}
}