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 简单的枚举
暴力求解法---简单枚举 定义一个函数(函数的内容大概是包含了题目所给的限制条件),然后主函数就是通过循环进行枚举,枚举出可能的元素,带入函数中进行验证,如果符合函数所给的情况,则为其解.
随机推荐
- Java-二叉树-插入、删除、遍历
二叉树的具体特性和细节知识点,自行百度,直接上代码. 节点:节点内容.左子孩子.右子孩子.父亲 class Node { private int data; private Node leftChil ...
- 视频流传输协议RTP/RTCP/RTSP/HTTP的区别 (转)
用一句简单的话总结:RTSP发起/终结流媒体.RTP传输流媒体数据 .RTCP对RTP进行控制,同步.之所以以前对这几个有点分不清,是因为CTC标准里没有对RTCP进行要求,因此在标准RTSP的代码中 ...
- Linux内存管理【转】
转自:http://www.cnblogs.com/wuchanming/p/4360264.html 转载:http://www.kerneltravel.net/journal/v/mem.htm ...
- fork()函数的执行过程、孤儿进程和僵尸进程
说起fork就不得不提COW(Copy On Write),就是“写时拷贝”.也就是当fork发生时,子进程根本不会去拷贝父进程的内存页面,而是与父进程共享.当子进程或父进程需要修改一个内存页面时,L ...
- react-dnd 拖拽
介绍 React DnD 是一组 React 高阶组件,可以用来帮你构建复杂的拖拽接口,同时解耦你的组件.React DnD 非常适合像 Trello 和 Storify 这样的应用,在不同地方通过拖 ...
- 微信公众号手机端PC端多客服系统
最近很多客户反应没有专门的客服坐在电脑面前,接收回复客户的问题:不能及时回复客户 咨询的问题,现在我们已经为此帮您解决烦恼!! 支持PC与手机端接收微信客户咨询与回复客户,让您随时随地及时回复客户咨询 ...
- Javascript实现页面滚动时导航智能定位
遇到的问题: 在做官网的时候,需要滚动定位的区块的图片不确定,无法确定用户浏览区域对应的模块导航 之前的解决方案是: 通过定位滚动条的位置来判断用户浏览区域对应的模块导航,这种方法的弊端是,区块的高度 ...
- vs-react-插件
- Codeforces Gym101606 A.Alien Sunset (2017 United Kingdom and Ireland Programming Contest (UKIEPC 2017))
2017 United Kingdom and Ireland Programming Contest (UKIEPC 2017) 寒假第一次组队训练赛,和学长一起训练,题目难度是3颗星,我和猪队友写 ...
- chartcontrol(统计坐标图形控件)
统计图形 把控件拖放到界面会弹出下图 图形共分八系列:Bar Series,Point and line Series,pie Series,Funnel Series,Area Series,Ra ...