HDU 5336 (2015 + school 4)-xyz and Drops (BFS)

Source: Internet
Author: User

Title Address: HDU 5336
Test instructions: There is an R row in column C, giving the size of the water droplets in n squares. The time limit T is given, which causes the water droplets to burst from the (Sx,sy) position, and when the fly-out waters meet the static water in the lattice, they converge when the aggregate droplet size >4. Ask about the water droplets in the N-position lattice given at t when the output is not burst: 1 The size of the droplets in the lattice. Otherwise the output: 0 blasting time.

#include <stdio.h>#include <math.h>#include <string.h>#include <stdlib.h>#include <iostream>#include <sstream>#include <algorithm>#include <set>#include <queue>#include <stack>#include <map>#pragma COMMENT (linker, "/stack:102400000,102400000")using namespace STD;typedef Long LongLL;Const intinf=0x3f3f3f3f;Const DoublePi=ACOs(-1.0);Const Doubleesp=1e-6;intmp[ the][ the];inttime[ the][ the];intjx[]= {0,1,0,-1};intjy[]= {1,0,-1,0};intR,c,n,t;intSx,sy;structDrop {intx, y;intTimeintPapa;} F1,F2;voidBFsintXxintYY) { queue<drop>Q    F1.x=xx;    F1.y=yy; F1.time=0; f1.papa=-1; Q.push (F1); while(!q.empty ())     {F1=q.front (); Q.pop ();if(f1.papa>=0) {F2.x=f1.x+jx[f1.papa];            F2.y=f1.y+jy[f1.papa]; f2.time=f1.time+1;if(f2.x>=1&&f2.x<=r&&f2.y>=1&&f2.y<=c&&f2.time<=t) {if(Mp[f2.x][f2.y]) {mp[f2.x][f2.y]++;if(mp[f2.x][f2.y]==5) {f2.papa=-1;                        Q.push (F2); }                    }Else{F2.papa=f1.papa;                    Q.push (F2); }                }        }Else{time[f1.x][f1.y]=f1.time; mp[f1.x][f1.y]=0; for(intI=0; i<4;            i++) {F2.x=f1.x+jx[i];            F2.y=f1.y+jy[i]; f2.time=f1.time+1;if(f2.x>=1&&f2.x<=r&&f2.y>=1&&f2.y<=c&&f2.time<=t) {if(Mp[f2.x][f2.y]) {mp[f2.x][f2.y]++;if(mp[f2.x][f2.y]==5) {f2.papa=-1;                        Q.push (F2); }                    }Else{f2.papa=i;                    Q.push (F2); }                }            }        }    }}intMain () {intV Drop node[ the]; while(~scanf("%d %d%d%d", &r,&c,&n,&t)) {memset(MP,0,sizeof(MP)); for(intI=0; i<n;i++) {scanf(" %d%d%d", &sx,&sy,&v);            NODE[I].X=SX;            Node[i].y=sy;        Mp[sx][sy]+=v; }scanf("%d%d", &sx,&sy); BFS (Sx,sy); for(intI=0; i<n;i++)if(Mp[node[i].x][node[i].y])printf("1%d\n", Mp[node[i].x][node[i].y]);Else                printf("0%d\n", Time[node[i].x][node[i].y]); }}/* Arrive at the same water droplet at the same time (so the code is ==5 instead of >4) 4 4 5 1001 1 2 to 3 4 3

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

HDU 5336 (2015 + school 4)-xyz and Drops (BFS)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.