Kick the ball!(dfs)湖南省赛第十届

Problem K: Kick the ball!

Time Limit: 1 Sec  Memory Limit: 128 MB  Special Judge

Submit: 109  Solved: 82

[Submit][Status][Web
Board
]

Description

"A penalty shoot-out (officially kicks from the penalty mark) is a method of determining the winner of an association football (soccer) match that is drawn after the regulation playing time and any applicable extra time periods have been played. In a penalty
shoot-out, each team takes turns attempting a specified number of shots from the penalty mark (usually 5) that are only defended by the opposing team‘s goalkeeper, with the team scoring the most goals being declared the winner."

-- wikipedia

The game finally comes to the shoot-out. What will the final result be?

"1-3!" You took a wild guess. But what is the probability that your guess is correct?

In this problem, team A kicks first (which is determined by a coin toss, as usual), both teams will attempt at most 5 shots (after all the 10 shots, the game may end in draw again), but the game will end as soon as the winner is already determined. For example,
after the first 8 kicks the score is 3-2 (left side is team A’s score, right side is team B), then if the 9-th kick is a goal, the game will end immediately with score 4-2, because even team B got its last kick, it still loses for sure. Another example: if
all the first 9 kicks are goals, the last kick (from team B) will still be performed, because although team B cannot win, the result might be a "draw", which is better than "lose".

Input

There will be at most 100 test cases. Each case contains two lines. The first line contains 10 floating numbers. The first 5 numbers are the goal probability of the players in team A (player 1 will shoot first, etc), the next 5 numbers are the goal probabilities
of the players in team B. Each probability will have exactly one digit after the decimal point. The second line contains your guess, in the format of scoreA-scoreB. 0<=scoreA,scoreB<=5.

Output

For each test case, print the case number and the probability (in percentage) that your wild guess is correct, to 2 decimal places. An absolute error of 0.01% will be ignored.

Sample Input

0.4 0.7 0.7 0.6 0.5 0.8 0.9 0.7 0.2 0.8
1-3
1.0 1.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 1.0
2-0
1.0 1.0 0.0 0.0 0.0 0.0 0.0 0.0 1.0 0.0
2-0
0.4 0.7 0.7 0.6 0.5 0.8 0.9 0.7 0.2 0.8
5-5
0.4 0.7 0.7 0.6 0.5 0.8 0.9 0.7 0.2 0.8
4-2

Sample Output

Case 1: 6.98%
Case 2: 100.00%
Case 3: 0.00%
Case 4: 0.47%
Case 5: 9.73%

HINT

题意:点球大战,轮流每队点射5个球。A先踢。A、B轮流踢,假设当前比分已经能直接让比赛胜利接下来的球就不须要踢了。问最后的得分是题所给出的得分的概率

思路:暴力DFS,直接枚举哪些球进了哪些球没进,注意比赛提前结束这个特殊的剪枝即可。

链接:http://acm.csu.edu.cn/OnlineJudge/problem.php?

cid=2095&pid=10

#include<stdio.h>
double pi[15];
int x;
int y;
double ans;
bool judge(int a,int b,int t)
{
    if(a-b-(t+1)/2>0) return true;//a>b,假设推断的这个点是b点。那么t是奇数须要(t+1)/2,假设是a点t为偶数t/2=(t+1)/2
    if(b-a-t/2>0) return true;//b>a,假设推断的这个点是b点,那么t是奇数须要(t+1)/2个求能够胜,可是b>a了。所以假设这球不得分,假设是a点t为偶数t/2=(t+1)/2
    return false;
}
void dfs(int a,int b,int k,double p)
{

    if(p<1e-6) return ;
    if(k==10)
    {
       // printf("a=%d,b=%d\n",a,b);
        if(a==x&&b==y)
            ans+=p;
        return ;
    }
    if(judge(a,b,10-k))//推断这一脚要不要踢
    {
        dfs(a,b,k+1,p);
        return ;
    }
    if(k&1)
    {
        dfs(a,b+1,k+1,p*pi[k]);
        dfs(a,b,k+1,p*(1-pi[k]));
    }
    else
    {
        dfs(a+1,b,k+1,p*pi[k]);
        dfs(a,b,k+1,p*(1-pi[k]));
    }
}
int main()
{
    int ca=1;
    while(scanf("%lf%lf%lf%lf%lf%lf%lf%lf%lf%lf",&pi[0],&pi[2],&pi[4],&pi[6],&pi[8],&pi[1],&pi[3],&pi[5],&pi[7],&pi[9])!=EOF)
    {

        scanf("%d-%d",&x,&y);
   //     printf("x=%d,y=%d\n",x,y);
        ans=0;
        dfs(0,0,0,1.0);
        printf("Case %d: %.2f%%\n",ca++,ans*100.0);
    }
    return 0;
}
/*
0.4 0.7 0.7 0.6 0.5 0.8 0.9 0.7 0.2 0.8
1-3
1.0 1.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 1.0
2-0
1.0 1.0 0.0 0.0 0.0 0.0 0.0 0.0 1.0 0.0
2-0
0.4 0.7 0.7 0.6 0.5 0.8 0.9 0.7 0.2 0.8
5-5
0.4 0.7 0.7 0.6 0.5 0.8 0.9 0.7 0.2 0.8
4-2
*/
时间: 2024-10-29 21:04:43

