zoj 3879 Capture the Flag(模拟 数学)

题目链接:?problemCode=3879

In computer security, Capture the Flag (CTF) is a computer security competition. CTF contests are usually designed to serve as an educational exercise to give participants experience in securing a machine, as well as conducting and reacting to the sort of attacks found in the real world. Reverse-engineering, network sniffing, protocol analysis, system administration, programming, and cryptanalysis are all skills which have been required by prior CTF contests at DEF CON. There are two main styles of capture the flag competitions: attack/defense and jeopardy.

In an attack/defense style competition, each team is given a machine (or a small network) to defend on an isolated network. Teams are scored on both their success in defending their assigned machine and on their success in attacking other team’s machines. Depending on the nature of the particular CTF game, teams may either be attempting to take an opponent’s flag from their machine or teams may be attempting to plant their own flag on their opponent’s machine.

Recently, an attack/defense style competition calledMCTFheld by Marjar University is coming, and there areNteams which participate in the competition. In the beginning, each team hasSpoints as initial score; during the competition, there are some checkpoints which will renew scores for all teams. The rules of the competition are as follows:

If a team has been attacked for a serviceP, they will loseN – 1points. The lost points will be split equally and be added to the team(s) which attacks successfully. For example, there are 4 teams and Team A has been attacked by Team B and Team C, so Team A will lose 3 points, while Team B and Team C each will get 1.5 points.If a team cannot maintain their service well, they will loseN – 1points, which will be split equally too and be added to the team(s) which maintains the service well.

The score will be calculated at the checkpoints and then all attacks will be re-calculated. Edward is the organizer of the competition and he needs to write a program to display the scoreboard so the teams can see their scores instantly. But he doesn’t know how to write. Please help him!

Input

There are multiple test cases. The first line of input contains an integerTindicating the number of test cases. For each test case:

The first line contains four integersN(2 <=N<= 100) – the number of teams,Q- the number of services (1 <=Q<= 10),S- the initial points (0 <=S<= 100000) andC- the number of checkpoints (1 <=C<= 100).

For each checkpoint, there are several parts:

The first line contains an integerA- the number of the successful attacks. ThenAlines follow and each line contains a message:[The No. of the attacker] [The No. of the defender] [The No. of the service]For example, "1 2 3" means the 1stteam attacks the 2ndteam in service 3 successfully. The No. of teams and services are indexed from 1. You should notice that duplicate messages are invalid because of the rules. Just ignore them.Then there areQlines and each line containsNintegers. Thejthnumber of theithline indicating thejthteam’s maintaining status of theithservice, where 1 means well and 0 means not well.Finally there is an integerU(0 <=U<= 100), which describing the number of the queries. The following line containsUintegers, which means Edward wants to know the score and the ranking of these teams.Output

For each queryL, output the score and the ranking of theLthteam. The relative error or absolute error of the score should be less than 10-5. The team with higher score gets higher rank; the teams with the same scores should have the same rank. It is guaranteed that the scores of any two teams are either the same or with a difference greater than 10-5.

Sample Input14 2 2500 501 1 1 11 1 1 141 2 3 421 2 13 2 11 1 1 11 1 1 141 2 3 411 2 21 1 1 11 1 1 041 2 3 400 0 0 00 0 0 041 2 3 401 1 1 11 1 1 121 4Sample Output2500.00000000 12500.00000000 12500.00000000 12500.00000000 12501.50000000 12497.00000000 42501.50000000 12500.00000000 32505.50000000 12495.00000000 42502.50000000 22497.00000000 32499.50000000 12489.00000000 42496.50000000 22491.00000000 32499.50000000 12491.00000000 3Hint

For C++ users, kindly usescanfto avoid TLE for huge inputs.

Author:DAI, LongaoSource:The 12th Zhejiang Provincial Collegiate Programming Contest

题意:首先输入4个数,n,q,p,c

代表有n个队伍,q个服务器,每支队伍的初始分数p,还有c次操作

对于每次操作,,首先输入一个k,代表k次攻击

每次攻击有三个数,a,b,c,代表a通过c服务器成功的攻击了b

对于每次成功的攻击,b会失去n-1分,这n-1分会平分给通过同一服务器攻击b的几支队伍

然后是q行,每行n个数,分别代表1~n是否成功维护了,1为成功,0为不成功

不成功的队伍会失去n-1分,这失去的分会平分给成功维护的那些队伍

然后输入k个数,询问这k支队伍的分数

PS:

当判断分数是否相等的时候, 不能直接用“ == ”去判断,这样会有一定的误差,要用作差去判断!

还有exp不能太大也不能太小!

如果心在远方,只需勇敢前行,梦想自会引路,

zoj 3879 Capture the Flag(模拟 数学)

相关文章:

你感兴趣的文章:

标签云: