When assessing the quality of binary classification, a confusion matrix is often used. Let's explain what it is. Suppose we have $$$N$$$ objects belonging to one of two classes (0 or 1). For example, the objects are X-ray images, where class 1 means the patient is sick, and class 0 means healthy. Let there be some algorithm that predicts the class of an object. Knowing the actual and predicted classes, we can construct the following table to evaluate the quality of the prediction:
| Predicted class = 1 | Predicted class = 0 | |
| Actual class = 1 | TP | FN |
| Actual class = 0 | FP | TN |
Here, the value TP (True Positive) is the number of objects for which the model predicted class 1, and they actually belong to class 1. The value TN (True Negative) is the number of objects for which the model predicted class 0, and they actually belong to class 0. The value FP (False Positive) is the number of objects for which the model predicted class 1, but they actually belong to class 0. The value FN (False Negative) is the number of objects for which the model predicted class 0, but they actually belong to class 1.
From the values in this table, we can compute two more characteristics—precision and recall.
Precision is calculated using the formula $$$precision = TP / (TP + FP)$$$, which indicates the proportion of objects that our algorithm classified as class 1 that actually belong to class 1.
Recall is calculated using the formula $$$recall = TP / (TP + FN)$$$, which indicates the proportion of class 1 objects among all class 1 objects that our algorithm found.
Suppose there were a total of 99 objects, of which 35 are class 0 and 64 are class 1. It is known that the model correctly identified the class for 51 objects. Find the answers to the following four questions.
In the answer, write four real numbers, each on a separate line. Use a point as the decimal separator. If you do not know any of the answers, write zeros instead. It is guaranteed that all numbers in the answer have a finite decimal part. In the "Language" field, select PHP (you do not need to know this language, it is just a feature of the checking system) and click the "Submit" button.
Scoring system: each correct answer is worth 25 points.
You are given a table with data on the evaluation of participants' solutions in a certain informatics olympiad: log.csv. A copy of this table is also available here: log.csv.
The table has 4 columns: problem — problem number (from 1 to 5); userId — participant identifier; language — programming language; score — points scored by the solution (from 0 to 100). The score values can also be empty (for example, if some solutions did not even compile on the server).
The olympiad was conducted according to traditional school rules: a participant can submit multiple solutions for each problem, and when summarizing the results, the best solution of the participant for each problem is selected, and the points for them are summed up.
Analyze the data in the table and answer the following 4 questions.
In your answer, write 4 integers, each on a separate line. Do not write anything extra. If you do not know some answers, write zeros instead. In the "Language" field, select PHP (you do not need to know this language, it is just a feature of the checking system) and click the "Submit" button.
Each correct answer is worth 25 points.
A well-known medical clinic has decided to add treatment for a dangerous disease called "Inflammation of Cunning" to its list of services. However, before treating the disease, it must be diagnosed. To this end, the clinic commissioned three medical laboratories to develop test systems for performing the diagnosis. After some time, the laboratories provided their results.
It is known that all test systems use different technologies and algorithms to identify the disease. Therefore, in this problem, we will consider their diagnoses to be independent of each other (note: in practice, some dependence would still exist, but we will ignore it here).
The first test system makes a correct diagnosis with a probability of $$$p_1$$$, the second with a probability of $$$p_2$$$, and the third with a probability of $$$p_3$$$. The final decision is made based on the majority of the results. That is, if any two or all three test systems determine that the patient is sick, then the patient is considered sick; otherwise, they are not. Determine the probability that the clinic will make correct diagnoses.
Three real numbers $$$p_1$$$, $$$p_2$$$, $$$p_3$$$ are given, each on a separate line ($$$0.5 \le p_1, p_2, p_3 \le 1$$$).
Output a single real number — the final probability of a correct diagnosis. The absolute or relative error of the answer must not exceed $$$10^{-4}$$$.
0.650.70.9
0.851
Measures of central tendency are statistical indicators that describe the "typical" or central value in a dataset. There are several such measures; we will consider three of them.
The median of a set of numbers of odd length is the element that will be in the middle if the numbers are sorted. The mode is the most frequently occurring element. There can be multiple modes. The arithmetic mean is the sum of all elements divided by their count.
Write a program that finds a set of five integers that simultaneously satisfies the following three conditions:
Three integers $$$x$$$, $$$y$$$, and $$$z$$$ are given, each on a separate line ($$$0 \le x, y, z \le 10^8$$$).
Output five integers that have the specified mode, median, and mean. The numbers must be in the range from $$$-10^9$$$ to $$$10^9$$$. If there are multiple valid answers, output any. If there are no solutions, output a single number -1.
125
1 9 1 2 12
132
-1
Solutions that work correctly for $$$x, y, z \le 10$$$ will be awarded 50 points.
Given $$$n$$$ points on a plane. Each point has coordinates $$$x_i$$$, $$$y_i$$$ and a color $$$c_i$$$, which can be white ($$$c_i=0$$$) or black ($$$c_i=1$$$).
To determine the color of a new point $$$P$$$, if it is unknown, the following approach can be used. The $$$k$$$ nearest points to it (where $$$k$$$ is some odd number) are taken, and the color that occurs most frequently among them is chosen. Note: the measure of proximity between two points can be calculated in different ways; in this problem, the usual Euclidean distance is used (i.e., the length of the segment between the points).
The quality of such a classifier depends on the choice of the parameter $$$k$$$. To find a good value for $$$k$$$, the following simple method can be used. We will look at what answers we get for our input points (for which the correct answers are known) with different $$$k$$$, and we will choose the value of $$$k$$$ for which the number of correct answers is maximized. This method is called "LOO cross-validation."
Let's explain how this method works in more detail. We will iterate through all odd values of $$$k$$$ in the range from $$$1$$$ to $$$n-1$$$. For each such $$$k$$$, we will iterate through all points. For each of them, we will find the $$$k$$$ nearest other points (not counting itself), take the color that occurs most frequently among them, and compare it with the actual color of that point. The more correct answers we get for the current value of $$$k$$$, the better that value is. Of course, to improve efficiency, the described implementation of the algorithm can be modified — the main thing is that the results remain correct.
Write a program that determines for each odd $$$k$$$ in the range from 1 to $$$n$$$ how many points will have their color correctly classified for the given $$$k$$$ during LOO cross-validation.
The first line of the input contains an integer $$$n$$$ ($$$2 \le n \le 1000$$$).
The following $$$n$$$ lines contain triples of numbers $$$x_i$$$, $$$y_i$$$, and $$$c_i$$$ — the coordinates of the next point ($$$-20000 \le x_i, y_i \le 20000$$$) and its color $$$c_i$$$ (which is either 0 or 1).
It is guaranteed that no two points coincide and the distances between all pairs of points are distinct.
Output the number of correctly classified points for $$$k=1$$$, $$$k=3$$$, $$$k=5$$$, and so on up to $$$n-1$$$ (if $$$n-1$$$ is even, then up to $$$n-2$$$). You do not need to output the values of $$$k$$$ themselves.
41 2 0-3 1 10 0 14 5 0
2 0
Subtask 1 (up to 30 points): $$$n \le 50$$$.
Subtask 2 (up to 30 points): $$$n \le 200$$$.
Subtask 3 (up to 40 points): $$$n \le 1000$$$.
Note for those writing in Python. You can input three numbers separated by spaces like this:
x, y, c = [int(x) for x in input().split()]
Vasya decided to develop a plugin for the new messenger Min. The plugin should determine whether an incoming message is fraudulent (i.e., written by scammers). Vasya has almost completed the work and implemented an algorithm that gives a score P for each message. The higher this score, the greater the likelihood that the message is fraudulent. The last detail remains — it is necessary to determine the triggering threshold, that is, starting from what threshold value T messages with a score P ≥ T will be considered fraudulent by the algorithm.
To solve this problem, Vasya formed a training dataset of N messages and enlisted the help of his classmates as experts. They read these N messages and marked which of them are fraudulent. All other messages are not fraudulent.
To evaluate the quality of the algorithm, Vasya decided to use the F1 metric. Let's explain how it is calculated. We introduce the following notations:
Then the values of precision and recall are calculated using the formulas:
precision = TP / (TP + FP), which indicates what proportion of messages that our algorithm labeled as fraudulent are indeed fraudulent.
recall = TP / (TP + FN), which indicates what proportion of fraudulent messages among all fraudulent messages our algorithm found.
The F1 metric is calculated using the formula:
Note: In the case when both precision and recall are zero, the resulting F1 metric is also zero.
The larger the value of the F1 metric, the higher the quality of classification. Find such a natural number — the threshold value T, which gives the maximum value of F1.
The first line of the input data contains the number N (1 ≤ N ≤ 105) — the total number of messages.
The second line lists N natural numbers separated by spaces in the range from 1 to 109 — the score values P for each message.
The third line contains the number K (1 ≤ K ≤ N) — the number of fraudulent messages.
The fourth line lists K distinct integers in the range from 1 to N in arbitrary order — the indices of the fraudulent messages.
Output a single natural number — the threshold value T, at which the maximum value of the F1 metric is achieved. If there are multiple correct answers, output the smallest one.
5
1 2 3 4 5
3
1 4 3
1
10
1 2 3 4 5 6 7 8 100 1000
1
9
9
Note for Python users. To input a set of space-separated integers, you can do it like this:
a = [int(x) for x in input().split()]
Grading system.
Subtask 1 (up to 60 points): N ≤ 100.
Subtask 2 (up to 40 points): N ≤ 105.