ZOJ 3879 Capture the Flag(模拟)
来源:互联网 发布:智慧养羊软件 编辑:程序博客网 时间:2024/06/05 06:30
思路:恶心模拟...照着题目怎么说就怎么做就好了
#include<bits/stdc++.h>using namespace std;const int maxn = 100000;#define exp 1e-5struct Node{int id,rank;double score;}nodes[105];int vis[105][105][105];int visit[105];bool cmp1(Node a,Node b){return a.score > b.score;}bool cmp2(Node a,Node b){return a.id<b.id;}int T;int main(){ scanf("%d",&T);while (T--){//memset(vis,0,sizeof(vis));int n,q,p,c;scanf("%d%d%d%d",&n,&q,&p,&c);for (int i = 0;i<=n;i++){nodes[i].id=i;nodes[i].rank=1;nodes[i].score = p;}while (c--){int k;scanf("%d",&k);memset(vis,0,sizeof(vis));while (k--){int a,b,c;scanf("%d%d%d",&a,&b,&c);if (vis[a][b][c])continue; vis[a][b][c]=1;}for (int i = 1;i<=q;i++){for (int j = 1;j<=n;j++){int cnt = 0;for (int k = 1;k<=n;k++){if (vis[k][j][i])cnt++;}if (!cnt)continue;double sscore = 1.0*(n-1)/cnt;nodes[j].score-=(n-1);for (int k = 1;k<=n;k++){if (vis[k][j][i])nodes[k].score+=sscore;}}}for (int i = 1;i<=q;i++){memset(visit,0,sizeof(visit));int cnt = 0;for (int j = 1;j<=n;j++){int x;scanf("%d",&x);if (x){visit[j]=1;cnt++;}else{visit[j]=0;nodes[j].score-=(n-1);}}if (cnt==n)continue;double sscore = 1.0*(n-1)/cnt;sscore = sscore * (n-cnt);for (int j = 1;j<=n;j++){if (visit[j]) nodes[j].score+=sscore;}} sort(nodes+1,nodes+n+1,cmp1); for (int i = 1;i<=n;i++) { if(i!=1) { if(fabs(nodes[i].score-nodes[i-1].score)<exp) nodes[i].rank = nodes[i-1].rank; else nodes[i].rank = i; } else nodes[i].rank = i; }sort(nodes+1,nodes+n+1,cmp2);int kk;scanf("%d",&kk);while (kk--){int x;scanf("%d",&x);printf("%f %d\n",nodes[x].score,nodes[x].rank);}}}}
0 0
- ZOJ 3879 Capture the Flag(模拟)
- 【模拟】 ZOJ 3879 Capture the Flag
- zoj 3879 Capture the Flag(长模拟)
- zoj 3879 Capture the Flag(模拟 数学)
- ZOJ 3879 Capture the Flag
- ZOJ-3879-Capture the Flag【模拟】【12th浙江省赛】
- ZOJ 2879 Capture the Flag (模拟题)
- ZOJ - 3879 Capture the Flag (模拟)题意难懂的水题
- ZOJ 3879 — Capture the Flag
- zoj Capture the Flag 比较难的模拟题
- ZOJ 3879 Capture the Flag (浙江省省赛K题+模拟)
- CTF入门指南1(Capture the flag)
- ZOJ3879:Capture the Flag(浙江省赛2015)
- Capture the Flag 浙江省赛K题
- The 2007 International Capture The Flag in UCSB
- 第十二届浙江省大学生程序设计大赛-Capture the Flag
- ZOJ-#3465 The Hive(字符串模拟)
- zoj Defuse the Bomb (模拟)
- 在微信中WeixinJSBridge call invoke closeWindow无效的问题
- 使用GitHub Desktop导致project file cannot be parsed
- hdu2089 简单dp
- 日常Java积累()
- 结构体中常见的冒号的用法是表示位域。
- ZOJ 3879 Capture the Flag(模拟)
- 解决Ubuntu 14.04的enable wifi问题(ASUS F552CL)
- css 盒子水平居中(确定宽度和不确定宽度)
- android---不打开图片获取图片宽高
- Windows 10 操作系统启用旧版本的 Windows照片查看器
- Linux程序移植到Android
- LeetCode *** 89. Gray Code
- 会话状态Session
- 网络:hmac 与服务器时间