結果
| 問題 |
No.309 シャイな人たち (1)
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2015-12-02 20:44:45 |
| 言語 | Java (openjdk 23) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 3,531 bytes |
| コンパイル時間 | 4,631 ms |
| コンパイル使用メモリ | 79,708 KB |
| 実行使用メモリ | 64,364 KB |
| 最終ジャッジ日時 | 2024-09-14 08:02:33 |
| 合計ジャッジ時間 | 13,575 ms |
|
ジャッジサーバーID (参考情報) |
judge6 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | -- * 3 |
| other | WA * 1 TLE * 1 -- * 11 |
ソースコード
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Iterator;
public class Main_yukicoder309 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
Printer pr = new Printer(System.out);
int r = sc.nextInt();
int c = sc.nextInt();
int[][] p = new int[r][c];
int[][] s = new int[r][c];
for (int i = 0; i < r; i++) {
for (int j = 0; j < c; j++) {
String tmp;
for (tmp = sc.next(); tmp.equals(""); tmp = sc.next()) {
}
p[i][j] = Integer.parseInt(tmp);
}
}
for (int i = 0; i < r; i++) {
for (int j = 0; j < c; j++) {
String tmp;
for (tmp = sc.next(); tmp.equals(""); tmp = sc.next()) {
}
s[i][j] = Integer.parseInt(tmp);
}
}
int n = 0x1 << c;
double[][] dp = new double[r + 1][n];
double dtmp = 1;
for (int i = 0; i < c; i++) {
dtmp /= 2;
}
Arrays.fill(dp[0], dtmp);
// for (int i = 1; i <= r; i++) {
// Arrays.fill(dp[i], 1.0);
// }
for (int i = 1; i <= r; i++) {
for (int j = 0; j < n; j++) {
for (int k = 0; k < n; k++) {
if (dp[i - 1][k] == 0) {
continue;
}
double ptmp2 = 1.0;
for (int l = 0; l < c && ptmp2 != 0; l++) {
int po = 0;
if (i != 1 && (k & 0x1 << l) != 0) {
po += 1;
}
if (l - 1 >= 0 && (j & 0x1 << l - 1) != 0) {
po += 1;
}
if (l + 1 < c && (j & 0x1 << l + 1) != 0) {
po += 1;
}
double ptmp = 0;
if (po + 4 - s[i - 1][l] >= 4) {
ptmp = (double)p[i - 1][l] / 100;
}
if ((j & 0x1 << l) != 0) {
ptmp2 *= ptmp;
} else {
ptmp2 *= (1.0 - ptmp);
}
}
dp[i][j] += ptmp2 * dp[i - 1][k];
}
}
}
double ret = 0;
for (int i = 1; i <= r; i++) {
for (int j = 0; j < n; j++) {
ret += dp[i][j] * Integer.bitCount(j);
}
}
pr.printf("%.14f\n", ret);
pr.close();
sc.close();
}
@SuppressWarnings("unused")
private static class Scanner {
BufferedReader br;
Iterator<String> it;
Scanner (InputStream in) {
br = new BufferedReader(new InputStreamReader(in));
}
String next() throws RuntimeException {
try {
if (it == null || !it.hasNext()) {
it = Arrays.asList(br.readLine().split(" ")).iterator();
}
return it.next();
} catch (IOException e) {
throw new IllegalStateException();
}
}
int nextInt() throws RuntimeException {
return Integer.parseInt(next());
}
long nextLong() throws RuntimeException {
return Long.parseLong(next());
}
float nextFloat() throws RuntimeException {
return Float.parseFloat(next());
}
double nextDouble() throws RuntimeException {
return Double.parseDouble(next());
}
void close() {
try {
br.close();
} catch (IOException e) {
// throw new IllegalStateException();
}
}
}
private static class Printer extends PrintWriter {
Printer(PrintStream out) {
super(out);
}
}
}