hdu5258简单枚举
百度之星复赛第一题。不明白这么水的题为何一堆人没过。。。这些人是咋晋级复赛的呢。。。
/*
* Author : ben
*/
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <functional>
#include <numeric>
#include <cctype>
using namespace std;
typedef struct Bang {
int x1, x2;
int y1, y2;
Bang(int xx1 = , int yy1 = , int xx2 = , int yy2 = ) {
x1 = xx1;
x2 = xx2;
y1 = yy1;
y2 = yy2;
}
} Bang;
Bang heng[], shu[];
int N, M, ans;
bool isCross(const Bang &b1, const Bang &b2) {
if (b2.x1 >= b1.x1 && b2.x1 <= b1.x2) {
if (b1.y1 >= b2.y1 && b1.y1 <= b2.y2) {
return true;
}
}
return false;
}
void work() {
for (int i = ; i < N; i++) {
for (int j = i + ; j < N; j++) {
for (int a = ; a < M; a++) {
if (!isCross(heng[i], shu[a]) || !isCross(heng[j], shu[a])) {
continue;
}
for (int b = a + ; b < M; b++) {
if (isCross(heng[i], shu[b]) && isCross(heng[j], shu[b])) {
ans++;
}
}
}
}
}
} int main() {
int T, n;
int x1, x2, y1, y2;
scanf("%d", &T);
for (int t = ; t <= T; t++) {
N = ;
M = ;
ans = ;
scanf("%d", &n);
for (int i = ; i < n; i++) {
scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
if (x1 == x2) {
shu[M++] = Bang(x1, min(y1, y2), x2, max(y1, y2));
} else {
heng[N++] = Bang(min(x1, x2), y1, max(x1, x2), y2);
}
}
work();
printf("Case #%d:\n%d\n", t, ans);
}
return ;
}
hdu5258简单枚举的更多相关文章
- UVA - 10167 - Birthday Cake (简单枚举)
思路:简单枚举 AC代码: #include <cstdio> #include <cstring> #include <iostream> #include &l ...
- Java练习 SDUT-1959_简单枚举类型——植物与颜色
简单枚举类型--植物与颜色 Time Limit: 1000 ms Memory Limit: 65536 KiB Problem Description 请定义具有red, orange, yell ...
- hdu5073 简单枚举+精度处理
其实这题还是挺简单的,因为移动k个星球后,这k个星球的权值就可以变为0,所以只有剩下的本来就是连着的才是最优解,也就是说要动也是动两端的,那么就O(N)枚举一遍动哪些就好了. 我是在杭电oj题目重现的 ...
- zoj 1622 Switch 开关灯 简单枚举
ZOJ Problem Set - 1622 Switch Time Limit: 2 Seconds Memory Limit: 65536 KB There are N lights i ...
- UVa 725 简单枚举+整数转换为字符串
Division Write a program that finds and displays all pairs of 5-digit numbers that between them use ...
- UVA 725 UVA 10976 简单枚举
UVA 725 题意:0~9十个数组成两个5位数(或0开头的四位数),要求两数之商等于输入的数据n.abcde/fghij=n. 思路:暴力枚举,枚举fghij的情况算出abcde判断是否符合题目条件 ...
- uva 10976 Fractions Again(简单枚举)
10976 Fractions Again It is easy to see that for every fraction in the form 1 k (k > 0), we can a ...
- C#枚举的简单使用
枚举这个名词大家都听过,很多小伙伴也使用过, 那么枚举在开发中能做什么,使用它后能给程序代码带来什么改变,为什么用枚举. 各位看官且坐下,听我一一道来. 为什么使用枚举? 1.枚举能够使代码更加清晰, ...
- 做 fzu oj 1003 简单的枚举
暴力求解法---简单枚举 定义一个函数(函数的内容大概是包含了题目所给的限制条件),然后主函数就是通过循环进行枚举,枚举出可能的元素,带入函数中进行验证,如果符合函数所给的情况,则为其解.
随机推荐
- Best Coder Lotus and Characters
Lotus and Characters 问题描述 Lotus有nn种字母,给出每种字母的价值以及每种字母的个数限制,她想构造一个任意长度的串. 定义串的价值为:第1位字母的价值*1+第2位字母的 ...
- Yii CActiveForm 客户端验证(enableClientValidation)和自定义验证
使用Yii的CActiveForm默认使用服务器端模型(model)的rules规则验证数据. 但这会导致无谓的请求提交,比较好的方式是为了用户体验在客户端也验证,而为了安全性,在服务器端和数据库也做 ...
- C#读取Excel 几种方法的体会
(1) OleDb: 用这种方法读取Excel速度还是非常的快的,但这种方式读取数据的时候不太灵活,不过可以在 DataTable 中对数据进行一些删减修改 这种方式将Excel作为一个数据源,直接用 ...
- 域名缓存侦测(DNS Cache Snooping)技术
域名缓存侦测(DNS Cache Snooping)技术 在企业网络中,通常都会配置DNS服务器,为网络内的主机提供域名解析服务.这些DNS不仅解析自己的私有域名,还会用递归方式,请求公网的DNS解析 ...
- 某考试 T2 bomb
轰炸(bomb)[题目描述]有n座城市,城市之间建立了m条有向的地下通道.你需要发起若干轮轰炸,每轮可以轰炸任意多个城市.但每次轰炸的城市中,不能存在两个不同的城市i,j满足可以通过地道从城市i到达城 ...
- 【Navicat preminm】64位的Navicat preminm注册
百度云盘 技术-->Navicat preminm+破解
- linux查看系统CPU,内存,硬盘使用情况
top查看CPU,内存使用情况 free查看硬盘使用情况
- lfu-cache(需要O(1),所以挺难的)
https://leetcode.com/problems/lfu-cache/ 很难,看了下面的参考: https://discuss.leetcode.com/topic/69137/java-o ...
- python 使用cx-freeze打包程序
python环境 3.6.5 win7 linux环境同理 先尝试了PyInstaller ,打包时一直提示 no module named gtk 而gtk 又依赖pygobj ...
- 没有IP地址的主机怎样保持IP层联通
在<两台不同网段的PC直连能否够相互ping通>一文中,我有点像在玩旁门左道,本文中.我继续走火入魔.两台机器,M1和M2,各自有一个网卡eth0,配置例如以下:M1的配置:eth0上不配 ...