90,真的需要帮忙看看,求
  • 板块P1605 迷宫
  • 楼主CYHMMZDAN
  • 当前回复1
  • 已保存回复1
  • 发布时间2022/11/24 17:29
  • 上次更新2023/10/27 01:41:37
查看原帖
90,真的需要帮忙看看,求
715540
CYHMMZDAN楼主2022/11/24 17:29
import java.io.*;
import java.io.BufferedReader;
import java.lang.reflect.Array;
import java.math.BigInteger;
import java.nio.ByteBuffer;
import java.nio.charset.StandardCharsets;
import java.text.Format;
import java.text.SimpleDateFormat;
import java.util.*;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.StreamTokenizer;
import java.util.Map;
import java.util.HashMap;

public class Main {
    static StreamTokenizer in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
    static StringBuilder stringBuilder = new StringBuilder();
    static PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
    static String s = "";
    static BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in));
    static int n = 0;
    static int min = (int) 2e9;
    static int sum = 0;
    static long sum1 = 0;
    static int max = -1;
    static int m1=0;
    static int m2=0;
    static int m3=0;
    static int m = 0;
    static int ans = 0;
    static int l = 0;
    static int r = 0;
    StringBuilder stringBuilder1=new StringBuilder();
    static Map<Map<Integer,Integer> ,Integer> map= new TreeMap<Map<Integer, Integer>, Integer>();
    static Map<Integer,Integer> map1= new TreeMap<>();
    static Map<Integer,Integer> map2= new TreeMap<>();
    static Map<String,Integer> map3= new TreeMap<>();
    static int[] h = new int[(int) (5e+5)];
    static boolean[] booleans=new boolean[101];
    static int[][] b2 = new int[1][1];
    static int[] dp = new int[10005];
    static int[][] pd = new int[20][20];
    static int[][] fs = new int[20][20];
    static int[] a=new int[2022];
    static int[] lie=new int[2022];
    static int[] b=new int[15];
    static int[] a1={0,1,-1,0,0};
    static int[] b1={0,0,0,1,-1};
    static String[] s1=new String[1005];
    static Set<String> set=new TreeSet<>();
    static Stack<String> stack=new Stack<>();
    static Queue<Integer> queun=new LinkedList<Integer>();//单队列
    static Deque<Integer> deque=new ArrayDeque<>();//双队列
    static PriorityQueue<Integer> xiao = new PriorityQueue();
    static PriorityQueue<Integer> xiao1 = new PriorityQueue();
    static PriorityQueue<Integer> xiao2 = new PriorityQueue();
    static PriorityQueue<Integer> da_1 = new PriorityQueue(Collections.reverseOrder());
    static PriorityQueue<Long> da = new PriorityQueue(Collections.reverseOrder());
    public static void main(String[] args) throws IOException {
        BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
        n=Scanf_Int();
        m=Scanf_Int();
        m1=Scanf_Int();
        l=Scanf_Int();
        r=Scanf_Int();
        int x=Scanf_Int();
        int y=Scanf_Int();
       for (int i=1;i<=n;i++){
           for (int j=1;j<=m;j++){
               fs[i][j]=1;
           }
       }
        while (m1-->0){
            pd[Scanf_Int()][Scanf_Int()]=1;
        }
        dfs(1,1,x,y);
        out.println(ans);
        out.close();
    }
    public static void dfs(int x,int y,int x1,int y1){
        if (x<1||x>n||y<1||y>m||pd[x][y]==1){
            return;
        }
        if (x==x1&&y==y1){
            ans++;
            return;
        }
        if (fs[x][y]==1){
            fs[x][y]=0;
            dfs(x-1,y,x1,y1);
            dfs(x+1,y,x1,y1);
            dfs(x,y-1,x1,y1);
            dfs(x,y+1,x1,y1);
            fs[x][y]=1;
        }
    }
    public static int max_4(int a,int b,int c,int d){
        int[] f=new int[5];
        f[1]=a;
        f[2]=b;
        f[3]=c;
        f[4]=d;
        Arrays.sort(f,1,5);
        return f[4];
    }
    public static int mod(int i,int n){
        return i%n;
    }
    public static boolean pd_sushu(int x){
        for (int i=2;i*i<x;i++){
            if ((x&1)==0){
                return false;
            }
        }
        return true;
    }
    public static int find_daiquan(int n,int[] f,int[] front){
        if(f[n]==n)return f[n];
        int fn=find_daiquan(f[n],f,front);
        front[n]+=front[f[n]];
        return f[n]=fn;
    }
    public static int find_dei(int x,int[] f){
        if (f[x]==x){
            return x;
        }
        return f[x]=find_dei(f[x],f);
    }
    public static void unity1(int x,int y,int[] f,int[] z){
        int a=find_daiquan(x,f,z);
        int b=find_daiquan(y,f,z);
        f[a]=b;
    }

    public static void unity(int x,int y,int[] f){
        int a=find_dei(x,f);
        int b=find_dei(y,f);
        f[a]=b;
    }
    public static void add(int a,int b,int v,Node[] nodes){
        if (v==0){
            nodes[b].w=a;
            nodes[b].q=nodes[a].q;
            nodes[a].q=b;
            nodes[nodes[b].q].w=b;
        }
        else {
            nodes[b].q=a;
            nodes[b].w=nodes[a].w;
            nodes[a].w=b;
            nodes[nodes[b].w].q=b;
        }
    }
    public static void jian(int a,Node[] nodes){
        for (int i=nodes[0].w;i!=0;i=nodes[i].w){
            if (i==a){
                nodes[nodes[i].w].q=nodes[i].q;
                nodes[nodes[i].q].w=nodes[i].w;
            }
        }
    }

    public static long ef1(int[] a,int[] b ,int l,int r,int x){
        sum=0;
        int mid = (l + r) / 2;
        if (l>r){
            return sum;
        }
        if (b[x]<=a[1]){
            sum+=(a[1]-b[x]);
            return sum;
        }
        if (b[x]>=a[n]){
            sum+=(b[x]-a[n]);
            return sum;
        }
        if (b[x] >= a[mid - 1] && b[x] <= a[mid]) {
            sum += Math.min(a[mid] - b[x], b[x] - a[mid - 1]);
            return sum;
        }
        if (b[x]<a[mid]&&b[x]<a[mid-1]){
            return ef1(a,b,l,mid-1,x);
        }
        if (b[x]>a[mid]&&b[x]>a[mid-1]){
            return ef1(a,b,mid+1,r,x);
        }
        return sum;
    }

    public static int gys(int a,int b){
        if (a==0||b==0){
            return 0;
        }
        if (a%b==0){
            return b;
        }
        return gys(b,a%b);
    }

    public static int gbs(int a,int b){

        return a*b/gys(a,b);

    }

    public static long ks_mod(long a,long b){
        if (b==0){
            return 1%m1;
        }
        long x=1,y=a;
        while (b>0){
            if ((b&1)==1){
                x*=y;
                x%=m1;
            }
            y*=y;
            y%=m1;
            b>>=1;
        }
        return x;
    }

    public static double log2(int n){
        return Math.log(n)/Math.log(2);
    }

    public static void gb(int l,int r){
        if (l==r){
            return;
        }
        int mid=(l+r)/2;
        int z=mid+1,k=l,x=l,p=l;
        gb(l,mid);
        gb(mid+1,r);
        while (k<=mid&&z<=r){
            if (a[k]<=a[z]){
                b[x++]=a[k++];
            }
            else {
                b[x++]=a[z++];
                sum+=mid+1-k;
            }
        }
        while (k<=mid){
            b[x++]=a[k++];
        }
        while (z<=r){
            b[x++]=a[z++];
        }
        for (int i=l;i<=r;i++){
            a[i]=b[i];
        }
    }

    public static void cr(long[] a){
        for (int i=1;i<a.length;i++){
            long b=a[i];
            int b1=i-1;
            while (b1>=0&&b>a[b1]){
                a[b1+1]=a[b1];
                b1--;
            }
            a[b1+1]=b;
        }
    }

    static int Scanf_Int() throws IOException {
        in.nextToken();
        return (int) in.nval;
    }

    static long Scanf_Long() throws IOException {
        in.nextToken();
        return (long) in.nval;
    }

    static double Scanf_Double() throws  IOException{
        in.nextToken();
        return in.nval;
    }
    static char Scanf_Char()throws IOException{//输入字符后可以空格,也可以换行
        in.nextToken();
        return in.sval.charAt(0);
    }
    static String Scanf_String() throws IOException{
        /*不能用这个来转变为字符数组和字符串数组,用bf.readLine();
         输入字符串后可以空格,也可以换行*/
        in.nextToken();
        return in.sval;
    }
}
class Node implements Comparable<Node> {
    int q,w;
    double e;
    String s;
    String s1;

    public Node(String s, String s1) {
        this.s = s;
        this.s1 = s1;
    }

    public Node(int q, int w) {
        this.q = q;
        this.w = w;
    }

    public Node(int q, String s) {
        this.q = q;
        this.s = s;
    }

    public Node(int q, int w, double e) {
        this.q = q;
        this.w = w;
        this.e = e;
    }

    @Override
    public int compareTo(Node o) {
        if (o.e>=this.e){
            return 1;
        }
        return -1;
    }
}
class Node1 implements Comparable<Node1>{
    int t,l,r,x;
    String s;


    public Node1(int t, int x, String s) {
        this.t = t;
        this.x = x;
        this.s = s;
    }

    @Override
    public int compareTo(Node1 o) {
        return o.t-this.t;
    }
}
2022/11/24 17:29
加载中...