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

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. 原型扩展的方法解决IE和Firefox的Js兼容问题

    if(!document.all){//textContent->text    Element.prototype.__defineGetter__('text',function(){ret ...

  2. ActionBarSherlock学习笔记 第一篇——部署

    ActionBarSherlock学习笔记 第一篇--部署          ActionBarSherlock是JakeWharton编写的一个开源框架,使用这个框架,可以实现在所有的Android ...

  3. 将MFC Grid control封装为DLL的做法及其在DLL中的使用方法

    MFCGrid control是一款非常优秀的网格控件,支持非常丰富的界面元素,如下图: 因而在数据库程序及报表程序应用较为广泛,其源码可以在下面下载到: MFC Grid control2.27源码 ...

  4. C++模板:读入优化

    int scan(int &x){ while(c=getchar(),c<'0'||c>'9');x=c-'0'; while(c=getchar(),c>='0'& ...

  5. CodeForces 448

    A:Rewards: 题目链接:http://codeforces.com/problemset/problem/448/A 题意:Bizon有a1个一等奖奖杯,a2个二等奖奖杯,a3个三等奖奖杯,b ...

  6. epoll相关

    1) 能不能给一个使用epoll相关API进行IO监控的示例?在<<epoll学习笔记>>中有一个简单的示例说明epoll相关API的使用, 但是这个示例是非常简单的, 它仅仅 ...

  7. 【SqlServer数据类型、C#数据类型、SqlDbType】对应关系及转换

    // sql server数据类型(如:varchar)// 转换为SqlDbType类型public static SqlDbType SqlTypeString2SqlType(string sq ...

  8. js 字符串为空

    content.replace(/(^\s)|(\s$)/g, "")

  9. asp.net mvc ,asp.net mvc api 中使用全局过滤器进行异常捕获记录

    MVC下的全局异常过滤器注册方式如下:标红为asp.net mvc ,asp.net mvc api  注册全局异常过滤器的不同之处 using SuperManCore; using System. ...

  10. html(第一天,div+css)

    一.CSS布局属性 Width:设置对象的宽度(width:45px). Height:设置对象的高度(Height:45px;). Background:设置对象的背景颜色.背景图像. 1.背景颜色 ...