|
1 |
| - |
| 1 | +import java.io.*; |
| 2 | +import java.util.*; |
2 | 3 | public class barn1 {
|
3 |
| - |
4 |
| - public static void main(String[] args) { |
5 |
| - // TODO Auto-generated method stub |
6 |
| - |
| 4 | + public static int boarddist(int x,int y) { |
| 5 | + return Math.max(y-x, x-y);// Difference |
| 6 | + //TODO add offset if needed |
| 7 | + } |
| 8 | + public static int count(int[] arr) { |
| 9 | + boolean b=false;int c=0;int temp; |
| 10 | + for(int i=0;i<arr.length;i++) { |
| 11 | + temp=arr[i]; |
| 12 | + if(temp==0 && b) { |
| 13 | + b=false; |
| 14 | + c++; |
| 15 | + } |
| 16 | + if(temp==1 && b==false) { |
| 17 | + b=true; |
| 18 | + } |
| 19 | + } |
| 20 | + return c; |
| 21 | + } |
| 22 | + public static void main(String[] args) throws IOException{ |
| 23 | + /* |
| 24 | + *Variable names and what they means |
| 25 | + * bs prefix means blocked stall |
| 26 | + * x,y,z are really just M S C in the problem |
| 27 | + * bstalls is a array of blocked stalls |
| 28 | + * stalls is a Bit representation of all stalls |
| 29 | + * WARNING "blockedstalls" is a multi use temporary variable that is reused many times for memory efficency. |
| 30 | + */ |
| 31 | + BufferedReader f=new BufferedReader(new FileReader("barn1.in")); |
| 32 | + StringTokenizer st=new StringTokenizer(f.readLine()); |
| 33 | + int x=Integer.parseInt(st.nextToken());//Read x |
| 34 | + int y=Integer.parseInt(st.nextToken());//Read y |
| 35 | + int z=Integer.parseInt(st.nextToken());//Read z |
| 36 | + int[] stalls=new int[y+1];// Offset a bit |
| 37 | + int blockedstall=-1; |
| 38 | + int[] bstalls=new int[z+1];//Offset a bit |
| 39 | + for(int i=0;i<z;i++) { |
| 40 | + blockedstall=Integer.parseInt(f.readLine()); |
| 41 | + stalls[blockedstall]=1; |
| 42 | + bstalls[i]=blockedstall; |
| 43 | + |
| 44 | + } |
| 45 | + f.close(); |
| 46 | + f=null; |
| 47 | + for(int i:stalls) {System.out.print(i+" ");} |
| 48 | + int combination=0; |
| 49 | + int[][][] mergecosts=new int[y+1][(2*z*(z-1))+1][2];//int[Offset][Which combination][x,y] |
| 50 | + for(int i=0;i<mergecosts.length;i++) { |
| 51 | + for(int j=0;j<mergecosts[i].length;j++) { |
| 52 | + mergecosts[i][j][0]=-1; // Doubles check speed if first is -1 then skip |
| 53 | + } |
| 54 | + } |
| 55 | + |
| 56 | + for(int bs1:bstalls) { |
| 57 | + for(int bs2:bstalls) { |
| 58 | + if(bs1==bs2) { |
| 59 | + System.out.println("Debug point 2: Info, blockedstall: "+blockedstall+", combination: "+combination+", More info: bs1: "+bs1+", bs2: "+bs2); |
| 60 | + }else { |
| 61 | + combination++;//increment |
| 62 | + blockedstall=boarddist(bs1,bs2); |
| 63 | + System.out.println("Debug point 1: Info, blockedstall: "+blockedstall+", combination: "+combination+", More info: bs1: "+bs1+", bs2: "+bs2); |
| 64 | + mergecosts[blockedstall][combination][0]=bs1; |
| 65 | + mergecosts[blockedstall][combination][1]=bs2; |
| 66 | + |
| 67 | + } |
| 68 | + } |
| 69 | + } |
| 70 | + combination=0; |
| 71 | + //for(int i=0;i<) |
| 72 | + |
7 | 73 | }
|
8 | 74 |
|
9 | 75 | }
|
0 commit comments