#define _USE_MATH_DEFINES #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; // 行列の積 template vector > matrixProduct(const vector >& x, const vector >& y) { int a = x.size(); int b = x[0].size(); int c = y[0].size(); vector > z(a, vector(c, 0)); for(int i=0; i vector > matrixPower(const vector >& x, int k) { int n = x.size(); vector > y(n, vector(n, 0)); for(int i=0; i > z = x; while(k > 0){ if(k & 1) y = matrixProduct(y, z); z = matrixProduct(z, z); k >>= 1; } return y; } const int dy[] = {-1, 0, 0, 1}; const int dx[] = {0, 1, -1, 0}; int main() { int h, w, t; int sy, sx, gy, gx; cin >> h >> w >> t >> sy >> sx >> gy >> gx; int si = sy * w + sx; int gi = gy * w + gx; vector grid(h); for(int i=0; i> grid[i]; int n = h * w; vector > mat(n, vector(n, 0.0)); for(int y=0; y