将每个格子标记为 x*n*n+y*n+z  每个格子会有一个独特的编号  将它放入vector中  去重  我一开始用 set 超时

#include <cstdio>
#include <cstring>
#include <vector>
#include <set>
#include <algorithm> using namespace std; int main()
{
vector<int> a;
int t,n,m;
scanf("%d",&t);
while(t--)
{
a.clear();
scanf("%d%d%*c",&n,&m);
for(int i = 0; i < m; i++)
{
char c,d;
int u,v;
scanf("%c%*c%d%*c%c%*c%d%*c",&c,&u,&d,&v);
if(c == 'X' && d == 'Y')
for(int i = 1; i <= n; i++)
a.push_back(u*n*n+v*n+i);
else if(c == 'X' && d == 'Z')
for(int i = 1; i <= n; i++)
a.push_back(u*n*n+i*n+v);
else if(c == 'Y' && d == 'X')
for(int i = 1; i <= n; i++)
a.push_back(v*n*n+u*n+i);
else if(c == 'Y' && d == 'Z')
for(int i = 1; i <= n; i++)
a.push_back(i*n*n+u*n+v);
else if(c == 'Z' && d == 'Y')
for(int i = 1; i <= n; i++)
a.push_back(i*n*n+v*n+u);
else if(c == 'Z' && d == 'X')
for(int i = 1; i <= n; i++)
a.push_back(v*n*n+i*n+u);
}
sort(a.begin(), a.end());
int u = unique(a.begin(), a.end())-a.begin();
printf("%d\n",u);
}
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. HDU 3682 To Be an Dream Architect:查重【三维坐标系中点在实数上的映射】

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3682 题意: 有一个n*n*n的立方体,左下角坐标为(1,1,1),接下来进行m次操作. 每个操作形如 ...

  4. HDU 3682 水模拟

    n*n*n的图形,m条线,每条线上的方格被删除.问一共删除了多少个方格 ans=m*n .然后推断一下直线相交的交点.去重就可以 #include "stdio.h" #inclu ...

  5. HDU 5643 King's Game 打表

    King's Game 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5643 Description In order to remember hi ...

  6. HDOJ 2111. Saving HDU 贪心 结构体排序

    Saving HDU Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total ...

  7. 【HDU 3037】Saving Beans Lucas定理模板

    http://acm.hdu.edu.cn/showproblem.php?pid=3037 Lucas定理模板. 现在才写,noip滚粗前兆QAQ #include<cstdio> #i ...

  8. hdu 4859 海岸线 Bestcoder Round 1

    http://acm.hdu.edu.cn/showproblem.php?pid=4859 题目大意: 在一个矩形周围都是海,这个矩形中有陆地,深海和浅海.浅海是可以填成陆地的. 求最多有多少条方格 ...

  9. HDU 4569 Special equations(取模)

    Special equations Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u S ...

随机推荐

  1. android操作通讯录的联系人

    界面配置文件 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"     and ...

  2. Objective-C 【关于导入类(@class 和 #import的区别)】

    之前我们分析过 #include 和 #import 的区别,#import不会引起交叉编译,#import 确定一个文件只能被导入一次,使在递归包含中不会出现问题. 那么 #import 和 @cl ...

  3. css笔记——移动端

    苹果手机 /*按钮样式:*/input[type=button], input[type=submit], input[type=file], button { cursor: pointer; -w ...

  4. 【转载】干货来袭!Linux小白最佳实践:《超容易的Linux系统管理入门书》(连载七)LAMP集成安装

    学Linux做程序开发也好,做系统管理也好,做网络管理员也好,做系统运维也好,不会LAMP和LNMP,那就等于连皮毛都不会!本篇是文字版的LAMP集成安装,下次连载我们要介绍LNMP的文字版安装.有喜 ...

  5. 通过Curator操作Zookeeper的简单例子代码

    Curator主要解决了三类问题: 一个是ZooKeeper client与ZooKeeper server之间的连接处理; 一个是提供了一套Fluent风格的操作API; 一个是ZooKeeper各 ...

  6. Visual Studio通过Web Deploy发布网站报错:An error occurred when the request was processed on the remote computer.

    这个问题很奇怪,不管我怎么重启服务器和自己的开发机,都没有用. 在网上找了很多资料,有说可以尝试去读Windows的错误日志,然后通过日志找原因…(详见Stackoverflow:http://sta ...

  7. Layout.xml中控件的ID命名方式

    控件 缩写 LayoutView lv RelativeView rv TextView tv Button btn ImageButton imgBtn ImageView mgView 或则 iv ...

  8. 印象笔记无法同步问题解决 Unable to send HTTP request: 12029

    问题 今天突然发现本地软件不能访问网络. 包括: 印象笔记无法同步, 搜狗输入法无法登陆. 但其它上网正常. 思路及解决过程 因为chrome上网 ,qq上网均正常. 且同事可以正常使用. 推测是本地 ...

  9. Memcached的安装(Linux)、操作、命令

    最近在整理有关分布式缓存的服务器,做了一下老牌nosql服务器memcached的学习总结.文中所述的所有安装均是在联网的情况下进行的. 序: 什么是memcached: Free & ope ...

  10. DTCMS插件配置;给所有会员发信息

    插件配置  :http://www.dtcms.net/help/10.aspx 给所有人发信息 a)     将收件人设置为0即发送给所有人 b)     Templates\main\userme ...