結果
問題 | No.456 Millions of Submits! |
ユーザー | Grenache |
提出日時 | 2016-12-08 15:00:58 |
言語 | Java21 (openjdk 21) |
結果 |
WA
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 9,397 bytes |
コンパイル時間 | 5,178 ms |
コンパイル使用メモリ | 80,628 KB |
実行使用メモリ | 149,940 KB |
最終ジャッジ日時 | 2024-06-23 11:01:32 |
合計ジャッジ時間 | 16,510 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
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 | WA | - |
ソースコード
import java.io.*; import java.util.*; 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<>(); List<List<Pair>> hm2 = new ArrayList<>(); for (int i = 0; i < 11 * 11; i++) { hm2.add(new ArrayList<>()); } Pair[] ti = new Pair[m]; double[] ret = new double[m]; for (int i = 0; i < m; i++) { a[i] = sc.nextInt(); b[i] = sc.nextInt(); double t = sc.nextDouble(); ti[i] = new Pair(i, t); // if (a[i] == 0) { // ret[i] = Math.pow(Math.E, t); // continue; // } else if (b[i] == 0) { // ret[i] = Math.pow(Math.E, Math.log(t) / a[i]); // continue; // } int tmp = a[i] * 11 + b[i]; hm2.get(tmp).add(ti[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()) { for (int tt = 0; tt < 11 * 11; tt++) { if (hm2.get(tt).size() == 0) { continue; } List<Pair> ttl = hm2.get(tt); // int aa = tt.getKey() / 100; // int bb = tt.getKey() % 100; int aa = tt / 11; int bb = tt % 11; // Collections.sort(tt.getValue()); Collections.sort(ttl); q.clear(); // q.add(new Quad(0.0, 30000.0, null, 0, 0, tt.getValue().size())); q.add(new Quad(0.0, 30000.0, null, 0, 0, ttl.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; int from = ee.from; int to = ee.to; if (cnttmp > 44) { // for (Pair e : anstmp) { for (int j = from; j < to; j++) { // ret.put(tt.getValue().get(j).i * 1_000_000_000L + tt.getKey(), rtmp); // ret[tt.getValue().get(j).i] = rtmp; ret[ttl.get(j).i] = rtmp; } continue; } // List<Pair> ansr = new ArrayList<>(); // List<Pair> ansl = new ArrayList<>(); // ansr.clear(); // ansl.clear(); double mid = (ltmp + rtmp) / 2; double lnmid = Math.log(mid); // double f = Math.pow(mid, aa) * Math.pow(Math.log(mid), bb); double f = pow(mid, aa) * pow(lnmid, bb); // int index = binary_search(tt.getValue(), ee.from, ee.to, f); int index = binary_search(ttl, from, to, f); if (to > index) { q.add(new Quad(mid, rtmp, null, cnttmp + 1, index, to)); } if (from < index) { // q.add(new Quad(ltmp, mid, null, cnttmp + 1, from, index)); ee.r = mid; ee.cnt++; ee.to = index; q.add(ee); } /* 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(Double.toString(ret[i])); res.append('\n'); } pr.println(res); } private static double pow(double x, int a) { double ret = 1; while (a > 0) { if ((a & 0x1) != 0) { ret *= x; } x *= x; a >>= 1; } return ret; } 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()); double ret = 0; try { boolean flag = false; double base = 0.1; int ch = nextPrintable(); do { if (ch == '.') { flag = true; } else { if (!flag) { ret *= 10; ret += ch - '0'; } else { ret += (ch - '0') * base; base /= 10; } } } while (isPrintable(ch = br.read())); return ret; } catch (IOException e) { throw new NoSuchElementException(); } } 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); } } }