Paste TaS1 decompiled, #IzI -- näytä pelkkänä tekstinä -- uusi tämän pohjalta
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 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 | // Decompiled by Jad v1.5.8e. Copyright 2001 Pavel Kouznetsov. // Jad home page: http://www.geocities.com/kpdus/jad.html // Decompiler options: packimports(3) // Source File Name: TaS1.java import java.io.PrintStream; import java.util.Scanner; class TaS1 { TaS1() { } public int ruutu(int i, int j) { if(1 <= i && i <= leveys && 1 <= j && j <= leveys) return lauta[i][j]; else return 0; } public void aseta(int i, int j, int k) { lauta[i][j] = -1 * k; int l = k; if(lauta[i + 1][j] > -1) lauta[i + 1][j] = -5; if(lauta[i - 1][j] > -1) lauta[i - 1][j] = -5; if(lauta[i][j + 1] > -1) lauta[i][j + 1] = -5; if(lauta[i][j - 1] > -1) lauta[i][j - 1] = -5; if(pelinumero == k) { l = raja; if(lauta[i + 1][j + 1] > -1 && lauta[i + 1][j + 1] < raja) lauta[i + 1][j + 1] += l; if(lauta[i + 1][j - 1] > -1 && lauta[i + 1][j - 1] < raja) lauta[i + 1][j - 1] += l; if(lauta[i - 1][j + 1] > -1 && lauta[i - 1][j + 1] < raja) lauta[i - 1][j + 1] += l; if(lauta[i - 1][j - 1] > -1 && lauta[i - 1][j - 1] < raja) lauta[i - 1][j - 1] += l; } else { if(lauta[i + 1][j + 1] > -1) lauta[i + 1][j + 1] += l; if(lauta[i + 1][j - 1] > -1) lauta[i + 1][j - 1] += l; if(lauta[i - 1][j + 1] > -1) lauta[i - 1][j + 1] += l; if(lauta[i - 1][j - 1] > -1) lauta[i - 1][j - 1] += l; } } public boolean sivutVapaat(int i, int j) { return ruutu(i + 1, j) == 0 && ruutu(i - 1, j) == 0 && ruutu(i, j + 1) == 0 && ruutu(i, j - 1) == 0; } public boolean kulmittain(int i, int j, int k) { return ruutu(i + 1, j + 1) == k || ruutu(i - 1, j + 1) == k || ruutu(i - 1, j - 1) == k || ruutu(i + 1, j - 1) == k; } public boolean kulmaruutu(int i, int j) { return (i == 1 || i == leveys) && (j == 1 || j == leveys); } public int[] valitse(boolean flag) { int i = 0; int j = 0; int k = 0; double d = 0.0D; double d2 = 0.0D; boolean flag1 = false; for(int l = 1; l <= leveys; l++) { for(int i1 = 1; i1 <= leveys; i1++) { if(ruutu(i1, l) <= raja - 1) continue; flag1 = true; if(ruutu(i1, l) > k) { i = i1; j = l; k = ruutu(i1, l); continue; } if(ruutu(i1, l) != k) continue; double d1 = Math.sqrt(Math.pow(i - Targetx, 2D) + Math.pow(j - Targety, 2D)); double d3 = Math.sqrt(Math.pow(i1 - Targetx, 2D) + Math.pow(l - Targety, 2D)); if(d3 < d1) { i = i1; j = l; } } } if(flag) { if(i == 1) Targetx = leveys; if(i == leveys) Targetx = 1; if(j == 1) Targety = leveys; if(j == leveys) Targety = 1; } if(flag1) return (new int[] { i, j }); else return null; } public void kirjaa(int ai[], int i) { for(int j = 0; j < ai.length; j += 2) aseta(ai[j], ai[j + 1], i); } public void run() { System.out.println("TaS1"); System.out.flush(); Scanner scanner = new Scanner(System.in); leveys = scanner.nextInt(); pelaajia = scanner.nextInt(); pelinumero = scanner.nextInt(); raja = 50; Targetx = leveys / 2; Targety = leveys / 2; lauta = new int[leveys + 2][leveys + 2]; lauta[1][1] = raja; lauta[1][leveys] = raja; lauta[leveys][1] = raja; lauta[leveys][leveys] = raja; for(int i = 0; i < leveys + 2; i++) { lauta[0][i] = -8; lauta[leveys + 1][i] = -8; lauta[i][0] = -8; lauta[i][leveys + 1] = -8; } int j = 0; do { int k = 1 + j % pelaajia; if(k == pelinumero) { boolean flag = j < pelaajia; int ai[] = valitse(flag); if(ai == null) break; kirjaa(ai, pelinumero); System.out.print(ai.length / 2); int ai2[] = ai; int j1 = ai2.length; for(int k1 = 0; k1 < j1; k1++) { int l1 = ai2[k1]; System.out.print(' '); System.out.print(l1); } System.out.println(); System.out.flush(); } else { int l = scanner.nextInt(); if(l == -1) break; int ai1[] = new int[2 * l]; for(int i1 = 0; i1 < l; i1++) { ai1[2 * i1 + 0] = scanner.nextInt(); ai1[2 * i1 + 1] = scanner.nextInt(); } kirjaa(ai1, k); } j++; } while(true); } public static void main(String args[]) { (new TaS1()).run(); } public static final String NIMI = "TaS1"; private int lauta[][]; private int leveys; private int pelaajia; private int pelinumero; private int raja; private int Targetx; private int Targety; } |