HDU 3682 水模拟
n*n*n的图形,m条线,每条线上的方格被删除。问一共删除了多少个方格
ans=m*n 。然后推断一下直线相交的交点。去重就可以
#include "stdio.h"
#include "string.h"
int xy[1010][1010],xz[1010][1010],yz[1010][1010],hash[1010]; struct node
{
int x,y,z;
} mark[1010];
int main()
{
int Case,n,m,i,j,cnt,a,b,ans,sum;
char ch1,ch2;
scanf("%d",&Case);
while (Case--)
{
scanf("%d%d",&n,&m);
if (m==0)
{
printf("0\n");
continue;
}
memset(xy,0,sizeof(xy));
memset(xz,0,sizeof(xz));
memset(yz,0,sizeof(yz)); cnt=0;
while (m--) // 去重边
{
getchar();
scanf("%c=%d,%c=%d",&ch1,&a,&ch2,&b);
if (ch1=='X' && ch2=='Y' && xy[a][b]==0)
{
mark[cnt].x=a;
mark[cnt].y=b;
mark[cnt++].z=-1;
xy[a][b]=1;
}
if (ch1=='Y' && ch2=='X' && xy[b][a]==0)
{
mark[cnt].x=b;
mark[cnt].y=a;
mark[cnt++].z=-1;
xy[b][a]=1;
}
if (ch1=='X' && ch2=='Z' && xz[a][b]==0)
{
mark[cnt].x=a;
mark[cnt].z=b;
mark[cnt++].y=-1;
xz[a][b]=1;
}
if (ch1=='Z' && ch2=='X' && xz[b][a]==0)
{
mark[cnt].x=b;
mark[cnt].z=a;
mark[cnt++].y=-1;
xz[b][a]=1;
}
if (ch1=='Y' && ch2=='Z' && yz[a][b]==0)
{
mark[cnt].y=a;
mark[cnt].z=b;
mark[cnt++].x=-1;
yz[a][b]=1;
}
if (ch1=='Z' && ch2=='Y' && yz[b][a]==0)
{
mark[cnt].y=b;
mark[cnt].z=a;
mark[cnt++].x=-1;
yz[b][a]=1;
}
} ans=n;
for (i=1; i<cnt; i++) //去重点
{
memset(hash,0,sizeof(hash));
sum=n;
for (j=0; j<i; j++)
{
if (mark[i].x==mark[j].x && mark[i].x!=-1)
{
if (mark[i].y==-1 && mark[j].y!=-1)
{
if (hash[mark[j].y]==0)
sum--;
hash[mark[j].y]=1;
}
if (mark[i].z==-1 && mark[j].z!=-1)
{
if (hash[mark[j].z]==0)
sum--;
hash[mark[j].z]=1;
}
} if (mark[i].y==mark[j].y && mark[i].y!=-1)
{
if (mark[i].x==-1 && mark[j].x!=-1)
{
if (hash[mark[j].x]==0)
sum--;
hash[mark[j].x]=1;
}
if (mark[i].z==-1 && mark[j].z!=-1)
{
if (hash[mark[j].z]==0)
sum--;
hash[mark[j].z]=1;
}
} if (mark[i].z==mark[j].z && mark[i].z!=-1)
{
if (mark[i].x==-1 && mark[j].x!=-1)
{
if (hash[mark[j].x]==0)
sum--;
hash[mark[j].x]=1;
}
if (mark[i].y==-1 && mark[j].y!=-1)
{
if (hash[mark[j].y]==0)
sum--;
hash[mark[j].y]=1;
}
}
} ans+=sum;
}
printf("%d\n",ans);
}
return 0;
}
HDU 3682 水模拟的更多相关文章
- hdu 3682 10 杭州 现场 C - To Be an Dream Architect 简单容斥 难度:1
C - To Be an Dream Architect Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d &a ...
- hdu 3682 10 杭州 现场 C To Be an Dream Architect 容斥 难度:0
C - To Be an Dream Architect Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d &a ...
- CodeForces.158A Next Round (水模拟)
CodeForces.158A Next Round (水模拟) 题意分析 校赛水题的英文版,坑点就是要求为正数. 代码总览 #include <iostream> #include &l ...
- CodeForces.71A Way Too Long Words (水模拟)
CodeForces71A. Way Too Long Words (水模拟) 题意分析 题怎么说你怎么做 没有坑点 代码总览 #include <iostream> #include & ...
- HDU-1042-N!(Java大法好 && HDU大数水题)
N! Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others) Total Subm ...
- Intel Code Challenge Elimination Round (Div.1 + Div.2, combined) A B C D 水 模拟 并查集 优先队列
A. Broken Clock time limit per test 1 second memory limit per test 256 megabytes input standard inpu ...
- HDU 4121 Xiangqi 模拟题
Xiangqi Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=4121 ...
- hdu 5071 Chat(模拟)
题目链接:hdu 5071 Chat 题目大意:模拟题. .. 注意最后说bye的时候仅仅要和讲过话的妹子说再见. 解题思路:用一个map记录每一个等级的妹子讲过多少话以及是否有这个等级的妹子.数组A ...
- hdu 4740【模拟+深搜】.cpp
题意: 给出老虎的起始点.方向和驴的起始点.方向.. 规定老虎和驴都不会走自己走过的方格,并且当没路走的时候,驴会右转,老虎会左转.. 当转了一次还没路走就会停下来.. 问他们有没有可能在某一格相遇. ...
随机推荐
- nginx实现简单负载均衡
配置文件 主文件: /etc/nginx/nginx.config 例当前在22.22.22.4服务器 //同时开另外三个服务器 可以在http{} 里添加 include /etc/nginx/si ...
- word标题编号变成黑块
把光标放置在黑块的后面 在键盘上按左方向键,则黑块变灰色(为选中状态) 然后ctrl+shift+s, 出现窗口“apply styles" 点击"reapply", 搞 ...
- iOS: 工具栏控件UIToolBar和工具栏按钮控件UIBarButtonItem的使用
一.工具栏控件:UIToolBar:UIView 介绍: ToolBar工具栏是视图View的属性,可以在工具栏上添加工具栏按钮Bar Button Item(可以是自定义的Custom.也可以是系统 ...
- oe7升级到oe8中import的使用
oe 7.0到oe 8.0 切换的时候发现我们系统的很多的module 无法load , import的时候出错, 后来发现oe 8.0自己的addons 也都做了修改在import自己的addon ...
- c# string与String区别
[C#] String与string的区别:供参考 转自:https://www.cnblogs.com/rosesmall/p/8351808.html C#是区分大小写的,但是我却发现C#中同时存 ...
- SQL Server-数据库中强varchar类型使用sum函数计算总和
select sum(cast(totalmoney AS DECIMAL)) as totalmoney from dbo.t_wxbill
- pip安装scrapy时报错:error: Unable to find vcvarsall.bat
网上一堆胡说八道的,请看微软官方文章: https://blogs.msdn.microsoft.com/pythonengineering/2016/04/11/unable-to-find-vcv ...
- 【笔记】探索js 的this 对象 (第三部分)
了解完函数的调用区域是如何影响this 对象的,还有this 的各种绑定方式以及各种绑定方式的优先级后 最后一部分,来了解一下this 的一些例外情况 1.被忽略的this 例如在使用bind 方法时 ...
- Echarts 获取后台数据 使用后台数据展示 柱形图
后台数据要以json格式返回 页面:引用echarts.js , 然后data以ajax的数据请求并返回 <%@ page language="java" import=&q ...
- Style对象之一
<html> <style type="text/css"> body{ background-color="#FFCC80"; bac ...