每年省赛必有的一道模拟题,描述都是非常的长,题目都是蛮好写的...

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题的更多相关文章

  1. ZOJ 3879 Capture the Flag

    以此题纪念我写的第一篇acm博客,第一道模拟:) http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3879 题意非常复杂,感觉 ...

  2. ZOJ 3872 Beauty of Array DP 15年浙江省赛D题

    也是一道比赛时候没有写出来的题目,队友想到了解法不过最后匆匆忙忙没有 A 掉 What a pity... 题意:定义Beauty数是一个序列里所有不相同的数的和,求一个序列所有字序列的Beauty和 ...

  3. ZOJ 3937 More Health Points (2016 浙江省赛 B题,可持久维护凸壳)

    题目链接  2016 ZJCPC Problem B 题意  CF 660F的树上版本. 其他做的方法都差不多,关键是把凸壳放到树上. 每次确定扔掉几个元素的时候直接$O(1)$修改(先不清楚这个位置 ...

  4. ZOJ 3940 Modulo Query (2016年浙江省赛E题,区间折叠 + map运用)

    题目链接  2016 ZJCPC Problem E 考虑一个开区间$[0, x)$对$a_{i}$取模的过程. $[0, x)$中小于$a_{i}$的部分不变,大于等于$a_{i}$的部分被切下来变 ...

  5. 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 ...

  6. 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 ...

  7. ZOJ 3780 - Paint the Grid Again - [模拟][第11届浙江省赛E题]

    题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3780 Time Limit: 2 Seconds      Me ...

  8. ZOJ 3777 - Problem Arrangement - [状压DP][第11届浙江省赛B题]

    题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3777 Time Limit: 2 Seconds      Me ...

  9. 第15届浙江省赛 E LIS

    LIS Time Limit: 1 Second      Memory Limit: 65536 KB      Special Judge DreamGrid is learning the LI ...

随机推荐

  1. poj 3243 Clever Y 高次方程

    1 Accepted 8508K 579MS C++ 2237B/** hash的强大,,还是高次方程,不过要求n不一定是素数 **/ #include <iostream> #inclu ...

  2. 11-C语言指针

    目录: 一.指针 二.指针与数组 回到顶部 一.指针 1 内存被分为字节,每个字节有唯一地址,指针保存的是内存中的地址. 2 保存指针的变量,就叫指针变量,(保存地址) 3 声明一个指针变量 int ...

  3. rsync、ssh备份

    Linux系统需求 为了实现这个备份程序,需要准备一个外部驱动器.您可以将备份写到一个外部USB磁盘,但这样做效率不高.因此,我假设您将备份写到位于网络某处的服务器中.这台服务器要为带有SSH和rsy ...

  4. Python中type与Object的区别

    Python中type与Object的区别 在查看了Python的API后,总算明白了.现在总结如下: 先来看object的说明: Python中关于object的说明很少,甚至只有一句话: clas ...

  5. Candy Sharing Game(模拟搜索)

    Candy Sharing Game Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Other ...

  6. 跨域引入iframe 自适应高度

    最近和别的公司合作一个项目,需要从他们那边引入一个页面,刚开始想的挺简单的,用iframe 引入就好啦,可是操作中才发现,自适应的问题不好解决,试了挺多办法,最终找到一个比较好的方法,记录一下,留着备 ...

  7. C# ikvm 运行htmlunit Provider com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl not found

    在使用 ikvm 去运行 htmlunit 中的 webclient Getpage的时候  报错说com.sun.org.apache.xerces.internal.jaxp.DocumentBu ...

  8. Java多线程之synchronized(二)

    为了解决“非线程安全”带来的问题,上一节中使用的办法是用关键字synchronized修饰多个线程可能同时访问到的方法,但是这样写是存在一定的弊端的,比如线程A调用一个用synchronized修饰的 ...

  9. OpenCV 安装

    OpenCV 安装 一.环境说明: 操作系统:window10 opencv版本是:VERSION3.1 二.安装过程: [1]官网下载:http://opencv.org/downloads.htm ...

  10. Linux常用解压文件

    tar.gz    tar -zxvf filename.tar.gz tar.bz2  tar -vxjf filename.tar.bz2