Hdu 4527 Xiao Ming series of the story of play turn 10 drops of water

Source: Internet
Author: User
Tags ming printf

Xiao Ming likes to have a game named 10 drop of water recently.

The game is carried out in a 6*6 square, with a drop of water or no water droplets on each grid. Water droplets are divided into four grades 1~4. At the beginning you have 10 drops of water, and by adding it into the lattice, it will let the droplets rise to 1 levels. You can also put water in an empty grid, which produces a level 1 droplet in this lattice. When the drop level is greater than 4, it bursts into four small water droplets and splashes in four directions. Each splash of water drops into the other water droplets and then melts into one or the other, causing it to rise to a level or burst, and so on. Splash small water droplets do not interfere with each other, the speed of motion is equal (1 seconds can move a lattice distance). The water droplets burst and disappeared.

Ideas:

Directly with BFS to simulate, pay attention to the simulation of a unit time a unit time to go, if two water droplets at the same time to reach another water droplets, then the water droplets +2.

After this second, look at all the points more than 4 of the water droplets to explode into the four direction of water droplets into the queue, and then continue to walk the next second.

#include <cstdio> #include <cmath> #include <cstring> #include <iostream> #include <algorit  
     
Hm> using namespace std;  
typedef long long Int64;  
const int INF = 0X3F3F3F3F;  
     
const int MAXN = 10010;  
int m;  
int mat[8][8];  
int blast[8][8];  
     
Up, down, left, right const int dir[][2] = {{ -1,0},{1,0},{0,-1},{0,1}};  
    struct node{int x, y;  
    int cnt;  
int dir;  
     
}Q[500000];  
    void Addque (int x, int y, int cnt, int& rear) {mat[x][y] = 0;  
        for (int i=0; i<4; ++i) {int dx = x + dir[i][0];  
        int dy = y + dir[i][1];  
            if (dx>=1&&dx<=6&&dy>=1&&dy<=6) {q[rear].x = dx;  
            Q[rear].y = dy;  
            q[rear].cnt = CNT;  
        Q[rear++].dir = i;  
     
    }} void BFs (int x, int y) {int front=0, rear=0;  
     
    Addque (x, y, 0, rear); int cur = 0; Current first few seconds while (front &LT Rear {while (Front < rear && q[front].cnt==cur) {//Take this whole second to the end Node &t = Q[fr  
            Ont++];  
            if (Mat[t.x][t.y]) {++MAT[T.X][T.Y];  
                } else{node& now = q[rear];  
                now.x = T.x + dir[t.dir][0];  
                NOW.Y = T.y + dir[t.dir][1];  
                now.cnt = t.cnt + 1;  
                Now.dir = T.dir;  
            if (now.x>=1&&now.x<=6&&now.y>=1&&now.y<=6) ++rear;  
                (int i=1; i<=6; ++i) {for (int j=1; j<=6; ++j) if (mat[i][j]>4) {  
            Addque (i,j,cur+1,rear);  
    }} ++cur;  
    int main () {int x, y; while (~SCANF ("%d", &mat[1][1])} {for (int i=1; i<=6; ++i) {for (int j= (i==1?2:1) ); j<=6;  
            ++J) {    scanf ("%d", &mat[i][j]);  
        } scanf ("%d", &m);  
            for (int i=0; i<m; ++i) {scanf ("%d%d", &x, &y);  
            if (++mat[x][y]>4) {BFS (x, y);  
                (int i=1; i<=6; ++i) {for (int j=1; j<=6; ++j)  
                if (j!=1) printf ("%d", mat[i][j]);  
            else printf ("%d", mat[i][j]);  
        Putchar (' \ n ');   
    } putchar (' \ n ');  
return 0; }

See more highlights of this column: http://www.bianceng.cnhttp://www.bianceng.cn/Programming/sjjg/

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.