首页 > 其他分享 >hdu-1253

hdu-1253

时间:2023-03-03 13:02:25浏览次数:54  
标签:hdu vis int 55 1253 100 include

http://acm.hdu.edu.cn/showproblem.php?pid=1253


这道水题hdu-1253_ios


#include<stdio.h>    
#include<iostream>    
#include<math.h>    
#include<stdlib.h>    
#include<ctype.h>    
#include<algorithm>    
#include<vector>    
#include<string.h>    
#include<queue>    
#include<stack>    
#include<set>    
#include<map>    
#include<sstream>    
#include<time.h>    
#include<utility>    
#include<malloc.h>    
#include<stdexcept>    

using namespace std;

int k,n,m,t,tt,T;

int mapp[55][55][55];  
int vis[55][55][55];  
int d[55][55][55];  
int xx[6]={0,0,0,0,-1,1};  
int yy[6]={0,0,1,-1,0,0};  
int zz[6]={1,-1,0,0,0,0};  

void bfs()  
{  
  queue<int> q;  
  vis[1][1][1]=1;  
  d[1][1][1]=0;  
  int s=1*10000+100+1;  
  q.push(s);  
  while(!q.empty())  
  {  
      s=q.front();  
      q.pop();  
      int i;  
      int x,y,z;  
      int tz=s%100;  
      s=s/100;  
      int ty=s%100;  
      s=s/100;  
      int tx=s;  
      for(i=0;i<6;i++)  
      {  
          x=tx+xx[i];  
          y=ty+yy[i];  
          z=tz+zz[i];  
          if(vis[x][y][z]==1||mapp[x][y][z]==1||mapp[x][y][z]==-1)  
                continue;  
          vis[x][y][z]=1;  
          d[x][y][z]=d[tx][ty][tz]+1;  
          q.push(x*10000+y*100+z);  
      }  
  }  
}  
int main()  
{  
    int k;  
    scanf("%d",&k);  
    int cas=1;  
    for(cas=1;cas<=k;cas++)  
    {  
        int a,b,c,t;  
        scanf("%d%d%d%d",&a,&b,&c,&t);  
        int i,j,l;  

        memset(mapp,-1,sizeof(mapp));  
        memset(vis,0,sizeof(vis));  
        memset(d,-1,sizeof(d));  

        for(i=1;i<=a;i++)  
            for(j=1;j<=b;j++)  
                for(l=1;l<=c;l++)  
                    scanf("%d",&mapp[i][j][l]);  

        bfs();  

        if(d[a][b][c] <= t && d[a][b][c] != -1)  
            printf("%d\n",d[a][b][c]);  
        else  
            printf("-1\n");  
    }  
    return 0;  
}  



标签:hdu,vis,int,55,1253,100,include
From: https://blog.51cto.com/u_15990681/6098478

相关文章

  • hdu-2821
    http://acm.hdu.edu.cn/showproblem.php?pid=2821不要被题目吓到,认真读题还是好理解的#include<stdio.h>#include<iostream>#include<string.h>#include<math.h......
  • HDU-5112-A Curious Matt (2014ACM/ICPC北京赛区现场赛A题!)
    http://acm.hdu.edu.cn/showproblem.php?pid=5112排序之后计算就好开始用cin超时了#include<stdio.h>#include<iostream>#include<math.h>#include<stdlib.h>#......
  • hdu-5122
    http://acm.hdu.edu.cn/showproblem.php?pid=5122简单题#include<stdio.h>#include<iostream>#include<math.h>#include<stdlib.h>#include<ctype.h>#include......
  • HDUOJ 2041-2055
    2041超级楼梯ProblemDescription有一楼梯共M级,刚开始时你在第一级,若每次只能跨上一级或二级,要走上第M级,共有多少种走法? Input输入数据首先包含一个整数N,表示测试实......
  • Problem C HDU - 5687
    现在有个字典要支持一下操作 1、insert:往神奇字典中插入一个单词  2、delete:在神奇字典中删除所有前缀等于给定字符串的单词  3、search:查询是否在神奇......
  • 统计难题 HDU - 1251
     给一些字符串,问以某个串为前缀的串有几个 #include<iostream>#include<algorithm>#include<cstring>usingnamespacestd;constintN=5e5+4;charnum[80]......
  • Reading comprehension HDU - 4990
    ans=0;   for(i=1;i<=n;i++)    {     if(i&1)ans=(ans*2+1)%m;     elseans=ans*2%m;    } ......
  • HDU 4081 Qin Shi Huang's National Road System(次小树,4级)
    A- QinShiHuang'sNationalRoadSystemTimeLimit:1000MS     MemoryLimit:32768KB     64bitIOFormat:%I64d&%I64uSubmit ​​Status​​......
  • hdu 4284 Travel(压缩DP,4级)
    TravelTimeLimit:10000/5000MS(Java/Others)    MemoryLimit:32768/32768K(Java/Others)TotalSubmission(s):2641    AcceptedSubmission(s):724......
  • hdu 2608 0 or 1(数论)
    0or1TimeLimit:6000/2000MS(Java/Others)    MemoryLimit:32768/32768K(Java/Others)TotalSubmission(s):1659    AcceptedSubmission(s):418Pro......