Kick the ball!(dfs)湖南省赛第十届的相关文章

CSU 1505 酷酷的单词 湖南省赛第十届题目

题目链接:http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1505 题意:技巧题,就是一行字符串中,每个字母出现的次数互不相同,复即为酷的单词. 解题思路:看看题意,再结合案例,就能明白了只需要对字符串中的每个字符进行统计个数就行. AC代码: #include <iostream> #include <cstdio> #include <cstdlib> #include <cstring> using n

湖南省第十届大学生计算机程序设计竞赛:酷酷的单词

1505: 酷酷的单词 Time Limit: 1 Sec Memory Limit: 128 MB Submit: 237 Solved: 88 [Submit][Status][Web Board] Description 输入一些仅由小写字母组成的单词.你的任务是统计有多少个单词是"酷"的,即每种字母出现的次数都不同. 比如ada是酷的,因为a出现2次,d出现1次,而1和2不同.再比如,banana也是酷的,因为a出现3次,n出现2次,b出现1次.但是,bbacccd不是酷的,因

Contest1657 - 2019年我能变强组队训练赛第十四场

Contest1657 - 2019年我能变强组队训练赛第十四场 Similarity of Subtrees #include <bits/stdc++.h> using namespace std; typedef unsigned long long ull; typedef long long ll; const int maxn=100100; ull ha[maxn]; vector<int>E[maxn]; unordered_map<ull,int>m;

2016湖南省赛 I Tree Intersection(线段树合并,树链剖分)

2016湖南省赛 I Tree Intersection(线段树合并,树链剖分) 传送门:https://ac.nowcoder.com/acm/contest/1112/I 题意: 给你一个n个结点的树,树上每个节点有自己的颜色 问你删除第i条边后形成的两颗子树有多少个相同的颜色 题解: 树链剖分写法: 对于每一种颜色来说,如果这个颜色是在单独的一颗子树中,那么就不会对其他的边产生贡献,所以我们单独对每一种颜色对边的贡献讨论,如果这个颜色只有一个,那么就不会产生贡献,否则,他就可以在两个相同颜

2016湖南省赛----A 2016 (同余定理)

2016湖南省赛----A 2016 (同余定理) Description 给出正整数 n 和 m,统计满足以下条件的正整数对 (a,b) 的数量: 1. 1≤a≤n,1≤b≤m; 2. a×b 是 2016 的倍数. Input 输入包含不超过 30 组数据. 每组数据包含两个整数 n,m (1≤n,m≤10 9). Output 对于每组数据,输出一个整数表示满足条件的数量. Sample Input 32 63 2016 2016 1000000000 1000000000 Sample

(三角剖分)三角形和矩形的面积交 2016湖南省赛

1 // (三角剖分)三角形和矩形的面积交 2016湖南省赛 2 3 #include <iostream> 4 #include <cstdio> 5 #include <cstring> 6 #include <stack> 7 #include <queue> 8 #include <cmath> 9 #include <algorithm> 10 using namespace std; 11 12 const i

11年湖南省赛 B counting game

比赛的时候这道题卡了大半时间,虽然说其他题目也挺多不会的.昨天一直觉得自己代码是没问题的,今早起来想想,可能是题意读错了,特意去看了一遍中文题意,恍然大悟. 第一:题意为只要  “含7的,或是7的倍数” 就拍手,比赛时被看成了尾数是7就拍手. 第二:今早交一次又WA了,原因是判断每位数是不是7的地方出了问题. 本人原码:   if(num % 7 == 0 || num % 10 == 7 || num / 10 == 7 || num / 100 == 7 || num / 1000 == 7

2018冬令营模拟测试赛(十九)

2018冬令营模拟测试赛(十九) [Problem A]小Y 试题描述 输入 见"试题描述" 输出 见"试题描述" 输入示例 见"试题描述" 输出示例 见"试题描述" 数据规模及约定 见"试题描述" 题解 目前未知. 这题目前就能做到 \(O(n \sqrt{M} \log n)\),其中 \(M\) 是逆序对数,然而会被卡 \(T\):当然这题暴力可以拿到和左边那个算法一样的分数,只要暴力加一个剪枝:当左

【杂题总汇】HDU多校赛第十场 Videos

[HDU2018多校赛第十场]Videos 最后一场比赛也结束了-- +HDU传送门+ ◇ 题目 <简要翻译> 有n个人以及m部电影,每个人都有一个快乐值.每场电影都有它的开始.结束时间和看了这部电影会得到的快乐值.电影分成两种类型,若同一个人连续(不是时间连续,是顺序连续)看了两部相同类型的电影,他的快乐值会扣除W,数据保证扣除的值不超过电影增加的快乐值. 特别的,一个人换电影不花费时间,即若第一部电影的结束时间等于下一部电影的开始时间,是可以两场都看的:看电影必须看完:一部电影只能一个人看