結果
| 問題 |
No.456 Millions of Submits!
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2016-12-07 23:39:22 |
| 言語 | Java (openjdk 23) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 5,887 bytes |
| コンパイル時間 | 4,441 ms |
| コンパイル使用メモリ | 81,360 KB |
| 実行使用メモリ | 175,652 KB |
| 最終ジャッジ日時 | 2024-06-23 04:08:08 |
| 合計ジャッジ時間 | 15,726 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 6 WA * 6 TLE * 1 |
ソースコード
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<Integer>> hm2 = new HashMap<>();
for (int i = 0; i < m; i++) {
a[i] = sc.nextInt();
b[i] = sc.nextInt();
t[i] = sc.nextDouble();
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(i);
}
Map<Long, Double> ret = new HashMap<>();
for (Entry<Integer, List<Integer>> tt : hm2.entrySet()) {
int aa = tt.getKey() / 100;
int bb = tt.getKey() % 100;
Queue<Double> l = new ArrayDeque<>();
Queue<Double> r = new ArrayDeque<>();
Queue<List<Integer>> ans = new ArrayDeque<>();
Queue<Integer> cnt = new ArrayDeque<>();
l.add(1.0);
r.add(30000.0);
ans.add(tt.getValue());
cnt.add(0);
while (!l.isEmpty()) {
double ltmp = l.remove();
double rtmp = r.remove();
List<Integer> anstmp = ans.remove();
int cnttmp = cnt.remove();
if (cnttmp > 60) {
for (int e : anstmp) {
ret.put(e * 1_000_000_000L + tt.getKey(), rtmp);
}
continue;
}
List<Integer> ansr = new ArrayList<>();
List<Integer> ansl = new ArrayList<>();
double mid = (ltmp + rtmp) / 2;
double f = Math.pow(mid, aa) * Math.pow(Math.log(mid), bb);
for (int i = 0, size = anstmp.size(); i < size; i++) {
// pr.printf("%e %e\n", mid, f);
if (f >= t[anstmp.get(i)]) {
ansr.add(anstmp.get(i));
} else {
ansl.add(anstmp.get(i));
}
}
if (ansr.size() > 0) {
l.add(ltmp);
r.add(mid);
ans.add(ansr);
cnt.add(cnttmp + 1);
}
if (ansl.size() > 0) {
l.add(mid);
r.add(rtmp);
ans.add(ansl);
cnt.add(cnttmp + 1);
}
}
}
for (int i = 0; i < m; i++) {
long key = i * 1_000_000_000L + a[i] * 100 + b[i];
pr.println(ret.get(key));
}
}
// ---------------------------------------------------
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);
}
}
}