zoukankan      html  css  js  c++  java
  • HDU 5926 Basic Mr. Frog’s Game 瞎搞

    Mr. Frog’s Game

    Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)
    Total Submission(s): 1273    Accepted Submission(s): 625


    Problem Description
    One day, Mr. Frog is playing Link Game (Lian Lian Kan in Chinese).



    In this game, if you can draw at most three horizontal or vertical head-and-tail-connected lines over the empty grids(the lines can be out of the whole board) to connect two non-empty grids with the same symbol or the two non-empty grids with the same symbol are adjacent, then you can change these two grids into empty and get several more seconds to continue the game.

    Now, Mr. Frog starts a new game (that means there is no empty grid in the board). If there are no pair of grids that can be removed together,Mr. Frog will say ”I’m angry” and criticize you.

    Mr. Frog is battle-scarred and has seen many things, so he can check the board in a very short time, maybe one second. As a Hong Kong Journalist, what you should do is to check the board more quickly than him, and then you can get out of the room before Mr. Frog being angry.
     
    Input
    The first line contains only one integer T (T500), which indicates the number of test cases.

    For each test case, the first line contains two integers n and m (1n,m30).

    In the next n lines, each line contains m integers,  j-th number in the i-th line means the symbol on the grid(the same number means the same symbol on the grid).
     
    Output
    For each test case, there should be one line in the output.

    You should output “Case #x: y”,where x is the case number(starting from 1), and y is a string representing the answer of the question. If there are at least one pair of grids that can be removed together, the y is “Yes”(without quote), else y is “No”.
     
    Sample Input
    2 3 3 1 2 1 2 1 2 1 2 1 3 3 1 2 3 2 1 2 3 2 1
     
    Sample Output
    Case #1: Yes Case #2: No
    Hint
    first sample can be explained as below.
     
    Source
     
     
    题目名字太暴力了....
    做的时候辅助输出的没删掉 wa了15min 感觉智商被掏空....
    题目本身比较水
    #include <iostream>
    #include <cstring>
    #include <cstdio>
    #include <algorithm>
    #include <queue>
    #include <vector>
    #include <iomanip>
    #include <math.h>
    #include <map>
    using namespace std;
    #define FIN     freopen("input.txt","r",stdin);
    #define FOUT    freopen("output.txt","w",stdout);
    #define INF     0x3f3f3f3f
    #define INFLL   0x3f3f3f3f3f3f3f
    #define lson    l,m,rt<<1
    #define rson    m+1,r,rt<<1|1
    typedef long long LL;
    typedef pair<int, int> PII;
    using namespace std;
    
    int mp[35][35];
    int flag = 0;
    int n, m;
    
    void dfs(int x, int y, int num) {
        if(flag) return ;
        if(x == 1 || x == n) {
            for(int i = 1; i <= m; i++) {
                if(i == y) continue;
                if(mp[x][i] == num) flag = 1;
            }
    
        }
        if(y == 1 || y == m) {
            for(int i = 1; i <= n; i++) {
                if(i == x) continue;
                if(mp[i][y] == num) flag = 1;
            }
        }
        if(mp[x + 1][y] == num || mp[x - 1][y] == num || mp[x][y + 1] == num || mp[x][y - 1] == num) flag = 1;
    }
    
    
    int main() {
        //FIN
        int T;
        int cnt = 1;
        scanf("%d", &T);
        while(T--) {
            scanf("%d%d", &n, &m);
            memset(mp, -1, sizeof(mp));
            for(int i = 1; i <= n; i++) {
                for(int j = 1; j <= m; j++) {
                    scanf("%d", &mp[i][j]);
                }
            }
    
            flag = 0;
            for(int i = 1; i<= n; i++) {
                for(int j = 1; j <= m; j++) {
                    dfs(i, j, mp[i][j]);
                }
            }
            if(flag) printf("Case #%d: Yes
    ", cnt++);
            else printf("Case #%d: No
    ", cnt++);
    
    
        }
        return 0;
    }
    

      

  • 相关阅读:
    c# 6.0, 7.0, 8.0, 9.0 总结
    Angular 学习笔记 (Angular 12 get started)
    Asp.net core 学习笔记之 globalization & localization 复习篇
    Angular 学习笔记 (Typescript 版本更新)
    Google Analytics & Ads 学习笔记 2 (GA4 版本)
    Google Analytics & Ads 学习笔记 2 (gtag 版本)
    Email 关于 POP3 IMAP SMTP office365 Outlook Gmail G-Suit shared mailbox小小理解
    摹客预言:设计工具的免费时代来了!
    低保真原型vs高保真原型,哪一种更适合你的设计?
    Instagram的UX和UI的演变史
  • 原文地址:https://www.cnblogs.com/Hyouka/p/7351259.html
Copyright © 2011-2022 走看看