题目链接:Save the Students!

#include<stdio.h>
#include<string.h>
#include<iostream>
#include<math.h>
using namespace std; bool vis[][]; // 所有数据保证在1到50.那么坐标在-50到100之间。所以。哈希到50到200之间。开始开的200*200的。WA。 double dis(double x1, double y1, double x2, double y2) // 两点间距离。
{
// cout << x1 << "==" << y1 << "==" << x2<< "==" << y2 << "==" << endl;
double xx = (x2-x1)*(x2-x1);
double yy = (y2-y1)*(y2-y1);
double ans = xx+yy+0.0;
return ans;
} int circle(int a, int b, int r) //是否在圆内。
{
int cnt = ;
for (int i=a-r; i<=a+r; ++i)
{
for (int j=b-r; j<=b+r; ++j)
{
if (!vis[i+][j+])
{
if (dis(i, j, a, b) <= r*r)
{
cnt++;
vis[i+][j+] = ;
}
}
}
}
return cnt;
} double area(int x1, int y1, int x2, int y2, int x3, int y3) // 三角形面积。
{
double temp = (x2-x1)*(y3-y1) - (x3-x1)*(y2-y1);
temp /= 2.0;
if (temp < ) temp = -temp;
return temp;
} int triangle(int x1, int y1, int x2, int y2, int x3, int y3) //是否在三角形内。
{
int cnt = ;
int minx = min(x1, min(x2, x3));
int maxx = max(x1, max(x2, x3));
int miny = min(y1, min(y2, y3));
int maxy = max(y1, max(y2, y3)); for (int i=minx; i<=maxx; ++i)
{
for (int j=miny; j<=maxy; ++j)
{
if (!vis[i+][j+])
{
double s1 = area(i, j, x1, y1, x2, y2);
double s2 = area(i, j, x1, y1, x3, y3);
double s3 = area(i, j, x2, y2, x3, y3);
double s = area(x1, y1, x2, y2, x3, y3);
if (s1 + s2 + s3 == s)
{
cnt++;
vis[i+][j+] = ;
}
}
}
}
return cnt;
} int square(int x1, int y1, int l) //正方形直接判断是不是已经被覆盖了。就可以。开始用了一个巨蠢的用距离判断点是不是在正方形内。。呵呵。。。。
{
int cnt = ;
for (int i=x1; i<=x1+l; ++i)
{
for (int j=y1; j<=y1+l; ++j)
{
if (!vis[i+][j+])
{
cnt++;
vis[i+][j+] = ;
}
}
}
return cnt;
} int main()
{
int t, n;
int x1, x2, x3, x4, x5, x6;
scanf("%d", &t);
while(t--)
{
scanf("%d", &n);
memset(vis, , sizeof(vis));
int ans = ;
for (int i=; i<n; ++i)
{
char temp;
getchar();
scanf("%c", &temp);
if (temp == 'C')
{
scanf("%d%d%d", &x1, &x2, &x3);
ans += circle(x1, x2, x3);
}
else if (temp == 'S')
{
scanf("%d%d%d", &x1, &x2, &x3);
ans += square(x1, x2, x3);
}
else if (temp == 'T')
{
scanf("%d%d%d%d%d%d", &x1, &x2, &x3, &x4, &x5, &x6);
ans += triangle(x1, x2, x3, x4, x5, x6);
}
}
printf("%d\n", ans);
}
return ;
}

