点我看题目

题意 : 其实我也说不太清楚题意,就是给你很多方块,每放一块方块,都要和前一块有一个面相接,如果不相接,就输出NO,并输出是第几个方块不相接的。如果满足每一个都和前边相接,那就判断所有没有与其他方块相接的面的个数。

思路 : 每输入一个就判断前一个的上下左右前后中距离为1的有没有这个点,如果没有就记录下位置,用于输出NO,如果有的话,就记录下来,然后减去两个面,因为两个方块相接,有两个面要被减去,ans先初始化为6*m,相当于先初始化为所有的面。

#include <stdio.h>
#include <string.h>
#include <iostream>
#include <set>
#include <algorithm> using namespace std ; //int dir[3][6] = {{-1,0,1,0,0,0},{0,-1,0,1,0,0},{0,0,0,0,-1,1}} ;
int dirx[] = {-,,,,,};
int diry[] = {,-,,,,};
int dirz[] = {,,,,-,}; struct node
{
int x,y,z ;
}temp1,temp2;
bool operator <(node a,node b)
{
if(a.x == b.x)
{
if(a.y == b.y)
{
return a.z < b.z ;
}
return a.y < b.y ;
}
return a.x < b.x ;
}
int main()
{
set<node>sett ;
int n ,m,cas = ;
scanf("%d",&n) ;
while(n--)
{
scanf("%d",&m) ;
int ans = m* ;
int flag = - ;
sett.clear() ;
scanf("%d,%d,%d",&temp1.x,&temp1.y,&temp1.z) ;
sett.insert(temp1) ;
for(int i = ; i <= m ; i++)
{
scanf("%d,%d,%d",&temp1.x,&temp1.y,&temp1.z) ;
if(flag == - && sett.find(temp1) != sett.end())
flag = i ;
if(flag == -)
{
int cnt = ;
for(int j = ; j < ; j++)
{
temp2.x = temp1.x+dirx[j] ;
temp2.y = temp1.y+diry[j] ;
temp2.z = temp1.z+dirz[j] ;
if(sett.find(temp2) != sett.end()) cnt++ ;
}
if(cnt) ans -= cnt* ;
else flag = i ;
sett.insert(temp1) ;
}
}
if(flag != -) printf("%d NO %d\n",cas++,flag) ;
else printf("%d %d\n",cas++,ans) ;
}
return ;
}

POJ 3792 Area of Polycubes(思维)的更多相关文章

  1. poj 3792 Area of Polycubes

    http://poj.org/problem?id=3792 #include <cstdio> #include <cstring> #include <cmath&g ...

  2. poj 3792 Area of Polycubes (简单模拟)

    题目 题意:在三维坐标系中,给定n个立方体的中心坐标,立方体的边长为1,按照输入顺序,后来输入的必须和之前输入的立方体有公共的边. 而且,不能和之前输入的立方体相同. 如果满足条件,输出表面积.如果不 ...

  3. poj 1654 Area 多边形面积

    /* poj 1654 Area 多边形面积 题目意思很简单,但是1000000的point开不了 */ #include<stdio.h> #include<math.h> ...

  4. poj 1265 Area 面积+多边形内点数

    Area Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 5861   Accepted: 2612 Description ...

  5. Area of Polycubes

    http://poj.org/problem?id=3792 题意:给出n个小正方体的中心坐标,求构成的多重小立方体的表面积.要求输入的下一个小正方体必须与之前的正方体有一个面是相交的.如果不满足条件 ...

  6. poj 1265 Area (Pick定理+求面积)

    链接:http://poj.org/problem?id=1265 Area Time Limit: 1000MS   Memory Limit: 10000K Total Submissions:  ...

  7. poj 1654 Area (多边形求面积)

    链接:http://poj.org/problem?id=1654 Area Time Limit: 1000MS   Memory Limit: 10000K Total Submissions:  ...

  8. poj 1265 Area( pick 定理 )

    题目:http://poj.org/problem?id=1265 题意:已知机器人行走步数及每一步的坐标   变化量 ,求机器人所走路径围成的多边形的面积.多边形边上和内部的点的数量. 思路:1.以 ...

  9. poj 1654 Area(多边形面积)

    Area Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 17456   Accepted: 4847 Description ...

随机推荐

  1. ArcMap 10.2 crashes during Loading Document launch stage

    问题描述: ArcMap unexpectedly exits during the "Loading Document..." stage on startup. No erro ...

  2. ###《VIM实用技巧》

    ###<VIM实用技巧> #@author: gr #@date: 2015-11-20 #@email: forgerui@gmail.com <VIM实用技巧>阅读笔记. ...

  3. Objective-C访问SQLite

    数据库的相关知识我就不去说明了,毕竟只要会sql语言的人就大家都一样. 本案例是在Xcode7.2环境下创建的single view application进行演示操作. 首先第一点,为什么要使用sq ...

  4. Swift构造器(Initializer)与析构器(Deinitializer)

    为了初始化结构体和类等类型的实例属性. 默认构造器 struct Fahrenheit { var temperature: Doubleinit(){ temperature = 32.0 } } ...

  5. UIView-4-EventForViews(在view上加入button时候的事件处理)

    #import "ViewController.h" @interface ViewController () @end @implementation ViewControlle ...

  6. javascript笔记——date以及datetime的比较

    <script src="$!webPath/resources/js/laydate/laydate.js"></script> <script s ...

  7. Java使用泛型类来提高方法的可重用性

    我的技术博客经常被流氓网站恶意爬取转载.请移步原文:http://www.cnblogs.com/hamhog/p/3832268.html,享受整齐的排版.有效的链接.正确的代码缩进.更好的阅读体验 ...

  8. Linux 下面对物理地址的访问

    参考链接:http://zhuhaibobb.blog.163.com/blog/static/2744006720101049030606/ Linux内核提供了/dev/mem驱动,提供了一种直接 ...

  9. 2013山东省“浪潮杯”省赛 A.Rescue The Princess

    A.Rescue The PrincessDescription Several days ago, a beast caught a beautiful princess and the princ ...

  10. HTTP Error 500.21解决方案

    Windows 7 IIS (HTTP Error 500.21 - Internal Server Error)解决方案   今天在测试网站的时候,在浏览器中输入http://localhost/时 ...