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

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. fitnesse 中各类fit fixture的python实现

    虽然网上都说slim效率很高,无奈找不到支持python的方法,继续用pyfit 1 Column Fixture 特点:行表格展现形式,一条测试用例对应一行数据 Wiki !define COMMA ...

  2. 通过读取excel数据和mysql数据库数据做对比(二)-代码编写测试

    通过上一步,环境已搭建好了. 下面开始实战, 首先,编写链接mysql的函数conn_sql.py import pymysql def sql_conn(u,pwd,h,db): conn=pymy ...

  3. c语言(3)--运算符&表达式&语句

    计算机的本职工作是进行一系列的运算,C语言为不同的运算提供了不同的运算符! 1.那些运算符们 .基本运算符 算术运算符:+ - * /  % ++ -- 赋值运算符:= 逗号运算符:, 关系运算符:& ...

  4. Vim键盘布局

     Vim键盘布局 用Linux的朋友一定会使用到Vim这个文本编辑器,它是由Vi发展而来的编辑器,其具有代码补齐.编译.错误跳转等丰富的功能,非常适合编程.对于修改Linux配置文件它更是你不二的选择 ...

  5. java.lang.ClassCastException: oracle.sql.TIMESTAMP cannot be cast to java.sql.Timestamp

    http://stackoverflow.com/questions/13269564/java-lang-classcastexception-oracle-sql-timestamp-cannot ...

  6. swift3.0 hello swift(1)

    一直对swift感兴趣,在前段时间的新闻中,大多是swift3.0发布和xcode8.0的改进,因为改动比较大,以前使用swift2.x做项目的人,都在担心其项目从2.x迁移到3.0+的问题.以前简单 ...

  7. Memory Architecture-SGA-Database Buffer Cache

    启动instance:1.分配内存空间SGA 2.启动后台进程 内存结构:1.SGA 2.PGA 3.UGA 4.Software code areas SGA components:1.Databa ...

  8. poj1077 Eight【爆搜+Hash(脸题-_-b)】

    转载请注明出处,谢谢:http://www.cnblogs.com/KirisameMarisa/p/4298840.html   ---by 墨染之樱花 题目链接:http://poj.org/pr ...

  9. eclipse主题插件

    打开eclipse ,选择 Help 选择Install New Software 点击 Add 输入http://eclipse-color-theme.github.com/update,选中Ec ...

  10. iOS系统原生二维码条形码扫描

    本文讲述如何用系统自带的东东实现二维码扫描的功能:点击当前页面的某个按钮,创建扫描VIEW.细心的小伙伴可以发现 title被改变了,返回按钮被隐藏了.这个代码自己写就行了,与本文关系不大...绿色的 ...