Tactical Multiple Defense System UVALive
来源:互联网 发布:java课程表管理系统 编辑:程序博客网 时间:2024/06/06 02:07
这个题目是训练赛的一个题目,当时一开始以为是一个几何,仔细读题后,我和队友确定这是一个最大匹配,然后建边,建边的时候一个点确定一个半径,然后判重跑一边匈牙利就行。判重的方法很多,我这个做法有点太暴力~~~直接枚举的。
#include <iostream>#include <vector>#include <cstdio>#include <string>#include <cstring>#include <algorithm>#include <map>using namespace std;const int maxn = 1e5 + 10;vector<int> G[maxn];int from[maxn];int cnt;bool vis[maxn];bool use[maxn];map<double,int> mp;int ans;int n;bool match(int x){ for(int i = 0; i < G[x].size(); i++) { if(!vis[G[x][i]]) { vis[G[x][i]] = true; if(!from[G[x][i]]|| match(from[G[x][i]])) { from[G[x][i]] = x; return true; } } } return false;}int hungary(){ cnt = 0; memset(from,0,sizeof(from)); for(int i = 1000; i <= 6000; i++) { if(use[i]) { memset(vis,0,sizeof(vis)); if(match(i)) ++cnt; } } return cnt;}int main(){ int t; scanf("%d",&t); while(t--) { memset(use,0,sizeof(use)); int ans = 7000; scanf("%d",&n); for(int i = 1000; i <= 6000; i++) G[i].clear(); mp.clear(); for(int i = 0; i < n; i++) { int r,x,y; scanf("%d %d %d",&r,&x,&y); double tmp = y *1.0 / x; int num; if(!mp.count(tmp)) { ans++; num = ans; mp[tmp] = ans; } else { num = mp[tmp]; } G[r].push_back(num); use[r] = true; } int cur = hungary(); printf("%d\n",cur); } return 0;}
阅读全文
1 0
- Tactical Multiple Defense System UVALive
- UVALive 4976 Defense Lines
- UVALive 4310 Minimal Multiple
- uvaLive 2701 Find The Multiple
- UVALive - 2701 Find The Multiple
- Multiple Morse Matches - UVaLive 2426 KMP+dp
- UVALive - 4356 Fire-Control System
- Multi-Stores multiple shop system
- uvaLive 6748 2D-Solar System
- UVALive 6748 2D-Solar System
- UVALive 2426 Multiple Morse Matches(kmp+dp)
- Defense Lines
- WMI Defense
- UvaLive-5713-Qin Shi Huang's National Road System
- UVaLive LA 4356 - Fire-Control System (扫描法 思维)
- UVALive 4839 HDU 3686 Traffic Real Time Query System
- UVALive - 4356 Fire-Control System 三角函数+暴力+剪枝
- UValive 5713 Qin Shi Huang's National Road System
- 简单有序表【C语言程序设计】
- lnmp 之nginx安装
- Companionship of Books
- docker学习笔记之Docker Compose与docker swarm
- mkisofs------制作iso文件
- Tactical Multiple Defense System UVALive
- 55-经典问题分析四
- MAC JAVA 1.8 与 9 版本切换
- 《Unity Shader入门精要》 第二章 学习笔记
- ElasticSearch入门 第二篇:集群配置
- JS继承
- python 中del 的用法
- 日常运维(五):CentOS7 firewalld
- Dice Possibility