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 水模拟的更多相关文章

  1. 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 ...

  2. 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 ...

  3. CodeForces.158A Next Round (水模拟)

    CodeForces.158A Next Round (水模拟) 题意分析 校赛水题的英文版,坑点就是要求为正数. 代码总览 #include <iostream> #include &l ...

  4. CodeForces.71A Way Too Long Words (水模拟)

    CodeForces71A. Way Too Long Words (水模拟) 题意分析 题怎么说你怎么做 没有坑点 代码总览 #include <iostream> #include & ...

  5. HDU-1042-N!(Java大法好 &amp;&amp; HDU大数水题)

    N! Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others) Total Subm ...

  6. 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 ...

  7. HDU 4121 Xiangqi 模拟题

    Xiangqi Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=4121 ...

  8. hdu 5071 Chat(模拟)

    题目链接:hdu 5071 Chat 题目大意:模拟题. .. 注意最后说bye的时候仅仅要和讲过话的妹子说再见. 解题思路:用一个map记录每一个等级的妹子讲过多少话以及是否有这个等级的妹子.数组A ...

  9. hdu 4740【模拟+深搜】.cpp

    题意: 给出老虎的起始点.方向和驴的起始点.方向.. 规定老虎和驴都不会走自己走过的方格,并且当没路走的时候,驴会右转,老虎会左转.. 当转了一次还没路走就会停下来.. 问他们有没有可能在某一格相遇. ...

随机推荐

  1. (转)探索C++的秘密之详解extern "C",这就是为什么很多.lib被我们正确调用确总是无法解析的。

    (转载,绝对的有用) lib被我们正确调用确总是无法解析.这是C++编译和C编译的区别 时常在cpp的代码之中看到这样的代码: #ifdef __cplusplus extern "C&qu ...

  2. C# 中的.pdb/ .vshost.exe/ .vshost.exe.manifest文件

    转自 C# 中的.pdb/ .vshost.exe/ .vshost.exe.manifest文件讨论 pdb文件: 英文全称:Program Database File 中文全称:程序数据库 文件 ...

  3. Ubuntu下,清屏等终端常用命令

    转自:http://blog.csdn.net/gaojinshan/article/details/9314435 # ctrl + l - 清屏 . cLear# ctrl + c - 终止命令. ...

  4. 靠谱助手 http://www.kpzs.com/

    靠谱助手 http://www.kpzs.com/ 靠谱助手是于2013年5月18日推出的一个专为第三方智能安卓引擎提供管理的免费应用程序,是国内最完美的PC端管理软件. 安卓引擎支持微信.陌陌等日常 ...

  5. weblogic生成和配置SSL证书

    采用Linux自带的OPENSSL进行证书的生成工作 准备阶段 以root登录,同时在el01gbcn01上完成 [oracle@el01gbcn01]# which java /u01/FMW/we ...

  6. libev客户端

    #include <ev.h> #include <stdio.h> #include <netinet/in.h> #include <stdlib.h&g ...

  7. Jupyter Notebook 快捷键

    Jupyter Notebook 快捷键 从命令模式进入编辑模式需按 Enter 键,从编辑模式切换到命令模式需按Esc 键. Jupyter Notebook 是一个交互式笔记本程序, 其有丰富的快 ...

  8. IOS APP 上传到AppStore

    由于第一次接触要把 app 上传到 AppStore 比较棘手,很多地方不懂,研究了 大半天 终于给上传成功了,现在坐等审核吧,首先把上传到AppStore的流程 整理下 : 第一 :准备证书 (要确 ...

  9. 教你如何搭建vue项目

    笔者工作也有一些时间,需要用vue写项目时也总是项目组长已经把项目搭建好了, 偶尔心血来潮想试着自己搭建一个vue项目 我们搭建vue项目呢主要是用到了vue-cli来搭建,但是前提是必须要已经安装好 ...

  10. (转)Akka学习笔记

    Akka学习笔记系列文章: <Akka学习笔记:ACTORS介绍> <Akka学习笔记:Actor消息传递(1)> <Akka学习笔记:Actor消息传递(2)> ...