题目链接: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. 【转】各种消息下wParam及lParam值的含义

    转载自:http://bbs.fishc.com/forum.php?mod=viewthread&tid=52668#lastpost 01.WM_PAINT消息 LOWORD(lParam ...

  2. python循环和布尔表达式总结

    1.Python的for循环是循环遍历序列的有限循环. 2.Python的while语句是一个不定循环的例子.只要循环条件保持为真,它就继续迭代.使用不定循环时,程序员必须注意,以免不小心写成无限循环 ...

  3. Python3基础 __repr__ 实例对象的名字,可以显示信息

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

  4. 自己写操作系统---bootsector篇

    其实博主本来想在寒假自己写一个OSkernal的,高高兴兴的影印了本<一个操作系统的实现>. 然后又去图书馆借来<30天自制操作系统>和<X86/X64体系探索编程> ...

  5. Zookeeper一致性协议原理Zab

    ZooKeeper为高可用的一致性协调框架,自然的ZooKeeper也有着一致性算法的实现,ZooKeeper使用的是ZAB协议作为数据一致性的算法, ZAB(ZooKeeper Atomic Bro ...

  6. 【安装】Microsoft SQL Server的安装

    数据库版本:2012 系统环境:windows 7 一.安装 依次选择“安装->全新 SQL Server 独立安装或向现有安装添加功能”;点“确定” 选择版本,推荐标准版,这里是直接输入序列号 ...

  7. jquery.cookie.js中$.cookie() 使用方法

    定义:让网站服务器把少量数据储存到客户端的硬盘或内存,从客户端的硬盘读取数据的一种技术: 下载与引入:jquery.cookie.js基于jquery:先引入jquery,再引入:jquery.coo ...

  8. javaweb项目运行时生成的Servers项目作用

    在javaweb项目中,看到有一个Servers的项目,发现每新增一个项目,就会在Servers项目中新生成一些对应的项目文件. 如图所示: 每个项目都有对应的文件.文件的结构图如下: 解释一:Ser ...

  9. makefile 中的符号替换($@、$^、$<、$?)

    Makefile  $@, $^, $< $@  表示目标文件$^  表示所有的依赖文件$<  表示第一个依赖文件$?  表示比目标还要新的依赖文件列表 如一个目录下有如下文件: $ ls ...

  10. .NET Core2.0应用IdentityServer4

    IdentityServer4能解决什么问题 假设我们开发了一套[微博程序],主要拥有两个功能:[登陆验证].[数据获取] 随后我们又开发了[简书程序].[知乎程序],它们的主要功能也是:[登陆验证] ...