제출 #440216

#제출 시각아이디문제언어결과실행 시간메모리
440216ImaginaryIQBalloons (CEOI11_bal)Java
컴파일 에러
0 ms0 KiB
import java.io.*; import java.util.*; public class Main { static class Kattio extends PrintWriter { private BufferedReader r; private StringTokenizer st; // standard input public Kattio() { this(System.in, System.out); } public Kattio(InputStream i, OutputStream o) { super(o); r = new BufferedReader(new InputStreamReader(i)); } // USACO-style file input public Kattio(String problemName) throws IOException { super(new FileWriter(problemName + ".out")); r = new BufferedReader(new FileReader(problemName + ".in")); } // returns null if no more input public String next() { try { while (st == null || !st.hasMoreTokens()) st = new StringTokenizer(r.readLine()); return st.nextToken(); } catch (Exception e) { } return null; } public int nextInt() { return Integer.parseInt(next()); } public double nextDouble() { return Double.parseDouble(next()); } public long nextLong() { return Long.parseLong(next()); } } static int n; static pair [] arr; static double [] ans; static Stack<pair> stack = new Stack<>(); public static void main(String[] args) throws IOException { Kattio io = new Kattio("bal"); n = io.nextInt(); arr = new pair[n+1]; ans = new double[n+1]; arr[0] = new pair(0 , 0); for (int i = 1; i <= n; i++) { arr[i] = new pair(io.nextInt(), io.nextInt()); } for (int i = 1; i <= n; i++) { pair minRad = arr[i]; while((!stack.isEmpty()) && check(arr[i])){ if(check(arr[i])){ // mark the touching radius minRad.y = Math.min(minRad.y, calIntersect(minRad)); stack.pop(); } } ans[i] = minRad.y; stack.add(minRad); } for (int i = 1; i <= n; i++) { io.printf("%.3f", ans[i]); if(i == n) break; io.println(); } io.close(); } static double calIntersect(pair p1){ return Math.pow(stack.peek().x - p1.x, 2) / (4 * stack.peek().y); } static boolean check(pair p1){ // check if the circle intersects double x1 = p1.x, y1 = p1.y, x2 = stack.peek().x, y2 = stack.peek().y, r1 = p1.y, r2 = stack.peek().y; double distSq = (x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2); double radSumSq = (r1 + r2) * (r1 + r2); if (distSq == radSumSq) return false; else if (distSq > radSumSq) return false; else return true; } public static class pair { private final int x; private double y; public pair(final int x, final double y) { this.x = x; this.y = y; } @Override public boolean equals(final Object o) { if (this == o) { return true; } if (!(o instanceof pair)) { return false; } final pair pair = (pair) o; if (x != pair.x) { return false; } if (y != pair.y) { return false; } return true; } @Override public int hashCode() { int result = x; result = 31 * result + (int)y; return result; } } }

컴파일 시 표준 에러 (stderr) 메시지

bal.java:5: error: class Main is public, should be declared in a file named Main.java
public class Main {
       ^
1 error