This repository was archived by the owner on Feb 29, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmoocast.java
More file actions
108 lines (92 loc) · 2.52 KB
/
moocast.java
File metadata and controls
108 lines (92 loc) · 2.52 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
import java.io.*;
import java.util.*;
public class moocast {
private static int[][] data;
private static int[][] map;
private static int cowstargeted;
private static int[][] modifmap;
private static int cownum;
public static void d(String a) {
System.out.println(a);
}
public static void Cast(int cow) {
d("Loading data varibles");
int range=data[cow][2];
int x=data[cow][0];
int y=data[cow][1];
int a,b;
d("Done");
//int count=0;
double calc=0;
for(int x1=x-range;x1<x+range;x1++) {
//count++;
if(cownum==0) {break;}
for(int y1=y-range;y1<y+range;y1++) {
if(cownum==0) {break;}
a=Math.max(x1-x, x-x1);
b=Math.max(y1-y, y-y1);
calc=Math.sqrt(a*a+b*b);
if(-1<x1&&-1<y1&&y1<25000&&x1<25000&&modifmap[x1][y1]!=0&&-1<calc&&calc<range+1) {
//count++;
////////////System.out.println("X Y = "+x1+" - "+y1+" "+count);
if(modifmap[x1][y1]>0) {
cownum--;
System.out.println("Cow found");
////////////System.out.println("RAnge:"+range);
////////////System.out.println(calc);
////////////System.out.println("We've hit a cow");
cowstargeted++;
modifmap[x1][y1]=0;//Eliminate the cow
//Above disables a cow
Cast(map[x1][y1]);
}
}
}
if(cownum==0) {break;}
}
}
public static void main(String[] args) throws IOException {
d("Reading");
BufferedReader f = new BufferedReader(new FileReader("3.in"));
int N=Integer.parseInt(f.readLine());//Read N
d("Parsed N");
data = new int[N][3];
StringTokenizer st;
map = new int[25000][25000];
d("Data init done");
cownum = N;
for(int i=0;i<N;i++) {
cownum=N;
/*Data Format
* 0 x
* 1 y
* 2 Power
*/
st=new StringTokenizer(f.readLine());
for(int j=0;j<3;j++) {
data[i][j]=Integer.parseInt(st.nextToken());
}
map[data[i][0]][data[i][1]]=i+1;
}
modifmap = map.clone();
f.close();
int high=1;
for(int i=0;i<N;i++) {
modifmap=map.clone();
cowstargeted=1;
////////////System.out.println("--Cow--");
Cast(i);
if(cowstargeted>high) {
System.out.println("New high");
high=cowstargeted;
}
}
////////////System.err.println(high);
f.close();
d("Closed f now writting output");
PrintWriter pw = new PrintWriter(new BufferedWriter(new FileWriter("moocast.out")));
pw.println(high);
pw.flush();
pw.close();
}
}