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
题意: 给出老虎的起始点.方向和驴的起始点.方向.. 规定老虎和驴都不会走自己走过的方格,并且当没路走的时候,驴会右转,老虎会左转.. 当转了一次还没路走就会停下来.. 问他们有没有可能在某一格相遇. ...
随机推荐
- 迁移11g Rac中OCR和VOTEDISK
环境:OEL+oracle rac 11.2.0.3 迁移描述:将ocr和votedisk从+DATE上迁移到+OCR_VOTE上: 操作如下: [root@ora2 ~]$ /u01/app/11. ...
- 【很变态】PHP类实例化对象竟然可以访问类的“静态(static)方法”!!!
之前发现一个PHP的变态问题:PHP中静态(static)调用非静态方法详解 这次看了下 ThinkPHP 的源码 function.inc.php ,里面有个函数: /** * 取得对象实例 支持调 ...
- OpenShift应用镜像构建(3) - Jenkins的流水线构建
Jenkins方式构建的定位是使用专门的CICD平台. 既支持把JenKins作为一个Pod部署到openshift内部,也支持部署在Openshift集群外部,操作上的区别是 openshift自己 ...
- Boost::Lexical_cast 的使用
.C++代码 #include <boost/lexical_cast.hpp> #include <iostream> int main() { using boost::l ...
- CocoSourcesCS 2
CocoSourcesCS 2 /*------------------------------------------------------------------------- DFA.cs - ...
- Win7双屏显示设置
双显示器:一个是T410自己的屏幕,一个是宏基的Acer1296*768显示器. 连接:将宏基显示器的Display端子连接到笔记本的Display口上,电源接上. 设置过程: 1.右键点屏幕,选“S ...
- Codeforces Beta Round #17 C. Balance (字符串计数 dp)
C. Balance time limit per test 3 seconds memory limit per test 128 megabytes input standard input ou ...
- Web开发常见的几个漏洞解决方法
http://www.cnblogs.com/wuhuacong/archive/2013/04/15/3022011.html 如何利用SQL注入漏洞攻破一个WordPress网站 平时工作,多数是 ...
- win7之64位下安装oracle11g遇到问题和不能删除干净的问题
今天在win7下装了oracle11g 删了又卸 来来回回重启了4.5次,结合网上是解释归纳下几点: 一.win64_11gR2_database_1of2.zip和win64_11gR2_datab ...
- 【Firefly API文档】—— Package DBentrust
http://bbs.gameres.com/thread_219653_1_1.html package dbentrust 该包下面主要是数据库的处理与memcached存储.里面封装了,从mem ...