結果
問題 | No.456 Millions of Submits! |
ユーザー | Grenache |
提出日時 | 2016-12-08 10:01:43 |
言語 | Java21 (openjdk 21) |
結果 |
WA
|
実行時間 | - |
コード長 | 7,809 bytes |
コンパイル時間 | 4,697 ms |
コンパイル使用メモリ | 81,884 KB |
実行使用メモリ | 275,888 KB |
最終ジャッジ日時 | 2024-06-23 08:26:26 |
合計ジャッジ時間 | 15,108 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | WA | - |
testcase_01 | WA | - |
testcase_02 | WA | - |
testcase_03 | WA | - |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | TLE | - |
ソースコード
import java.io.*; import java.util.*; import java.util.Map.*; public class Main_yukicoder456 { private static Scanner sc; private static Printer pr; private static void solve() { int m = sc.nextInt(); int[] a = new int[m]; int[] b = new int[m]; double[] t = new double[m]; // Map<Integer, List<Double>> hm = new HashMap<>(); Map<Integer, List<Pair>> hm2 = new HashMap<>(); Pair[] ti = new Pair[m]; for (int i = 0; i < m; i++) { a[i] = sc.nextInt(); b[i] = sc.nextInt(); t[i] = sc.nextDouble(); ti[i] = new Pair(i, t[i]); int tmp = a[i] * 100 + b[i]; if (!hm2.containsKey(tmp)) { // hm.put(tmp, new ArrayList<>()); hm2.put(tmp, new ArrayList<>()); } // hm.get(tmp).add(t[i]); hm2.get(tmp).add(ti[i]); } // Arrays.sort(ti); Map<Long, Double> ret = new HashMap<>(); // Queue<Double> l = new ArrayDeque<>(); // Queue<Double> r = new ArrayDeque<>(); // Queue<List<Integer>> ans = new ArrayDeque<>(); // Queue<Integer> cnt = new ArrayDeque<>(); Queue<Quad> q = new ArrayDeque<>(); for (Entry<Integer, List<Pair>> tt : hm2.entrySet()) { int aa = tt.getKey() / 100; int bb = tt.getKey() % 100; Collections.sort(tt.getValue()); q.clear(); q.add(new Quad(0.0, 30000.0, null, 0, 0, tt.getValue().size())); // l.add(0.0); // r.add(30000.0); // ans.add(tt.getValue()); // cnt.add(0); while (!q.isEmpty()) { Quad ee = q.remove(); double ltmp = ee.l; double rtmp = ee.r; List<Pair> anstmp = ee.ans; int cnttmp = ee.cnt; if (cnttmp > 50) { // for (Pair e : anstmp) { for (int j = ee.from; j < ee.to; j++) { ret.put(tt.getValue().get(j).i * 1_000_000_000L + tt.getKey(), rtmp); } continue; } // List<Pair> ansr = new ArrayList<>(); // List<Pair> ansl = new ArrayList<>(); // ansr.clear(); // ansl.clear(); double mid = (ltmp + rtmp) / 2; double f = Math.pow(mid, aa) * Math.pow(Math.log(mid), bb); int index = binary_search(tt.getValue(), ee.from, ee.to, f); if (ee.to > index) { q.add(new Quad(mid, rtmp, null, cnttmp + 1, index, ee.to)); } if (ee.from < index) { q.add(new Quad(ltmp, mid, null, cnttmp + 1, ee.from, index)); } /* for (int i = 0, size = anstmp.size(); i < size; i++) { // pr.printf("%e %e\n", mid, f); if (f >= t[anstmp.get(i).i]) { ansr.add(anstmp.get(i)); } else { ansl.add(anstmp.get(i)); } } if (ansr.size() > 0) { q.add(new Quad(ltmp, mid, ansr, cnttmp + 1)); // l.add(ltmp); // r.add(mid); // ans.add(ansr); // cnt.add(cnttmp + 1); } if (ansl.size() > 0) { q.add(new Quad(mid, rtmp, ansl, cnttmp + 1)); // l.add(mid); // r.add(rtmp); // ans.add(ansl); // cnt.add(cnttmp + 1); } */ } } StringBuilder res = new StringBuilder(); for (int i = 0; i < m; i++) { long key = i * 1_000_000_000L + a[i] * 100 + b[i]; // pr.printf("%.10f\n", ret.get(key)); // pr.println(Double.toString(ret.get(key))); res.append(Double.toString(ret.get(key))); res.append('\n'); } pr.println(res); } private static class Pair implements Comparable<Pair> { int i; double t; Pair(int i, double t) { this.i = i; this.t = t; } @Override public int compareTo(Pair o) { return Double.compare(t, o.t); } } private static class Quad { double l; double r; List<Pair> ans; int cnt; int from; int to; Quad(double l, double r, List<Pair> list, int cnt, int from, int to) { this.l = l; this.r = r; this.ans = list; this.cnt = cnt; this.from = from; this.to = to; } } private static int binary_search(List<Pair> data, int l, int r, double value) { while (r > l) { int mid = l + (r - l) / 2; if (data.get(mid).t >= value) { // if (data[mid] > value) { r = mid; } else { l = mid + 1; } } return l; /* while (r - l > 1) { int mid = l + (r - l) / 2; if (data.get(mid).t >= value) { // if (data[mid] > value) { r = mid; } else { l = mid; } } return r; // return l + 1; */ } // --------------------------------------------------- public static void main(String[] args) { sc = new Scanner(System.in); pr = new Printer(System.out); solve(); pr.close(); sc.close(); } @SuppressWarnings("unused") private static class Scanner { BufferedReader br; Scanner (InputStream in) { br = new BufferedReader(new InputStreamReader(in)); } private boolean isPrintable(int ch) { return ch >= '!' && ch <= '~'; } private boolean isCRLF(int ch) { return ch == '\n' || ch == '\r' || ch == -1; } private int nextPrintable() { try { int ch; while (!isPrintable(ch = br.read())) { if (ch == -1) { throw new NoSuchElementException(); } } return ch; } catch (IOException e) { throw new NoSuchElementException(); } } String next() { try { int ch = nextPrintable(); StringBuilder sb = new StringBuilder(); do { sb.appendCodePoint(ch); } while (isPrintable(ch = br.read())); return sb.toString(); } catch (IOException e) { throw new NoSuchElementException(); } } int nextInt() { try { // parseInt from Integer.parseInt() boolean negative = false; int res = 0; int limit = -Integer.MAX_VALUE; int radix = 10; int fc = nextPrintable(); if (fc < '0') { if (fc == '-') { negative = true; limit = Integer.MIN_VALUE; } else if (fc != '+') { throw new NumberFormatException(); } fc = br.read(); } int multmin = limit / radix; int ch = fc; do { int digit = ch - '0'; if (digit < 0 || digit >= radix) { throw new NumberFormatException(); } if (res < multmin) { throw new NumberFormatException(); } res *= radix; if (res < limit + digit) { throw new NumberFormatException(); } res -= digit; } while (isPrintable(ch = br.read())); return negative ? res : -res; } catch (IOException e) { throw new NoSuchElementException(); } } long nextLong() { try { // parseLong from Long.parseLong() boolean negative = false; long res = 0; long limit = -Long.MAX_VALUE; int radix = 10; int fc = nextPrintable(); if (fc < '0') { if (fc == '-') { negative = true; limit = Long.MIN_VALUE; } else if (fc != '+') { throw new NumberFormatException(); } fc = br.read(); } long multmin = limit / radix; int ch = fc; do { int digit = ch - '0'; if (digit < 0 || digit >= radix) { throw new NumberFormatException(); } if (res < multmin) { throw new NumberFormatException(); } res *= radix; if (res < limit + digit) { throw new NumberFormatException(); } res -= digit; } while (isPrintable(ch = br.read())); return negative ? res : -res; } catch (IOException e) { throw new NoSuchElementException(); } } float nextFloat() { return Float.parseFloat(next()); } double nextDouble() { return Double.parseDouble(next()); } String nextLine() { try { int ch; while (isCRLF(ch = br.read())) { if (ch == -1) { throw new NoSuchElementException(); } } StringBuilder sb = new StringBuilder(); do { sb.appendCodePoint(ch); } while (!isCRLF(ch = br.read())); return sb.toString(); } catch (IOException e) { throw new NoSuchElementException(); } } void close() { try { br.close(); } catch (IOException e) { // throw new NoSuchElementException(); } } } private static class Printer extends PrintWriter { Printer(PrintStream out) { super(out); } } }