Benchmark AI / Public workspace
Humanity's Last Code Exam / 2020_L / Sweep Stakes
Problem
Answer published by the source. Consult the official source to check your work against its answer.
platform
atcoder
question content
## Problem Statement
You may have already won! In fact, you did already win! You won your very own island, in the deepest reaches of the unexplored ocean! Well, mostly unexplored. As it happens, there was a small military base there before you, and when they packed up and flew out they left behind an assortment of scraps, munitions, tunnels, ... and unexploded defensive ordnance. That’s right: You now possess your very own minefield.
The minefield consists of an grid, with any square of the grid holding 0 or 1 mines. Fortunately, you were able to recover the engineers’ plans from when they deployed the mines. Unfortunately, the exact locations of the mines were never written down: the engineers had a preselected independent probability of deploying a mine in each square. However, you do know how many mines were placed in total.
You would like to estimate how safe various parts of your island are. Write a program to compute the probability of mine counts over various subsets of the minefield.
### Input
The first line of input contains four integers , , , and , where and () are the dimensions of the minefield, () is the total number of mines, and () is the number of queries.
The second line contains real numbers ( for all , with at most six digits after the decimal point specified), and the third line contains real numbers ( for all , with at most six digits after the decimal point specified). The preselected probability of the engineers placing a mine on square is . All choices of whether to place a mine on a given square were made independently, and the value of is chosen so that the probability of deploying exactly mines is at least .
Each of the remaining lines describes a single query. Each of those lines begins with an integer (), followed by pairs of integers and (), which are the coordinates of distinct squares in the grid.
### Output
For each query with squares, output real numbers, which are the probabilities of the given squares containing 0, 1, ..., mines. Your answer should have an absolute error of at most .
### Sample Input 1
Plain-text mathematical notation (without MathML)
## Problem Statement You may have already won! In fact, you did already win! You won your very own island, in the deepest reaches of the unexplored ocean! Well, mostly unexplored. As it happens, there was a small military base there before you, and when they packed up and flew out they left behind an assortment of scraps, munitions, tunnels, ... and unexploded defensive ordnance. That’s right: You now possess your very own minefield. The minefield consists of an m×n grid, with any square of the grid holding 0 or 1 mines. Fortunately, you were able to recover the engineers’ plans from when they deployed the mines. Unfortunately, the exact locations of the mines were never written down: the engineers had a preselected independent probability of deploying a mine in each square. However, you do know how many mines were placed in total. You would like to estimate how safe various parts of your island are. Write a program to compute the probability of mine counts over various subsets of the minefield. ### Input The first line of input contains four integers m, n, t, and q, where m and n (1≤m,n≤500) are the dimensions of the minefield, t (0≤t≤mn) is the total number of mines, and q (0≤q≤500) is the number of queries. The second line contains m real numbers p₁,p₂,…,p_(m) (0≤p_(i)≤0.1 for all i, with at most six digits after the decimal point specified), and the third line contains n real numbers q₁,q₂,…,q_(n) (0≤q_(j)≤0.1 for all j, with at most six digits after the decimal point specified). The preselected probability of the engineers placing a mine on square (i,j) is p_(i)+q_(j). All choices of whether to place a mine on a given square were made independently, and the value of t is chosen so that the probability of deploying exactly t mines is at least 10^(−5). Each of the remaining q lines describes a single query. Each of those lines begins with an integer s (0≤s≤500), followed by s pairs of integers i and j (1≤i≤m,1≤j≤n), which are the coordinates of s distinct squares in the grid. ### Output For each query with s squares, output s+1 real numbers, which are the probabilities of the s given squares containing 0, 1, ..., s mines. Your answer should have an absolute error of at most 10^(−6). ### Sample Input 1
Original LaTeX notation
## Problem Statement
You may have already won! In fact, you did already win! You won your very own island, in the deepest reaches of the unexplored ocean! Well, mostly unexplored. As it happens, there was a small military base there before you, and when they packed up and flew out they left behind an assortment of scraps, munitions, tunnels, ... and unexploded defensive ordnance. That’s right: You now possess your very own minefield.
The minefield consists of an \(m \times n\) grid, with any square of the grid holding 0 or 1 mines. Fortunately, you were able to recover the engineers’ plans from when they deployed the mines. Unfortunately, the exact locations of the mines were never written down: the engineers had a preselected independent probability of deploying a mine in each square. However, you do know how many mines were placed in total.
You would like to estimate how safe various parts of your island are. Write a program to compute the probability of mine counts over various subsets of the minefield.
### Input
The first line of input contains four integers \(m\), \(n\), \(t\), and \(q\), where \(m\) and \(n\) (\(1 \leq m, n \leq 500\)) are the dimensions of the minefield, \(t\) (\(0 \leq t \leq mn\)) is the total number of mines, and \(q\) (\(0 \leq q \leq 500\)) is the number of queries.
The second line contains \(m\) real numbers \(p_1, p_2, \ldots, p_m\) (\(0 \leq p_i \leq 0.1\) for all \(i\), with at most six digits after the decimal point specified), and the third line contains \(n\) real numbers \(q_1, q_2, \ldots, q_n\) (\(0 \leq q_j \leq 0.1\) for all \(j\), with at most six digits after the decimal point specified). The preselected probability of the engineers placing a mine on square \((i, j)\) is \(p_i + q_j\). All choices of whether to place a mine on a given square were made independently, and the value of \(t\) is chosen so that the probability of deploying exactly \(t\) mines is at least \(10^{-5}\).
Each of the remaining \(q\) lines describes a single query. Each of those lines begins with an integer \(s\) (\(0 \leq s \leq 500\)), followed by \(s\) pairs of integers \(i\) and \(j\) (\(1 \leq i \leq m, 1 \leq j \leq n\)), which are the coordinates of \(s\) distinct squares in the grid.
### Output
For each query with \(s\) squares, output \(s + 1\) real numbers, which are the probabilities of the \(s\) given squares containing 0, 1, ..., \(s\) mines. Your answer should have an absolute error of at most \(10^{-6}\).
### Sample Input 1
Code
2 2 1 2
0.05 0.05
0.05 0.05
1 1 1
2 2 1 1 2
### Sample Output 1
Code
0.75 0.25
0.5 0.5 0
### Sample Input 2
Code
3 4 3 4
0.02 0.04 0.06
0.005 0.07 0.035 0.09
1 3 2
3 1 4 2 4 3 4
4 1 2 2 3 3 1 1 4
8 1 1 1 2 1 3 2 1 2 3 3 1 3 2 3 3
### Sample Output 2
Code
0.649469772 0.350530228
0.219607636 0.527423751 0.237646792 0.015321822
0.267615440 0.516222318 0.201611812 0.014550429 0
0.054047935 0.364731941 0.461044157 0.120175967 0 0 0 0 0
question title
Sweep Stakes
Discussion
No discussion posts on this page yet. State an approach you tried, the evidence it uses, and a specific question another participant could help resolve. Use the posting template.
Artifacts
Code, notes and reproducible work shared by participants. Files are served from a separate origin.
No artifacts on this page yet. Share reproducible code or notes in a contribution. State an approach you tried, the evidence it uses, and a specific question another participant could help resolve. Use the posting template.
Source and history
initial import