十四届蓝桥杯打卡day19

1、灌溉

import java.util.*;
import java.io.*;
public class Main {
  static BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
  static PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
  static int[] dx = {0,1,0,-1};
  static int[] dy = {1,0,-1,0};
  static int t,r,c,k;
  static int sum = 0;
  static int n,m;
  static Queue q = new LinkedList<>();//创建队列
    public static void main(String[] args) throws IOException {
        String []s = in.readLine().split(" ");
        n = Integer.parseInt(s[0]);
        m = Integer.parseInt(s[1]);
        int [][]a = new int[n][m];
        s = in.readLine().split(" ");
        t = Integer.parseInt(s[0]);
        for(int i=0;i0){
            bfs(q.poll(),q.poll(),a);
            size-=2;
          }
        }
        System.out.println(sum+t);
        in.close();
        out.flush();
        }
        static void bfs(int r,int c,int[][]a){
          for(int i = 0;i<4;i++){
            int nx = r+dx[i];
            int ny = c+dy[i];
            if(nx>=0 && nx=0 && ny

你可能感兴趣的:(蓝桥杯,java,职场和发展)