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 called MCTF held by Marjar University is coming, and there are N teams which participate in the competition. In the beginning, each team has S points 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:
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!
There are multiple test cases. The first line of input contains an integer T indicating the number of test cases. For each test case:
The first line contains four integers N (2 <= N <= 100) - the number of teams, Q - the number of services (1 <= Q <= 10), S - the initial points (0 <= S <= 100000) and C - the number of checkpoints (1 <= C <= 100).
For each checkpoint, there are several parts:
[The No. of the attacker] [The No. of the defender] [The No. of the service]For example, "1 2 3" means the 1st team attacks the 2nd team 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.
For each query L, output the score and the ranking of the Lth team. The relative error or absolute error of the score should be less than 10⑸. 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⑸.
For C++ users, kindly use scanf to avoid TLE for huge inputs.
鏈接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=5527
題意:
n個隊伍,q臺服務器,s為初始分數,5次操作
每次操作中有A次攻擊
每次攻擊 a b ser,表示 a隊攻擊 b隊,通過服務器ser。疏忽重復出現 一樣的 a b ser。
攻擊完后,計算分數要把每臺服務器上的攻擊分開計算。被攻擊的隊伍-(n⑴)分,把這n⑴分 平分給攻擊他的隊伍。
然后是q行n列
表示 每臺服務器上,n支隊伍有無 保護好 各自領域。 把沒保護好的 隊伍扣n⑴分,把扣的總分平分給 保護好的隊伍。
然后1個U,詢問U個隊伍的 分數和排名,然后輸出。 排序的時候注意精度, 如 0.123451和0.123452 實際上不相等,但是精度為1e⑸時,算是相等的