UVALive 5984的更多相关文章

  1. UVALive - 4108 SKYLINE[线段树]

    UVALive - 4108 SKYLINE Time Limit: 3000MS     64bit IO Format: %lld & %llu Submit Status uDebug ...

  2. UVALive - 3942 Remember the Word[树状数组]

    UVALive - 3942 Remember the Word A potentiometer, or potmeter for short, is an electronic device wit ...

  3. UVALive - 3942 Remember the Word[Trie DP]

    UVALive - 3942 Remember the Word Neal is very curious about combinatorial problems, and now here com ...

  4. 思维 UVALive 3708 Graveyard

    题目传送门 /* 题意:本来有n个雕塑,等间距的分布在圆周上,现在多了m个雕塑,问一共要移动多少距离: 思维题:认为一个雕塑不动,视为坐标0,其他点向最近的点移动,四舍五入判断,比例最后乘会10000 ...

  5. UVALive 6145 Version Controlled IDE(可持久化treap、rope)

    题目链接:https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&page=show_ ...

  6. UVALive 6508 Permutation Graphs

    Permutation Graphs Time Limit:3000MS     Memory Limit:0KB     64bit IO Format:%lld & %llu Submit ...

  7. UVALive 6500 Boxes

    Boxes Time Limit:3000MS     Memory Limit:0KB     64bit IO Format:%lld & %llu Submit Status Pract ...

  8. UVALive 6948 Jokewithpermutation dfs

    题目链接:UVALive 6948  Jokewithpermutation 题意:给一串数字序列,没有空格,拆成从1到N的连续数列. dfs. 可以计算出N的值,也可以直接检验当前数组是否合法. # ...

  9. 【暑假】[实用数据结构]UVAlive 3135 Argus

    UVAlive 3135 Argus Argus Time Limit: 3000MS   Memory Limit: Unknown   64bit IO Format: %lld & %l ...

随机推荐

  1. C++ Compress Floder

    第三方函数.头文件.测试工程下载地址:http://download.csdn.net/detail/u012958937/8361733

  2. Python3基础 file for+文件指针 读取txt文本并 一行一行的输出(高效率)

             Python : 3.7.0          OS : Ubuntu 18.04.1 LTS         IDE : PyCharm 2018.2.4       Conda ...

  3. 三点估算和PERT技术

    三点估算是PMP考试中的必考题目,每次约2-4道题目.现在就三点估算和PERT技术做详细讲解,以飨读者. 通过考虑估算中的不确定性和风险,可以提高活动持续时间估算的准确性.这个概念起源于计划评审技术( ...

  4. POJ 3694 Network(并查集缩点 + 朴素的LCA + 无向图求桥)题解

    题意:给你一个无向图,有q次操作,每次连接两个点,问你每次操作后有几个桥 思路:我们先用tarjan求出所有的桥,同时我们可以用并查集缩点,fa表示缩点后的编号,还要记录每个节点父节点pre.我们知道 ...

  5. Centos用yum方式安装nodejs和npm

    要通过 yum 来安装 nodejs 和 npm 需要先给 yum 添加 epel 源 ##添加 epel 源 rpm -ivh http://download.fedoraproject.org/p ...

  6. BZOJ4415: [Shoi2013]发牌 树状数组+二分

    Description 假设一开始,荷官拿出了一副新牌,这副牌有N张不同的牌,编号依次为1到N.由于是新牌,所以牌是按照顺序排好的,从牌库顶开始,依次为1, 2,……直到N,N号牌在牌库底.为了发完所 ...

  7. C语言通过枚举网卡,API接口可查看man 7 netdevice--获取接口IP地址

    /*代码来自StackOverflow: http://stackoverflow.com/questions/212528/linux-c-get-the-ip-address-of-local-c ...

  8. C++课程上 有关“指针” 的小结

    上完了C++的第二节课以后,觉得应该对这个内容进行一个小结,巩固知识点,并对我的心情进行了一个侧面烘托... 开始上课的老师: 正在上课的我: 上去敲代码的我: 过程是这样的: 下来的我: 非常的尴尬 ...

  9. 圆点博士 陀螺仪和加速度计MPU6050的单位换算方法

    圆点博士陀螺仪和加速度计MPU6050的单位换算方法 陀螺仪和加速度计MPU6050的单位换算方法 对于四轴的初学者,可能无法理解四轴源代码里面陀螺仪和加速度数据的那些数学转换方法.下面我们来具体描述 ...

  10. 如何获取xml循环体报文内容

    Xml报文格式如下所示:   <body> <FILENAME></FILENAME> <records>20</records> < ...