1 条题解

  • 2
    @ 2023-7-26 10:49:08

    我来发题解啦

    #include <bits/stdc++.h>
     
    using namespace std;
     
    int n, s;
    bool b[13][13];
    const int dx[8] = {0, 0, 1, 1, 1, -1, -1, -1};
    const int dy[8] = {1, -1, 1, 0, -1, 1, 0, -1};
     
    void go(int x, int y){
    	if(x == 1 && y == n){
    		s++;
    		return;
    	}
    	int xx, yy;
    	for(int i = 0; i <= 7; i++){
    		xx = x + dx[i];
    		yy = y + dy[i];
    		if(b[xx][yy]){
    			b[xx][yy] = false;
    			go(xx, yy);
    			b[xx][yy] = true;
    		}
    	}
    }
     
    int main(){
    	int x;
    	cin >> n;
    	memset(b, 0, sizeof(b));
    	for(int i = 1; i <= n; i++){
    	  	for(int j = 1; j <= n; j++){
    			cin >> x;
    			b[i][j] = (x == 0);
    		}
    	}
    	s = 0;
    	b[1][1] = false;
    	go(1, 1);
        cout << s << endl;
        return 0;
    }
    

    已AC!

    • 1

    信息

    ID
    1110
    时间
    1000ms
    内存
    128MiB
    难度
    3
    标签
    递交数
    21
    已通过
    19
    上传者