ZOJ 3879 Capture the Flag 15年浙江省赛K题
每年省赛必有的一道模拟题,描述都是非常的长,题目都是蛮好写的...
sigh... 比赛的时候没有写出这道题目 :(
题意:首先输入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支队伍的分数
//#pragma comment(linker, "/STACK:16777216") //for c++ Compiler
#include <stdio.h>
#include <iostream>
#include <fstream>
#include <cstring>
#include <cmath>
#include <stack>
#include <string>
#include <map>
#include <set>
#include <list>
#include <queue>
#include <vector>
#include <algorithm>
#define Max(a,b) (((a) > (b)) ? (a) : (b))
#define Min(a,b) (((a) < (b)) ? (a) : (b))
#define Abs(x) (((x) > 0) ? (x) : (-(x)))
#define MOD 1000000007
#define pi acos(-1.0) using namespace std; typedef long long ll ;
typedef unsigned long long ull ;
typedef unsigned int uint ;
typedef unsigned char uchar ; template<class T> inline void checkmin(T &a,T b){if(a>b) a=b;}
template<class T> inline void checkmax(T &a,T b){if(a<b) a=b;} const double eps = 1e- ;
const int N = ;
const int M = * ;
const ll P = 10000000097ll ;
const int MAXN = ; struct node {
int id, rank;
double score;
} a[]; int n, q, c, t;
double p;
bool vis[][][], hsh[]; int cmp1 (node a,node b) {
return a.score > b.score;
} int cmp2 (node a,node b) {
return a.id < b.id;
} int main () {
int i, j, k;
scanf ("%d",&t);
while (t--) {
scanf ("%d%d%lf%d", &n, &q, &p, &c);
for (i = ; i <= n; ++i) {
a[i].id = i;
a[i].rank = ;
a[i].score = p;
}
while (c--) {
scanf("%d",&k);
memset (vis, , sizeof (vis));
while(k--) {
int atk, def, sev;
scanf("%d%d%d", &atk, &def, &sev);
if (vis[atk][def][sev]) continue;
vis[atk][def][sev] = true;
}
for (i = ; i <= q; ++i) {
for (j = ; j <= n; ++j) { //防守方
int cnt = ;
for (k = ; k <= n; ++k) { //攻击方
if (vis[k][j][i]) //统计攻击j的队伍有几支
++cnt;
}
if (!cnt) continue;
double ss = 1.0 * (n - ) / cnt;//平分
a[j].score -= (n - ); //防守方失去n-1
for (k = ; k <= n; ++k) {
if (vis[k][j][i]) //攻击方得到分数
a[k].score += ss;
}
}
} for (i = ; i <= q; ++i) { //服务器
memset (hsh, , sizeof (hsh));
int cnt = ;
for (j = ; j <= n; ++j) {
int x;
scanf ("%d",&x);
if (x) { //成功维护的队伍数
hsh[j] = true;
++cnt;
} else {
hsh[j] = false;
a[j].score -= (n - );
}
}
if(cnt == n) continue;
double ss = 1.0 * (n - ) / cnt;
ss = ss * (n - cnt);
for (j = ; j <= n; ++j) {
if (hsh[j]) {
a[j].score += ss;
}
}
}
sort (a + , a + n + , cmp1);
for (i = ; i <= n; ++i) { //更新排名
if (i != ) {
if (fabs(a[i].score - a[i - ].score) < 1e-)
a[i].rank = a[i - ].rank;
else
a[i].rank = i;
} else {
a[i].rank = i;
}
}
sort (a + , a + n + , cmp2);
scanf ("%d", &k);
while (k--) {
int x;
scanf ("%d",&x);
printf ("%.5f %d\n",a[x].score, a[x].rank);
}
}
} return ;
}
ZOJ 3879 Capture the Flag 15年浙江省赛K题的更多相关文章
- ZOJ 3879 Capture the Flag
以此题纪念我写的第一篇acm博客,第一道模拟:) http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3879 题意非常复杂,感觉 ...
- ZOJ 3872 Beauty of Array DP 15年浙江省赛D题
也是一道比赛时候没有写出来的题目,队友想到了解法不过最后匆匆忙忙没有 A 掉 What a pity... 题意:定义Beauty数是一个序列里所有不相同的数的和,求一个序列所有字序列的Beauty和 ...
- ZOJ 3937 More Health Points (2016 浙江省赛 B题,可持久维护凸壳)
题目链接 2016 ZJCPC Problem B 题意 CF 660F的树上版本. 其他做的方法都差不多,关键是把凸壳放到树上. 每次确定扔掉几个元素的时候直接$O(1)$修改(先不清楚这个位置 ...
- ZOJ 3940 Modulo Query (2016年浙江省赛E题,区间折叠 + map运用)
题目链接 2016 ZJCPC Problem E 考虑一个开区间$[0, x)$对$a_{i}$取模的过程. $[0, x)$中小于$a_{i}$的部分不变,大于等于$a_{i}$的部分被切下来变 ...
- ACM学习历程——ZOJ 3829 Known Notation (2014牡丹江区域赛K题)(策略,栈)
Description Do you know reverse Polish notation (RPN)? It is a known notation in the area of mathema ...
- ZOJ 3781 - Paint the Grid Reloaded - [DFS连通块缩点建图+BFS求深度][第11届浙江省赛F题]
题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3781 Time Limit: 2 Seconds Me ...
- ZOJ 3780 - Paint the Grid Again - [模拟][第11届浙江省赛E题]
题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3780 Time Limit: 2 Seconds Me ...
- ZOJ 3777 - Problem Arrangement - [状压DP][第11届浙江省赛B题]
题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3777 Time Limit: 2 Seconds Me ...
- 第15届浙江省赛 E LIS
LIS Time Limit: 1 Second Memory Limit: 65536 KB Special Judge DreamGrid is learning the LI ...
随机推荐
- yii教程
http://www.yiichina.com/doc 官网是很好的参考文档
- bzoj 1295: [SCOI2009]最长距离
题目链接 1295: [SCOI2009]最长距离 Time Limit: 10 Sec Memory Limit: 162 MBSubmit: 1165 Solved: 619[Submit][ ...
- Apache proxy中转设置
参考http://sjsky.iteye.com/blog/1067119 打开http.conf (macOS中 Apache配置文件在/etc/apache2/中 etc是隐藏的) 确保下面 ...
- Qt的目录依赖问题----怎样生成一个绿色的Qt软件包
Qt的目录依赖问题----怎样生成一个绿色的Qt软件包 一.核心问题: 如果将编译好的Qt文件拷贝到任何目录下,作为一个绿色软件库来使用? 二.原理讨论 由于Qt在编译的时候将安装路径硬编码到了库文件 ...
- rsync、ssh备份
Linux系统需求 为了实现这个备份程序,需要准备一个外部驱动器.您可以将备份写到一个外部USB磁盘,但这样做效率不高.因此,我假设您将备份写到位于网络某处的服务器中.这台服务器要为带有SSH和rsy ...
- 字符串模式匹配KMP算法
一篇不错的博客:http://www.cnblogs.com/dolphin0520/archive/2011/08/24/2151846.html KMP字符串模式匹配通俗点说就是一种在一个字符串中 ...
- Request url 各种属性值
網址:http://localhost:1897/News/Press/Content.aspx/123?id=1#toc Request.ApplicationPath / Request.Phys ...
- JavaScript 高级程序设计(第3版)笔记——chapter5:引用类型(基本包装类型部分)
一.介绍 为了方便操作基本类型值,ECMAScript还提供了3个特殊的引用类型:Boolean, Number, String. 实际上,每当读取一个基本类型值得时候,后台就会创建一个对应的基本包装 ...
- [译]Stairway to Integration Services Level 12 - 高级日志配置
介绍 本文中,我们将结合之前学习的时间冒泡,日志记录,以及复制模型.建立一个自定义的SSIS包日志模型. SSIS Task事件回顾 Reviewing SSIS Task Events 在做实 ...
- html 5 新增标签及简介
作为下一代Web技术的代表,HTML5概念在近些年尤其火热.据了解,HTML5受到垂青最直接的原因就是其跨平台性,除此之外,它不仅仅可以用于表示Web内容,还可能将Web带入一个广阔的生态平台. 下面 ...