id int64 1 3.58k | problem_description stringlengths 516 21.8k | instruction int64 0 3 | solution_c dict |
|---|---|---|---|
3,560 | <p>There is a <code>50 x 50</code> chessboard with <strong>one</strong> knight and some pawns on it. You are given two integers <code>kx</code> and <code>ky</code> where <code>(kx, ky)</code> denotes the position of the knight, and a 2D array <code>positions</code> where <code>positions[i] = [x<sub>i</sub>, y<sub>i</su... | 0 | {
"code": "class Solution {\npublic:\nint n;\n int getsteps(int x, int y, int tx, int ty, vector<vector<int>>&dp) {\n if (x == tx && y == ty) \n return dp[0][0]; \n else { \n\n if (dp[abs(x - tx)][abs(y - ty)] != 0) \n return dp[abs(x - tx)][abs(y - ty)]; \n \n el... |
3,560 | <p>There is a <code>50 x 50</code> chessboard with <strong>one</strong> knight and some pawns on it. You are given two integers <code>kx</code> and <code>ky</code> where <code>(kx, ky)</code> denotes the position of the knight, and a 2D array <code>positions</code> where <code>positions[i] = [x<sub>i</sub>, y<sub>i</su... | 0 | {
"code": "const int mv[8][2] = {{1, 2}, {2, 1}, {2, -1}, {1, -2},\n {-1, -2}, {-2, -1}, {-2, 1}, {-1, 2}};\nconst int N = 50;\nint D[16][16]; \nint sz;\nint dp[2][16][(1 << 16)];\n\nusing int2 = pair<int, int>;\nclass Solution {\npublic:\n inline bool isInside(int r0, int c0) {\n r... |
3,560 | <p>There is a <code>50 x 50</code> chessboard with <strong>one</strong> knight and some pawns on it. You are given two integers <code>kx</code> and <code>ky</code> where <code>(kx, ky)</code> denotes the position of the knight, and a 2D array <code>positions</code> where <code>positions[i] = [x<sub>i</sub>, y<sub>i</su... | 0 | {
"code": "class Solution {\npublic:\n using pii = pair<int, int>;\n\n int dfs(vector<vector<int>>& dp, const vector<vector<int>>& steps, int i, int k, bool is_alice) {\n if (k == 0) return 0;\n if (dp[i][k] != -1) return dp[i][k];\n int n = dp.size(), ret = is_alice ? INT_MIN : INT_MAX;\n ... |
3,560 | <p>There is a <code>50 x 50</code> chessboard with <strong>one</strong> knight and some pawns on it. You are given two integers <code>kx</code> and <code>ky</code> where <code>(kx, ky)</code> denotes the position of the knight, and a 2D array <code>positions</code> where <code>positions[i] = [x<sub>i</sub>, y<sub>i</su... | 0 | {
"code": "#define MAX_POSITIONS 15\n#define BOARD_SIZE 50\n#define INF 1e8\nclass Solution {\npublic:\n \n // who = 0 -> maximize\n // who = 1 -> minimize\n \n int moves[MAX_POSITIONS][BOARD_SIZE][BOARD_SIZE];\n bool HasBit(int mask, int id) {\n return (mask>>id)&1;\n }\n int dp[MAX_PO... |
3,560 | <p>There is a <code>50 x 50</code> chessboard with <strong>one</strong> knight and some pawns on it. You are given two integers <code>kx</code> and <code>ky</code> where <code>(kx, ky)</code> denotes the position of the knight, and a 2D array <code>positions</code> where <code>positions[i] = [x<sub>i</sub>, y<sub>i</su... | 0 | {
"code": "class Solution {\npublic:\n set<pair<int,int>> corners = {{0,0}, {0,49}, {49,0}, {49,49}};\n vector<vector<int>> dp;\n\n int maxMoves(int kx, int ky, vector<vector<int>>& positions) {\n int n = positions.size();\n positions.push_back({kx, ky});\n dp.resize(1 << (n+1), vector<i... |
3,560 | <p>There is a <code>50 x 50</code> chessboard with <strong>one</strong> knight and some pawns on it. You are given two integers <code>kx</code> and <code>ky</code> where <code>(kx, ky)</code> denotes the position of the knight, and a 2D array <code>positions</code> where <code>positions[i] = [x<sub>i</sub>, y<sub>i</su... | 0 | {
"code": "class Solution {\npublic:\n int maxMoves(int kx, int ky, vector<vector<int>>& positions) {\n int n = positions.size();\n positions.push_back({kx, ky});\n set<pair<int,int>> corners = {{0,0}, {0,49}, {49,0}, {49,49}};\n vector<vector<int>> dp(1 << (n+1), vector<int>(n+1, 0));\... |
3,560 | <p>There is a <code>50 x 50</code> chessboard with <strong>one</strong> knight and some pawns on it. You are given two integers <code>kx</code> and <code>ky</code> where <code>(kx, ky)</code> denotes the position of the knight, and a 2D array <code>positions</code> where <code>positions[i] = [x<sub>i</sub>, y<sub>i</su... | 0 | {
"code": "#include <bits/stdc++.h>\nusing namespace std;\n#define all(x) x.begin(), x.end()\nusing ull = unsigned long long;\nusing ll = long long;\nusing pii = pair<int,int>;\nusing pll = pair<ll,ll>;\nusing vi = vector<int>;\nusing vll = vector<ll>;\nusing vvi = vector<vector<int>>;\nusing vvll = vector<vector<ll>... |
3,560 | <p>There is a <code>50 x 50</code> chessboard with <strong>one</strong> knight and some pawns on it. You are given two integers <code>kx</code> and <code>ky</code> where <code>(kx, ky)</code> denotes the position of the knight, and a 2D array <code>positions</code> where <code>positions[i] = [x<sub>i</sub>, y<sub>i</su... | 0 | {
"code": "int dist[2500][2500];\nvector<int> dx, dy;\n\nvoid build() {\n if (!dx.empty())\n return;\n\n vector<int> adj[2500];\n\n dx = {2, 2, -2, -2, 1, 1, -1, -1};\n dy = {1, -1, 1, -1, 2, -2, 2, -2};\n\n for (int i = 0; i < 50; i++) {\n for (int j = 0; j < 50; j++) {\n int ... |
3,560 | <p>There is a <code>50 x 50</code> chessboard with <strong>one</strong> knight and some pawns on it. You are given two integers <code>kx</code> and <code>ky</code> where <code>(kx, ky)</code> denotes the position of the knight, and a 2D array <code>positions</code> where <code>positions[i] = [x<sub>i</sub>, y<sub>i</su... | 0 | {
"code": "const int MAX_DIST = 10000;\nconst int MAX_N = 15; \nconst int MAX_POS = 2500;\n\nint dp[MAX_POS][MAX_POS];\nint dp1[1 << MAX_N][MAX_N + 1];\n\nvector<pair<int, int>> dir = {{2, 1}, {2, -1}, {-2, 1}, {-2, -1},\n {1, 2}, {1, -2}, {-1, 2}, {-1, -2}};\n\nint IDX(int i, int j) { re... |
3,560 | <p>There is a <code>50 x 50</code> chessboard with <strong>one</strong> knight and some pawns on it. You are given two integers <code>kx</code> and <code>ky</code> where <code>(kx, ky)</code> denotes the position of the knight, and a 2D array <code>positions</code> where <code>positions[i] = [x<sub>i</sub>, y<sub>i</su... | 0 | {
"code": "const int MAX_DIST = 3000;\nconst int MAX_N = 15; \nconst int MAX_POS = 2500;\n\nint dp[MAX_POS][MAX_POS];\nint dp1[1 << MAX_N][MAX_N + 1];\n\nvector<pair<int, int>> dir = {{2, 1}, {2, -1}, {-2, 1}, {-2, -1},\n {1, 2}, {1, -2}, {-1, 2}, {-1, -2}};\n\nint IDX(int i, int j) { ret... |
3,560 | <p>There is a <code>50 x 50</code> chessboard with <strong>one</strong> knight and some pawns on it. You are given two integers <code>kx</code> and <code>ky</code> where <code>(kx, ky)</code> denotes the position of the knight, and a 2D array <code>positions</code> where <code>positions[i] = [x<sub>i</sub>, y<sub>i</su... | 0 | {
"code": "static const int __ = [](){\n ios_base::sync_with_stdio(false);\n cin.tie(nullptr);\n cout.tie(nullptr);\n return 0;\n}();\n\nconst int dx[8] = {-2, -2, -1, -1, +1, +1, +2, +2};\nconst int dy[8] = {-1, +1, -2, +2, -2, +2, -1, +1};\n\nclass Solution {\n struct PairHash {\n template <cl... |
3,560 | <p>There is a <code>50 x 50</code> chessboard with <strong>one</strong> knight and some pawns on it. You are given two integers <code>kx</code> and <code>ky</code> where <code>(kx, ky)</code> denotes the position of the knight, and a 2D array <code>positions</code> where <code>positions[i] = [x<sub>i</sub>, y<sub>i</su... | 0 | {
"code": "static const int __ = [](){\n ios_base::sync_with_stdio(false);\n cin.tie(nullptr);\n cout.tie(nullptr);\n return 0;\n}();\n\nconst int dx[8] = {-2, -2, -1, -1, +1, +1, +2, +2};\nconst int dy[8] = {-1, +1, -2, +2, -2, +2, -1, +1};\n\nclass Solution {\n struct PairHash {\n template <cl... |
3,560 | <p>There is a <code>50 x 50</code> chessboard with <strong>one</strong> knight and some pawns on it. You are given two integers <code>kx</code> and <code>ky</code> where <code>(kx, ky)</code> denotes the position of the knight, and a 2D array <code>positions</code> where <code>positions[i] = [x<sub>i</sub>, y<sub>i</su... | 0 | {
"code": "const int L = 50;\nint G[L][L][L][L];\nint D[8][2] = {{1, 2}, {1, -2}, {-1, 2}, {-1, -2}, {2, 1}, {2, -1}, {-2, 1}, {-2, -1}};\nint dp[2][(15 << 15) + 5];\n\nclass Solution {\npublic:\n void FindG(int s)\n{\n int xs = s / L, ys = s % L;\n queue<int> q;\n q.push(s);\n while(!q.empty())\n {... |
3,560 | <p>There is a <code>50 x 50</code> chessboard with <strong>one</strong> knight and some pawns on it. You are given two integers <code>kx</code> and <code>ky</code> where <code>(kx, ky)</code> denotes the position of the knight, and a 2D array <code>positions</code> where <code>positions[i] = [x<sub>i</sub>, y<sub>i</su... | 0 | {
"code": "class Solution {\n int d[16][16];\n void print(vector<vector<int>>& pos, int i)\n {\n cout << \"(\" << pos[i][0] << \",\" << pos[i][1] << \")\";\n }\n int dx[8] = {-2, -2, -1, 1, 2, 2, 1, -1};\n int dy[8] = {-1, 1, 2, 2, 1, -1, -2, -2};\n int n;\n int f[100010][16] = {};\npub... |
3,560 | <p>There is a <code>50 x 50</code> chessboard with <strong>one</strong> knight and some pawns on it. You are given two integers <code>kx</code> and <code>ky</code> where <code>(kx, ky)</code> denotes the position of the knight, and a 2D array <code>positions</code> where <code>positions[i] = [x<sub>i</sub>, y<sub>i</su... | 0 | {
"code": "auto _=[]{ios_base::sync_with_stdio(false),cin.tie(0);return 0;}();\n#define all(x) (x).begin(),(x).end()\nconst vector<int> dx = {1,2,2,1,-1,-2,-2,-1};\nconst vector<int> dy = {2,1,-1,-2,-2,-1,1,2};\nvector<vector<int>> dp(2500,vector<int>(2500)), moves((1<<17),vector<int>(16));\nclass Solution {\npublic:... |
3,560 | <p>There is a <code>50 x 50</code> chessboard with <strong>one</strong> knight and some pawns on it. You are given two integers <code>kx</code> and <code>ky</code> where <code>(kx, ky)</code> denotes the position of the knight, and a 2D array <code>positions</code> where <code>positions[i] = [x<sub>i</sub>, y<sub>i</su... | 0 | {
"code": "class Solution{\npublic:\n int aux[1<<15][16][2],bux[16][16],cux[50][50];\n\n int rec(int sx,int sy,int tx,int ty){\n queue<pair<int,int>> q;\n memset(cux,-1,sizeof(cux));\n q.push({sx,sy});\n cux[sx][sy]=0;\n while(!q.empty()){\n int x=q.front().first,y=... |
3,560 | <p>There is a <code>50 x 50</code> chessboard with <strong>one</strong> knight and some pawns on it. You are given two integers <code>kx</code> and <code>ky</code> where <code>(kx, ky)</code> denotes the position of the knight, and a 2D array <code>positions</code> where <code>positions[i] = [x<sub>i</sub>, y<sub>i</su... | 0 | {
"code": "typedef pair<int, int> pii;\n\nint dx[] = {-1, 1, 2, 2, 1, -1, -2, -2};\nint dy[] = {2, 2, 1, -1, -2, -2, -1, 1};\n\nclass Solution {\n vector<vector<int>> dists1;\n vector<vector<int>> dists2;\n vector<int> dp;\n int n;\npublic:\n int maxMoves(int kx, int ky, vector<vector<int>>& positions)... |
3,560 | <p>There is a <code>50 x 50</code> chessboard with <strong>one</strong> knight and some pawns on it. You are given two integers <code>kx</code> and <code>ky</code> where <code>(kx, ky)</code> denotes the position of the knight, and a 2D array <code>positions</code> where <code>positions[i] = [x<sub>i</sub>, y<sub>i</su... | 0 | {
"code": "class Solution {\npublic:\n//odd set bit-->alise-->max;\n int helper(int l, int kx, int ky, vector<vector<int>>& pos, vector<vector<int>>&dp, vector<vector<int>>&precum, vector<vector<int>>&precum1, int msk){\n int i,j;\n if(msk==0) return 0;\n \n int set=pos.size() - __builtin_popc... |
3,560 | <p>There is a <code>50 x 50</code> chessboard with <strong>one</strong> knight and some pawns on it. You are given two integers <code>kx</code> and <code>ky</code> where <code>(kx, ky)</code> denotes the position of the knight, and a 2D array <code>positions</code> where <code>positions[i] = [x<sub>i</sub>, y<sub>i</su... | 0 | {
"code": "class Solution {\npublic:\n//odd set bit-->alise-->max;\n int helper(int l, int kx, int ky, vector<vector<int>>& pos, vector<vector<int>>&dp, vector<vector<int>>&precum, vector<vector<int>>&precum1, int msk){\n int i,j;\n if(msk==0) return 0;\n \n int set=pos.size() - __builtin_popc... |
3,560 | <p>There is a <code>50 x 50</code> chessboard with <strong>one</strong> knight and some pawns on it. You are given two integers <code>kx</code> and <code>ky</code> where <code>(kx, ky)</code> denotes the position of the knight, and a 2D array <code>positions</code> where <code>positions[i] = [x<sub>i</sub>, y<sub>i</su... | 0 | {
"code": "class Solution {\nprivate:\n int bfs(const pair<int,int>& s, const pair<int,int>& t) {\n const int n(50), mv[][2]={{-1,-2},{-2,-1},{-2,1},{-1,2},{1,2},{2,1},{2,-1},{1,-2}};\n int res(0);\n queue<pair<int,int>> que({s});\n bool usd[n][n];\n memset(usd,0,sizeof(usd));\n ... |
3,560 | <p>There is a <code>50 x 50</code> chessboard with <strong>one</strong> knight and some pawns on it. You are given two integers <code>kx</code> and <code>ky</code> where <code>(kx, ky)</code> denotes the position of the knight, and a 2D array <code>positions</code> where <code>positions[i] = [x<sub>i</sub>, y<sub>i</su... | 0 | {
"code": "class Solution {\npublic:\n const vector<pair<int, int>> DIRECTIONS = { {2, 1}, {2, -1}, {1, 2}, {-1, 2}, {-2, 1}, {-2, -1}, {1, -2}, {-1, -2}};\n int maxMoves(int kx, int ky, vector<vector<int>>& pos) {\n int n = 50;\n int m = pos.size();\n int inf = 1e9;\n \n vect... |
3,560 | <p>There is a <code>50 x 50</code> chessboard with <strong>one</strong> knight and some pawns on it. You are given two integers <code>kx</code> and <code>ky</code> where <code>(kx, ky)</code> denotes the position of the knight, and a 2D array <code>positions</code> where <code>positions[i] = [x<sub>i</sub>, y<sub>i</su... | 0 | {
"code": "vector<vector<int>> dist(2500 , vector<int> (2500 , 1e5));\n\n int get(int x , int y){\n return x * 50 + (y%50); \n }\nbool precompute(){\n auto fin = [&](int start){\n queue<int> q;\n q.push(start);\n dist[start][sta... |
3,560 | <p>There is a <code>50 x 50</code> chessboard with <strong>one</strong> knight and some pawns on it. You are given two integers <code>kx</code> and <code>ky</code> where <code>(kx, ky)</code> denotes the position of the knight, and a 2D array <code>positions</code> where <code>positions[i] = [x<sub>i</sub>, y<sub>i</su... | 0 | {
"code": "class Solution {\nprivate:\n int memoTable[50][1 << 15];\n int distances[16][16];\n int totalPawns;\n\n void calculateDistances(int startX, int startY, const vector<vector<int>>& pawns) {\n for (int i = 0; i < totalPawns; ++i) {\n distances[0][i + 1] = computeDistance(startX, ... |
3,560 | <p>There is a <code>50 x 50</code> chessboard with <strong>one</strong> knight and some pawns on it. You are given two integers <code>kx</code> and <code>ky</code> where <code>(kx, ky)</code> denotes the position of the knight, and a 2D array <code>positions</code> where <code>positions[i] = [x<sub>i</sub>, y<sub>i</su... | 0 | {
"code": "static constexpr int dir[8][2] = {{-2, 1}, {2, 1}, {2, -1}, {-2, -1}, {1, 2}, {-1, 2}, {1, -2}, {-1, -2}};\nclass Solution {\npublic:\n int maxMoves(int kx, int ky, vector<vector<int>>& positions) {\n int n = positions.size(), dis[n + 1][50][50];\n memset(dis, -1, sizeof(dis));\n qu... |
3,560 | <p>There is a <code>50 x 50</code> chessboard with <strong>one</strong> knight and some pawns on it. You are given two integers <code>kx</code> and <code>ky</code> where <code>(kx, ky)</code> denotes the position of the knight, and a 2D array <code>positions</code> where <code>positions[i] = [x<sub>i</sub>, y<sub>i</su... | 0 | {
"code": "class Solution {\npublic:\nint moves[17][17];\nint knight[9] = {1, 2, 1, -2, -1, 2, -1, -2, 1}; \nvoid bfs(int i, vector<vector<int>> &pos) {\n int b[50][50] = {}, sx = pos[i][0], sy = pos[i][1];\n vector<pair<int, int>> q{{sx, sy}};\n while (!q.empty()) {\n vector<pair<int, int>> q1;\n ... |
3,560 | <p>There is a <code>50 x 50</code> chessboard with <strong>one</strong> knight and some pawns on it. You are given two integers <code>kx</code> and <code>ky</code> where <code>(kx, ky)</code> denotes the position of the knight, and a 2D array <code>positions</code> where <code>positions[i] = [x<sub>i</sub>, y<sub>i</su... | 0 | {
"code": "class Solution {\npublic:\n int dista[15][50][50];\n void bfs(int &x, int &y, int i){\n queue<pair<int,int>> qu;\n qu.push({x,y});\n dista[i][x][y]=0;\n int dist=1;\n int dir[8][2]={{-2,1},{-1,2},{1,2},{2,1},{2,-1},{1,-2},{-1,-2},{-2,-1}};\n \n while(!... |
3,560 | <p>There is a <code>50 x 50</code> chessboard with <strong>one</strong> knight and some pawns on it. You are given two integers <code>kx</code> and <code>ky</code> where <code>(kx, ky)</code> denotes the position of the knight, and a 2D array <code>positions</code> where <code>positions[i] = [x<sub>i</sub>, y<sub>i</su... | 0 | {
"code": "class Solution {\npublic:\n pair<int, int> dirs[8] = {{-2, -1}, {-2, 1}, {2, -1}, {2, 1}, {-1, 2}, {1, 2}, {-1, -2}, {1, -2}};\n int maxMoves(int kx, int ky, vector<vector<int>>& positions) {\n int state = 0;\n vector<unordered_map<int, int>> memo(2);\n unordered_map<int, int> me... |
3,560 | <p>There is a <code>50 x 50</code> chessboard with <strong>one</strong> knight and some pawns on it. You are given two integers <code>kx</code> and <code>ky</code> where <code>(kx, ky)</code> denotes the position of the knight, and a 2D array <code>positions</code> where <code>positions[i] = [x<sub>i</sub>, y<sub>i</su... | 0 | {
"code": " int dp[2][16][(1<<16)];\n int moves[50][50][50][50];\n vector<int> dx={-2,-1,1,2,2,1,-1,-2};\n vector<int> dy={1,2,2,1,-1,-2,-2,-1};\n vector<vector<int> > pos;\n int n;\n bool precaled=false;\n \n void precal(){\n precaled=true;\n \n for(int i=0;i<50;i++){\n ... |
3,560 | <p>There is a <code>50 x 50</code> chessboard with <strong>one</strong> knight and some pawns on it. You are given two integers <code>kx</code> and <code>ky</code> where <code>(kx, ky)</code> denotes the position of the knight, and a 2D array <code>positions</code> where <code>positions[i] = [x<sub>i</sub>, y<sub>i</su... | 0 | {
"code": "// structure for storing a cell's data\nstruct cell {\n int x, y;\n int dis;\n cell() {}\n cell(int x, int y, int dis)\n : x(x)\n , y(y)\n , dis(dis)\n {\n }\n};\n\n// Utility method returns true if (x, y) lies\n// inside Board\nbool isInside(int x, int y, int N)\n{\n... |
3,560 | <p>There is a <code>50 x 50</code> chessboard with <strong>one</strong> knight and some pawns on it. You are given two integers <code>kx</code> and <code>ky</code> where <code>(kx, ky)</code> denotes the position of the knight, and a 2D array <code>positions</code> where <code>positions[i] = [x<sub>i</sub>, y<sub>i</su... | 0 | {
"code": "auto _=[]{ios_base::sync_with_stdio(false),cin.tie(0);return 0;}();\n#define all(x) (x).begin(),(x).end()\nconst vector<int> dx = {1,2,2,1,-1,-2,-2,-1};\nconst vector<int> dy = {2,1,-1,-2,-2,-1,1,2};\nvector<vector<int>> dp(2500,vector<int>(2500)), moves((1<<17),vector<int>(16));\nclass Solution {\npublic:... |
3,560 | <p>There is a <code>50 x 50</code> chessboard with <strong>one</strong> knight and some pawns on it. You are given two integers <code>kx</code> and <code>ky</code> where <code>(kx, ky)</code> denotes the position of the knight, and a 2D array <code>positions</code> where <code>positions[i] = [x<sub>i</sub>, y<sub>i</su... | 0 | {
"code": "template<class T,class T2>inline bool Amin(T& t,const T2& v){if(v<t){t=v;return 1;}return 0;}\ntemplate<class T,class T2>inline bool Amax(T& t,const T2& v){if(v>t){t=v;return 1;}return 0;}\nclass Solution {\npublic:\n int ssdis[50][50];\n int dis[16][16],dp[1<<16][16];\n queue<pair<int,int>>q;\n ... |
3,560 | <p>There is a <code>50 x 50</code> chessboard with <strong>one</strong> knight and some pawns on it. You are given two integers <code>kx</code> and <code>ky</code> where <code>(kx, ky)</code> denotes the position of the knight, and a 2D array <code>positions</code> where <code>positions[i] = [x<sub>i</sub>, y<sub>i</su... | 0 | {
"code": "class Solution {\npublic:\n int d[16][50][50],dis[50][50];\n const int nxt[8][2]={{1,2},{1,-2},{2,1},{2,-1},{-1,2},{-1,-2},{-2,1},{-2,-1}};\n void bfs(int id,int px,int py){\n for(int i=0;i<50;i++){\n for(int j=0;j<50;j++){\n dis[i][j]=-1;\n }\n }... |
3,560 | <p>There is a <code>50 x 50</code> chessboard with <strong>one</strong> knight and some pawns on it. You are given two integers <code>kx</code> and <code>ky</code> where <code>(kx, ky)</code> denotes the position of the knight, and a 2D array <code>positions</code> where <code>positions[i] = [x<sub>i</sub>, y<sub>i</su... | 0 | {
"code": "#define REP(i,a,b) for(int i = a; i <= b; ++i)\n#define mem(a,b) memset(a,b,sizeof(a))\nconst int maxn = 50, maxk = 16;\nconst int walk[8][2] = {{1,2}, {1,-2}, {-1,2}, {-1,-2}, {2,1}, {2,-1}, {-2,1}, {-2,-1}};\n\nint dis[20][20];\nint mpp[maxn+5][maxn+5];\nint kk, f[2][maxk+5][(1<<maxk) + 5];\n\nint dfs(in... |
3,560 | <p>There is a <code>50 x 50</code> chessboard with <strong>one</strong> knight and some pawns on it. You are given two integers <code>kx</code> and <code>ky</code> where <code>(kx, ky)</code> denotes the position of the knight, and a 2D array <code>positions</code> where <code>positions[i] = [x<sub>i</sub>, y<sub>i</su... | 0 | {
"code": "using P2I = pair<int, int>;\nusing T4I = tuple<int, int, int, int>;\nclass Solution {\n vector<vector<int>> dist = {\n {2, 1},\n {2, -1},\n {-2, 1},\n {-2, -1},\n {1, 2},\n {1, -2},\n {-1, 2},\n {-1, -2}\n };\n int memo[3000][16];\n int ba... |
3,560 | <p>There is a <code>50 x 50</code> chessboard with <strong>one</strong> knight and some pawns on it. You are given two integers <code>kx</code> and <code>ky</code> where <code>(kx, ky)</code> denotes the position of the knight, and a 2D array <code>positions</code> where <code>positions[i] = [x<sub>i</sub>, y<sub>i</su... | 0 | {
"code": "class Solution {\npublic:\n int dp[20][(1<<16)][2];\n int d[51][50][50];\n int v[51][50][50];\n int maxMoves(int kx, int ky, vector<vector<int>>& p) {\n p.insert(p.begin(),{kx,ky});\n int n=p.size();\n memset(dp,-1,sizeof(dp));\n for(int i=0;i<51;i++){\n f... |
3,560 | <p>There is a <code>50 x 50</code> chessboard with <strong>one</strong> knight and some pawns on it. You are given two integers <code>kx</code> and <code>ky</code> where <code>(kx, ky)</code> denotes the position of the knight, and a 2D array <code>positions</code> where <code>positions[i] = [x<sub>i</sub>, y<sub>i</su... | 0 | {
"code": "class Solution {\npublic:\n int dp[20][(1<<16)][2];\n int d[51][50][50];\n int v[51][50][50];\n int maxMoves(int kx, int ky, vector<vector<int>>& p) {\n p.insert(p.begin(),{kx,ky});\n int n=p.size();\n memset(dp,-1,sizeof(dp));\n for(int i=0;i<51;i++){\n f... |
3,560 | <p>There is a <code>50 x 50</code> chessboard with <strong>one</strong> knight and some pawns on it. You are given two integers <code>kx</code> and <code>ky</code> where <code>(kx, ky)</code> denotes the position of the knight, and a 2D array <code>positions</code> where <code>positions[i] = [x<sub>i</sub>, y<sub>i</su... | 0 | {
"code": "\nint dx[] = {-2, -1, 1, 2, 2, 1, -1, -2};\nint dy[] = {1, 2, 2, 1, -1, -2, -2, -1};\nvector<vector<int>> minmoves[51][51];\nbool done=false;\n vector<vector<int>> bfs(int i,int j){\n vector<vector<int>> dis(51,vector<int> (51,1e9));\n dis[i][j]=1;\n queue<pair<int,int>> q;\n dis[i][j]=0;\n q... |
3,560 | <p>There is a <code>50 x 50</code> chessboard with <strong>one</strong> knight and some pawns on it. You are given two integers <code>kx</code> and <code>ky</code> where <code>(kx, ky)</code> denotes the position of the knight, and a 2D array <code>positions</code> where <code>positions[i] = [x<sub>i</sub>, y<sub>i</su... | 0 | {
"code": "class Solution {\npublic:\n typedef long long ll;\n ll predp[16][50][50];\n ll dp[65536][16][2];\n vector<ll>dx={1,1,2,2,-2,-2,-1,-1};\n vector<ll>dy={2,-2,-1,1,-1,1,2,-2};\n bool isValid(int i,int j){\n return (i>=0&&i<50&&j>=0&&j<50);\n }\n void bfs(int kx,int ky,ve... |
3,560 | <p>There is a <code>50 x 50</code> chessboard with <strong>one</strong> knight and some pawns on it. You are given two integers <code>kx</code> and <code>ky</code> where <code>(kx, ky)</code> denotes the position of the knight, and a 2D array <code>positions</code> where <code>positions[i] = [x<sub>i</sub>, y<sub>i</su... | 0 | {
"code": "class Solution {\nprivate:\n const int N = 50;\n vector<vector<int>> dirs = {{2, 1}, {2, -1}, {-2, 1}, {-2, -1}, \n {1, 2}, {1, -2}, {-1, 2}, {-1, -2}};\n\npublic:\n int maxMoves(int kx, int ky, vector<vector<int>>& positions) {\n positions.insert(positions.be... |
3,560 | <p>There is a <code>50 x 50</code> chessboard with <strong>one</strong> knight and some pawns on it. You are given two integers <code>kx</code> and <code>ky</code> where <code>(kx, ky)</code> denotes the position of the knight, and a 2D array <code>positions</code> where <code>positions[i] = [x<sub>i</sub>, y<sub>i</su... | 0 | {
"code": "class Solution {\nprivate:\n const int N = 50;\n vector<vector<int>> dirs = {{2, 1}, {2, -1}, {-2, 1}, {-2, -1}, \n {1, 2}, {1, -2}, {-1, 2}, {-1, -2}};\n\npublic:\n int maxMoves(int kx, int ky, vector<vector<int>>& positions) {\n positions.insert(positions.be... |
3,560 | <p>There is a <code>50 x 50</code> chessboard with <strong>one</strong> knight and some pawns on it. You are given two integers <code>kx</code> and <code>ky</code> where <code>(kx, ky)</code> denotes the position of the knight, and a 2D array <code>positions</code> where <code>positions[i] = [x<sub>i</sub>, y<sub>i</su... | 0 | {
"code": "int a[50][50][50][50];\nbool flag=false;\nint dx[8]={-1,1,-2,2,-2,2,-1,1};\nint dy[8]={-2,-2,-1,-1,1,1,2,2};\nvoid helper1(int i,int j){\n queue<pair<int,pair<int,int>>>pq;\n pq.push({i,{j,0}});\n a[i][j][i][j]=0;\n while(pq.size()!=0){\n int l=(pq.front()).first;\n int r=(pq.fron... |
3,560 | <p>There is a <code>50 x 50</code> chessboard with <strong>one</strong> knight and some pawns on it. You are given two integers <code>kx</code> and <code>ky</code> where <code>(kx, ky)</code> denotes the position of the knight, and a 2D array <code>positions</code> where <code>positions[i] = [x<sub>i</sub>, y<sub>i</su... | 0 | {
"code": "int dp[2][16][(1<<16)]; \nint dp2[50][50][50][50];\n vector<pair<int, int>> moves = {\n {2, 1}, {2, -1}, {-2, 1}, {-2, -1},\n {1, 2}, {1, -2}, {-1, 2}, {-1, -2}\n};\nclass Solution {\npublic:\n int rec2(int x1,int y1, int x2,int y2){\n if(dp2[x1][y1][x2][y2]!=-1)return dp2[x1][y1][x2][y2... |
3,560 | <p>There is a <code>50 x 50</code> chessboard with <strong>one</strong> knight and some pawns on it. You are given two integers <code>kx</code> and <code>ky</code> where <code>(kx, ky)</code> denotes the position of the knight, and a 2D array <code>positions</code> where <code>positions[i] = [x<sub>i</sub>, y<sub>i</su... | 0 | {
"code": "int dist[50][50][50][50];\nint memo[1 << 15][51][2];\n\nclass Solution {\npublic:\n \n int solve(int x, int y, vector<vector<int>> &pos, int mask, int last, int maximize) {\n if (memo[mask][last][maximize] != -1) return memo[mask][last][maximize];\n \n int n = pos.size();\n ... |
3,560 | <p>There is a <code>50 x 50</code> chessboard with <strong>one</strong> knight and some pawns on it. You are given two integers <code>kx</code> and <code>ky</code> where <code>(kx, ky)</code> denotes the position of the knight, and a 2D array <code>positions</code> where <code>positions[i] = [x<sub>i</sub>, y<sub>i</su... | 0 | {
"code": "#include <vector>\n#include <queue>\n#include <tuple>\n#include <algorithm>\n#include <cstring>\n#include <functional>\n\nclass Solution {\npublic:\n const int dx[8] = {2, 2, -1, -1, 1, 1, -2, -2};\n const int dy[8] = {-1, 1, 2, -2, 2, -2, 1, -1};\n \n // BFS function to calculate the shortest ... |
3,560 | <p>There is a <code>50 x 50</code> chessboard with <strong>one</strong> knight and some pawns on it. You are given two integers <code>kx</code> and <code>ky</code> where <code>(kx, ky)</code> denotes the position of the knight, and a 2D array <code>positions</code> where <code>positions[i] = [x<sub>i</sub>, y<sub>i</su... | 1 | {
"code": "vector<int> X = {2 , 2 , -2 , -2 , 1 , 1 , -1 , -1 } ;\nvector<int> Y = {1 ,-1 , 1 , -1 , 2 , -2 , 2 , -2 } ;\nint Dist[50][50][50][50] ;\n\nclass Solution {\n\n void bfs( int sx , int sy ){\n\n queue<pair<int,int>> q ;\n\n q.push({sx , sy}) ;\n Dist[sx][sy][sx][sy] = 0 ;\n\n ... |
3,560 | <p>There is a <code>50 x 50</code> chessboard with <strong>one</strong> knight and some pawns on it. You are given two integers <code>kx</code> and <code>ky</code> where <code>(kx, ky)</code> denotes the position of the knight, and a 2D array <code>positions</code> where <code>positions[i] = [x<sub>i</sub>, y<sub>i</su... | 1 | {
"code": "int minMoves[50][50][50][50];\nclass Solution {\npublic:\n unordered_map<int, int> dp[50][50];\n int calcMoves(int x, int y, vector<vector<int>>& positions, int done) {\n if (dp[x][y].find(done) != dp[x][y].end())\n return dp[x][y][done];\n if (done + 1 == (1 << positions.siz... |
3,560 | <p>There is a <code>50 x 50</code> chessboard with <strong>one</strong> knight and some pawns on it. You are given two integers <code>kx</code> and <code>ky</code> where <code>(kx, ky)</code> denotes the position of the knight, and a 2D array <code>positions</code> where <code>positions[i] = [x<sub>i</sub>, y<sub>i</su... | 1 | {
"code": "#include <vector>\n#include <queue>\n#include <algorithm>\nusing namespace std;\n\nclass Solution {\npublic:\n // Direction vectors for knight's 8 possible moves\n vector<pair<int, int>> directions = {{2, 1}, {2, -1}, {-2, 1}, {-2, -1},\n {1, 2}, {1, -2}, {-1, ... |
3,560 | <p>There is a <code>50 x 50</code> chessboard with <strong>one</strong> knight and some pawns on it. You are given two integers <code>kx</code> and <code>ky</code> where <code>(kx, ky)</code> denotes the position of the knight, and a 2D array <code>positions</code> where <code>positions[i] = [x<sub>i</sub>, y<sub>i</su... | 1 | {
"code": "#include <vector>\n#include <queue>\n#include <algorithm>\nusing namespace std;\n\nclass Solution {\npublic:\n // Direction vectors for knight's 8 possible moves\n vector<pair<int, int>> directions = {{2, 1}, {2, -1}, {-2, 1}, {-2, -1},\n {1, 2}, {1, -2}, {-1, ... |
3,560 | <p>There is a <code>50 x 50</code> chessboard with <strong>one</strong> knight and some pawns on it. You are given two integers <code>kx</code> and <code>ky</code> where <code>(kx, ky)</code> denotes the position of the knight, and a 2D array <code>positions</code> where <code>positions[i] = [x<sub>i</sub>, y<sub>i</su... | 1 | {
"code": "#define INF 1e9\n#define F first\n#define S second\nvector<vector<int>> min_moves[51][51];\nint dp[16][2][100001];\nbool done = false;\nusing state = pair<int,int>;\nint dr[8] = {-1,-1,-2,-2, 1, 1, 2,2};\nint dc[8] = {-2, 2,-1, 1,-2, 2,-1,1};\n\nclass Solution {\npublic:\n vector<vector<int>> bfs(int sr... |
3,560 | <p>There is a <code>50 x 50</code> chessboard with <strong>one</strong> knight and some pawns on it. You are given two integers <code>kx</code> and <code>ky</code> where <code>(kx, ky)</code> denotes the position of the knight, and a 2D array <code>positions</code> where <code>positions[i] = [x<sub>i</sub>, y<sub>i</su... | 1 | {
"code": "class Solution {\n const int INF = (int)(1e9);\n const vector<int> dy = { -2, -1, 1, 2, 2, 1, -1, -2 }, dx = { 1, 2, 2, 1, -1, -2, -2, -1 };\npublic:\n int maxMoves(int kx, int ky, vector<vector<int>>& positions) {\n int n = positions.size(), m = 50;\n positions.push_back({ kx, ky })... |
3,560 | <p>There is a <code>50 x 50</code> chessboard with <strong>one</strong> knight and some pawns on it. You are given two integers <code>kx</code> and <code>ky</code> where <code>(kx, ky)</code> denotes the position of the knight, and a 2D array <code>positions</code> where <code>positions[i] = [x<sub>i</sub>, y<sub>i</su... | 1 | {
"code": "int dist[50][50][50][50];\nint dx[8]={1,1,2,2,-1,-1,-2,-2};\nint dy[8]={2,-2,1,-1,2,-2,1,-1};\nvoid dis(int start_x,int start_y){\n queue<pair<int,pair<int,int>>> q;\n q.push({start_x,{start_y,0}});\n dist[start_x][start_y][start_x][start_y]=0;\n while(!q.empty()){\n auto top=q.front();\... |
3,560 | <p>There is a <code>50 x 50</code> chessboard with <strong>one</strong> knight and some pawns on it. You are given two integers <code>kx</code> and <code>ky</code> where <code>(kx, ky)</code> denotes the position of the knight, and a 2D array <code>positions</code> where <code>positions[i] = [x<sub>i</sub>, y<sub>i</su... | 1 | {
"code": "class Solution {\npublic:\n int maxMoves(int kx, int ky, vector<vector<int>>& positions) {\n const int B = 50;\n int n = positions.size();\n // position n = knight\n vector<vector<int>> d(n+1, vector<int>(B*B, -1));\n\n auto getCoord = [](int x, int y) -> int{\n ... |
3,560 | <p>There is a <code>50 x 50</code> chessboard with <strong>one</strong> knight and some pawns on it. You are given two integers <code>kx</code> and <code>ky</code> where <code>(kx, ky)</code> denotes the position of the knight, and a 2D array <code>positions</code> where <code>positions[i] = [x<sub>i</sub>, y<sub>i</su... | 1 | {
"code": "class Solution {\npublic:\n int N; // Number of positions (pawns + knight)\n int dist[16][16]; // Distance matrix\n int dp_cache[16][1 << 15][2]; // DP memoization cache\n vector<pair<int, int>> positions; // Positions (knight start + pawns)\n unordered_map<int, int> pos_idx; // Position to ... |
3,560 | <p>There is a <code>50 x 50</code> chessboard with <strong>one</strong> knight and some pawns on it. You are given two integers <code>kx</code> and <code>ky</code> where <code>(kx, ky)</code> denotes the position of the knight, and a 2D array <code>positions</code> where <code>positions[i] = [x<sub>i</sub>, y<sub>i</su... | 1 | {
"code": "#include<bits/stdc++.h>\nusing namespace std;\n\nclass Solution {\npublic:\n int n;\n vector<pair<int, int>> pos;\n int distance_matrix[16][16];\n int memo_table[16][1<<15][2];\n \n int kx, ky;\n vector<vector<int>> positions;\n \n int dx[8] = {1,2,2,1,-1,-2,-2,-1};\n int dy[8... |
3,560 | <p>There is a <code>50 x 50</code> chessboard with <strong>one</strong> knight and some pawns on it. You are given two integers <code>kx</code> and <code>ky</code> where <code>(kx, ky)</code> denotes the position of the knight, and a 2D array <code>positions</code> where <code>positions[i] = [x<sub>i</sub>, y<sub>i</su... | 1 | {
"code": " \n\nclass Solution { \npublic:\n// Directions for knight moves\nint dirs[8][2] = {{2,1}, {2,-1}, {-2,1}, {-2,-1}, {1,2}, {1,-2}, {-1,2}, {-1,-2}};\n\n// Function to calculate the minimum moves from (kx, ky) to all positions using BFS\nvoid bfs(int startX, int startY, int index, int** dist, vector<pair<int... |
3,560 | <p>There is a <code>50 x 50</code> chessboard with <strong>one</strong> knight and some pawns on it. You are given two integers <code>kx</code> and <code>ky</code> where <code>(kx, ky)</code> denotes the position of the knight, and a 2D array <code>positions</code> where <code>positions[i] = [x<sub>i</sub>, y<sub>i</su... | 1 | {
"code": "class Solution {\npublic:\n int dx[8] = {1,2,2,1,-1,-2,-2,-1};\n int dy[8] = {2,1,-1,-2,-2,-1,1,2};\n int dp[16][(1<<16)][2];\n\n int rec(int prev, int mask, int turn, vector<vector<int>>&vec ,vector<vector<int>>& positions ){\n \n int l = positions.size();\n if(mask == (1... |
3,560 | <p>There is a <code>50 x 50</code> chessboard with <strong>one</strong> knight and some pawns on it. You are given two integers <code>kx</code> and <code>ky</code> where <code>(kx, ky)</code> denotes the position of the knight, and a 2D array <code>positions</code> where <code>positions[i] = [x<sub>i</sub>, y<sub>i</su... | 2 | {
"code": "class Solution {\npublic:\n\n vector<vector<int>>directions={\n\n {-2, -1}, {-2, 1},\n \n {-1, -2}, {1, -2},\n\n {-1, 2}, {1, 2},\n\n {2, -1}, {2, 1}\n }; \n\n int solve(int kx, int ky, int idx, vector<vector<int>>& mindist,\n int n, bool alice, int mask, int ... |
3,560 | <p>There is a <code>50 x 50</code> chessboard with <strong>one</strong> knight and some pawns on it. You are given two integers <code>kx</code> and <code>ky</code> where <code>(kx, ky)</code> denotes the position of the knight, and a 2D array <code>positions</code> where <code>positions[i] = [x<sub>i</sub>, y<sub>i</su... | 2 | {
"code": "class Solution {\npublic:\n\n vector<vector<int>>directions={\n\n {-2, -1}, {-2, 1},\n \n {-1, -2}, {1, -2},\n\n {-1, 2}, {1, 2},\n\n {2, -1}, {2, 1}\n }; \n\n int solve(int kx, int ky, int idx, vector<vector<int>>& mindist,\n int n, bool alice, int mask, int ... |
3,560 | <p>There is a <code>50 x 50</code> chessboard with <strong>one</strong> knight and some pawns on it. You are given two integers <code>kx</code> and <code>ky</code> where <code>(kx, ky)</code> denotes the position of the knight, and a 2D array <code>positions</code> where <code>positions[i] = [x<sub>i</sub>, y<sub>i</su... | 2 | {
"code": "class Solution {\npublic:\n \n int dpm[17][17];\n int dp[17][2<<16];\n \n vector<vector<int>> dirs = {\n {1, -2}, \n {2, -1}, \n {2, 1}, \n {1, 2}, \n {-1, 2}, \n {-2, 1}, \n {-2, -1}, \n {-1, -2}, \n };\n \n void minMo... |
3,560 | <p>There is a <code>50 x 50</code> chessboard with <strong>one</strong> knight and some pawns on it. You are given two integers <code>kx</code> and <code>ky</code> where <code>(kx, ky)</code> denotes the position of the knight, and a 2D array <code>positions</code> where <code>positions[i] = [x<sub>i</sub>, y<sub>i</su... | 2 | {
"code": "class Solution {\npublic:\n const int N = 50;\n const int INF = 1e9;\n const int dx[8] = {-2, -1, 1, 2, 2, 1, -1, -2};\n const int dy[8] = {1, 2, 2, 1, -1, -2, -2, -1};\n\n // Precompute distances for all squares once using BFS from a starting position.\n vector<vector<int>> bfs(int kx, i... |
3,560 | <p>There is a <code>50 x 50</code> chessboard with <strong>one</strong> knight and some pawns on it. You are given two integers <code>kx</code> and <code>ky</code> where <code>(kx, ky)</code> denotes the position of the knight, and a 2D array <code>positions</code> where <code>positions[i] = [x<sub>i</sub>, y<sub>i</su... | 2 | {
"code": "#include <bits/stdc++.h>\n#define sz size()\n#define bk back()\n#define fi first\n#define se second\n\nusing namespace std;\ntypedef long long ll;\ntypedef pair<int, int> pii;\n\nclass Solution {\n vector<int> dx = {1, 2, 1, 2, -1, -2, -1, -2};\n vector<int> dy = {2, 1, -2, -1, 2, 1, -2, -1};\n\n pu... |
3,560 | <p>There is a <code>50 x 50</code> chessboard with <strong>one</strong> knight and some pawns on it. You are given two integers <code>kx</code> and <code>ky</code> where <code>(kx, ky)</code> denotes the position of the knight, and a 2D array <code>positions</code> where <code>positions[i] = [x<sub>i</sub>, y<sub>i</su... | 2 | {
"code": "class Solution {\npublic:\n int maxMoves(int kx, int ky, vector<vector<int>>& positions) {\n int n = positions.size(); \n vector<vector<int>> dist(n+1, vector<int>(n+1)), dir = {{-2, -1}, {-2, 1}, {-1, -2}, {-1, 2}, {1, -2},{1, 2}, {2, -1}, {2, 1}}; \n positions.push_back({kx, ky});... |
3,560 | <p>There is a <code>50 x 50</code> chessboard with <strong>one</strong> knight and some pawns on it. You are given two integers <code>kx</code> and <code>ky</code> where <code>(kx, ky)</code> denotes the position of the knight, and a 2D array <code>positions</code> where <code>positions[i] = [x<sub>i</sub>, y<sub>i</su... | 2 | {
"code": "class Solution {\npublic:\n int maxMoves(int kx, int ky, vector<vector<int>>& positions) {\n // Total number of positions (knight + pawns)\n int N = positions.size();\n positions.insert(positions.begin(), {kx, ky}); // positions[0] is the knight's starting position\n N++; // ... |
3,560 | <p>There is a <code>50 x 50</code> chessboard with <strong>one</strong> knight and some pawns on it. You are given two integers <code>kx</code> and <code>ky</code> where <code>(kx, ky)</code> denotes the position of the knight, and a 2D array <code>positions</code> where <code>positions[i] = [x<sub>i</sub>, y<sub>i</su... | 2 | {
"code": "class Solution {\npublic:\n int maxMoves(int kx, int ky, vector<vector<int>>& positions) {\n return maxMoves_DFS(kx, ky, positions);\n }\n\n int maxMoves_DFS(int kx, int ky, vector<vector<int>>& positions) {\n auto getCode = [this](const vector<int>& pos) -> int { return pos[1] * N +... |
3,560 | <p>There is a <code>50 x 50</code> chessboard with <strong>one</strong> knight and some pawns on it. You are given two integers <code>kx</code> and <code>ky</code> where <code>(kx, ky)</code> denotes the position of the knight, and a 2D array <code>positions</code> where <code>positions[i] = [x<sub>i</sub>, y<sub>i</su... | 2 | {
"code": "#include <bits/stdc++.h>\n#define sz size()\n#define bk back()\n#define fi first\n#define se second\n\nusing namespace std;\ntypedef long long ll;\ntypedef pair<int, int> pii;\n\nclass Solution {\n\n public:\n int maxMoves(int sx, int sy, vector<vector<int>> &positions) {\n vector<int> dx = {1, ... |
3,560 | <p>There is a <code>50 x 50</code> chessboard with <strong>one</strong> knight and some pawns on it. You are given two integers <code>kx</code> and <code>ky</code> where <code>(kx, ky)</code> denotes the position of the knight, and a 2D array <code>positions</code> where <code>positions[i] = [x<sub>i</sub>, y<sub>i</su... | 2 | {
"code": "class Solution {\npublic:\n int N;\n vector<vector<vector<int>>> dp;\n int dx[8] = {2, 2, -2, -2, 1, -1, 1, -1};\n int dy[8] = {1, -1, -1, 1, 2, 2, -2, -2};\n int rec(int t, int x, int y, int ind, vector<vector<int>> &p, int mask, vector<vector<vector<int>>> &dis) {\n if( mask == (1 <... |
3,560 | <p>There is a <code>50 x 50</code> chessboard with <strong>one</strong> knight and some pawns on it. You are given two integers <code>kx</code> and <code>ky</code> where <code>(kx, ky)</code> denotes the position of the knight, and a 2D array <code>positions</code> where <code>positions[i] = [x<sub>i</sub>, y<sub>i</su... | 2 | {
"code": "class Solution {\n static constexpr array<array<int,2>,8> dirs{{{-1, -2}, {-2,-1}, {1,-2}, {2,-1}, {2, 1}, {1,2}, {-1,2}, {-2, 1}}};\npublic:\n int maxMoves(int kx, int ky, vector<vector<int>>& positions) {\n // calculate min moves from each positions to other positions\n\n positions.pu... |
3,560 | <p>There is a <code>50 x 50</code> chessboard with <strong>one</strong> knight and some pawns on it. You are given two integers <code>kx</code> and <code>ky</code> where <code>(kx, ky)</code> denotes the position of the knight, and a 2D array <code>positions</code> where <code>positions[i] = [x<sub>i</sub>, y<sub>i</su... | 2 | {
"code": "class Solution {\n static constexpr array<array<int,2>,8> dirs{{{-1, -2}, {-2,-1}, {1,-2}, {2,-1}, {2, 1}, {1,2}, {-1,2}, {-2, 1}}};\npublic:\n int maxMoves(int kx, int ky, vector<vector<int>>& positions) {\n // calculate min moves from each positions to other positions\n\n positions.pu... |
3,560 | <p>There is a <code>50 x 50</code> chessboard with <strong>one</strong> knight and some pawns on it. You are given two integers <code>kx</code> and <code>ky</code> where <code>(kx, ky)</code> denotes the position of the knight, and a 2D array <code>positions</code> where <code>positions[i] = [x<sub>i</sub>, y<sub>i</su... | 2 | {
"code": "static constexpr int diffs[8][2] = \n{\n {1, 2}, {2, 1}, {2, -1}, {1, -2},\n {-1, 2}, {-2, 1}, {-2, -1}, {-1, -2}\n};\n\nstatic int visited[50][50];\n// static int moves2[15];\n\nstatic int pre_cpt_moves[50][50][50][50];\n\nstatic void one_bfs(int x, int y)\n{\n const int x0 = x;\n const int... |
3,560 | <p>There is a <code>50 x 50</code> chessboard with <strong>one</strong> knight and some pawns on it. You are given two integers <code>kx</code> and <code>ky</code> where <code>(kx, ky)</code> denotes the position of the knight, and a 2D array <code>positions</code> where <code>positions[i] = [x<sub>i</sub>, y<sub>i</su... | 2 | {
"code": "/*\n! 这道题学到很多东西:\n1) ! 如果用LINE1的全局的moves2而不是每个DFS call都有一个单独的moves,\n ! 则会不同call stack会有干扰互相影响;\n2) ! legacy_get_moves会TLE,不如先pre compute任意起点到任意终点\n ! 的移动数,可以避免legacy_get_moves中的重复计算;\n3) ! last_eliminate_pos_idx也是要cache要考虑的啊,\n ! 不然cache的key不对,没有unique\n*/\n\nstatic constexpr int diffs[8][2] = \n{\n... |
3,560 | <p>There is a <code>50 x 50</code> chessboard with <strong>one</strong> knight and some pawns on it. You are given two integers <code>kx</code> and <code>ky</code> where <code>(kx, ky)</code> denotes the position of the knight, and a 2D array <code>positions</code> where <code>positions[i] = [x<sub>i</sub>, y<sub>i</su... | 2 | {
"code": "class Solution {\npublic:\n int maxMoves(int kx, int ky, vector<vector<int>>& positions) {\n positions.push_back({kx, ky});\n \n vector<unordered_map<string, int>> dp(positions.size());\n\n // 0 means not killed and 1 means killed\n string state(positions.size(), '0');... |
3,560 | <p>There is a <code>50 x 50</code> chessboard with <strong>one</strong> knight and some pawns on it. You are given two integers <code>kx</code> and <code>ky</code> where <code>(kx, ky)</code> denotes the position of the knight, and a 2D array <code>positions</code> where <code>positions[i] = [x<sub>i</sub>, y<sub>i</su... | 2 | {
"code": "\nconst int dx[8] = {-2, -2, -1, -1, 1, 1, 2, 2};\nconst int dy[8] = {1, -1, 2, -2, 2, -2, 1, -1};\nconst int inf = 1e9;\nbool ckmin(auto& a, auto b) { return b < a ? a = b, 1 : 0; }\nbool ckmax(auto& a, auto b) { return b > a ? a = b, 1 : 0; }\n\nclass Solution {\n public:\n int maxMoves(int kx, int ky, ... |
3,560 | <p>There is a <code>50 x 50</code> chessboard with <strong>one</strong> knight and some pawns on it. You are given two integers <code>kx</code> and <code>ky</code> where <code>(kx, ky)</code> denotes the position of the knight, and a 2D array <code>positions</code> where <code>positions[i] = [x<sub>i</sub>, y<sub>i</su... | 2 | {
"code": "class Solution {\npublic:\n int maxMoves(int kx, int ky, vector<vector<int>>& positions) {\n int N = positions.size();\n vector<pair<int, int>> pos; // positions including initial knight position\n pos.emplace_back(kx, ky); // index 0\n for (auto& p : positions) {\n ... |
3,560 | <p>There is a <code>50 x 50</code> chessboard with <strong>one</strong> knight and some pawns on it. You are given two integers <code>kx</code> and <code>ky</code> where <code>(kx, ky)</code> denotes the position of the knight, and a 2D array <code>positions</code> where <code>positions[i] = [x<sub>i</sub>, y<sub>i</su... | 2 | {
"code": "vector<vector<int> > dis;\nbool isInit = false;\nclass Solution {\npublic:\n void init(){\n isInit = true;\n dis.resize(2500, vector<int>(2500, 1e9));\n auto check = [](int x, int y) -> bool{\n if(x<0 || y<0 || x>=50 || y>=50)return false;\n return true;\n ... |
3,560 | <p>There is a <code>50 x 50</code> chessboard with <strong>one</strong> knight and some pawns on it. You are given two integers <code>kx</code> and <code>ky</code> where <code>(kx, ky)</code> denotes the position of the knight, and a 2D array <code>positions</code> where <code>positions[i] = [x<sub>i</sub>, y<sub>i</su... | 2 | {
"code": "class Solution {\npublic:\n std::vector<std::vector<int>> directions = {\n {-2, 1}, {-1, 2}, {1, 2}, {2, 1},\n {2, -1}, {1, -2}, {-1, -2}, {-2, -1}\n };\n vector<vector<vector<int>>>dist;\n map<array<int,3>, int> dp;\n using ii = pair<int,int>;\n void calcDist(int id... |
3,560 | <p>There is a <code>50 x 50</code> chessboard with <strong>one</strong> knight and some pawns on it. You are given two integers <code>kx</code> and <code>ky</code> where <code>(kx, ky)</code> denotes the position of the knight, and a 2D array <code>positions</code> where <code>positions[i] = [x<sub>i</sub>, y<sub>i</su... | 2 | {
"code": "class Solution {\npublic:\n vector<vector<unordered_map<int, int>>>dp;\n int delr[8] = {-2, -2, -1, 1, 2, 2, 1, -1};\n int delc[8] = {-1, 1, 2, 2, 1, -1, -2, -2};\n \n void bfs(vector<vector<int>>& positions, int ind, vector<vector<int>>& dist){\n int n = positions.size();\n ve... |
3,560 | <p>There is a <code>50 x 50</code> chessboard with <strong>one</strong> knight and some pawns on it. You are given two integers <code>kx</code> and <code>ky</code> where <code>(kx, ky)</code> denotes the position of the knight, and a 2D array <code>positions</code> where <code>positions[i] = [x<sub>i</sub>, y<sub>i</su... | 2 | {
"code": "class Solution {\npublic:\n map<pair<pair<int,int >, pair<int,int > >,int> E;\n map<pair<pair<int,int>,int>,int> mem;\n\n bool valid(int x,int y)\n {\n if(x>=0 && x<50 && y>=0 && y<50)\n return true;\n return false;\n }\n\n void bfs(pair<int,int> source, int kx, i... |
3,560 | <p>There is a <code>50 x 50</code> chessboard with <strong>one</strong> knight and some pawns on it. You are given two integers <code>kx</code> and <code>ky</code> where <code>(kx, ky)</code> denotes the position of the knight, and a 2D array <code>positions</code> where <code>positions[i] = [x<sub>i</sub>, y<sub>i</su... | 2 | {
"code": "class Solution {\npublic:\n map<pair<pair<int,int >, pair<int,int > >,int> E;\n map<pair<pair<int,int>,int>,int> mem;\n\n bool valid(int x,int y)\n {\n if(x>=0 && x<50 && y>=0 && y<50)\n return true;\n return false;\n }\n\n void bfs(pair<int,int> source, int kx, i... |
3,560 | <p>There is a <code>50 x 50</code> chessboard with <strong>one</strong> knight and some pawns on it. You are given two integers <code>kx</code> and <code>ky</code> where <code>(kx, ky)</code> denotes the position of the knight, and a 2D array <code>positions</code> where <code>positions[i] = [x<sub>i</sub>, y<sub>i</su... | 2 | {
"code": "class Solution {\npublic:\nint dp[17][1 << (15)];\nvector<vector<int>> directions = {{2, 1}, {2, -1}, {-2, 1}, {-2, -1}, {1, 2}, {1, -2}, {-1, 2}, {-1, -2}};\nvoid fillMinDist(vector<vector<int>> &minDist,int x,int y,int idx,int n,vector<vector<int>>& positions){\n vector<vector<int>> dist(50,vector<in... |
3,560 | <p>There is a <code>50 x 50</code> chessboard with <strong>one</strong> knight and some pawns on it. You are given two integers <code>kx</code> and <code>ky</code> where <code>(kx, ky)</code> denotes the position of the knight, and a 2D array <code>positions</code> where <code>positions[i] = [x<sub>i</sub>, y<sub>i</su... | 2 | {
"code": "#include <bits/stdc++.h>\nusing namespace std;\n#define dbg(...) __f(#__VA_ARGS__,__VA_ARGS__)\n// trace std::pair\ntemplate<class L,class R> std::ostream& operator<<(std::ostream& os,std::pair<L,R>& P){\n return os<<\"{\"<<P.first<<\":\"<<P.second<<\"}\";\n}\n// trace std::vector\ntemplate<class T> std... |
3,560 | <p>There is a <code>50 x 50</code> chessboard with <strong>one</strong> knight and some pawns on it. You are given two integers <code>kx</code> and <code>ky</code> where <code>(kx, ky)</code> denotes the position of the knight, and a 2D array <code>positions</code> where <code>positions[i] = [x<sub>i</sub>, y<sub>i</su... | 2 | {
"code": "int min_moves[50][50][50][50]; // 4D array to store distances between all pairs of points on the board\n int dx[8] = {1, 2, 2, 1, -1, -2, -2, -1}; // Possible moves in x-direction for a knight\n int dy[8] = {2, 1, -1, -2, -2, -1, 1, 2}; // Possible moves in y-direction for a knight\n\nclass Solution ... |
3,560 | <p>There is a <code>50 x 50</code> chessboard with <strong>one</strong> knight and some pawns on it. You are given two integers <code>kx</code> and <code>ky</code> where <code>(kx, ky)</code> denotes the position of the knight, and a 2D array <code>positions</code> where <code>positions[i] = [x<sub>i</sub>, y<sub>i</su... | 2 | {
"code": "class Solution {\npublic:\n vector<pair<int,int>> par = {{2,1},{2,-1},{-2,1},{-2,-1},{1,2},{1,-2},{-1,2},{-1,-2}};\n bool isValid(int i, int j){\n return i>=0 && j>=0 && i<50 && j<50;\n }\n vector<vector<int>> findbfs(int i, int j){\n vector<vector<int>>dis(50,vector<int>(50,1e9))... |
3,560 | <p>There is a <code>50 x 50</code> chessboard with <strong>one</strong> knight and some pawns on it. You are given two integers <code>kx</code> and <code>ky</code> where <code>(kx, ky)</code> denotes the position of the knight, and a 2D array <code>positions</code> where <code>positions[i] = [x<sub>i</sub>, y<sub>i</su... | 2 | {
"code": "#define gc getchar_unlocked\n#define fo(i, n) for (i = 0; i < n; i++)\n#define Fo(i, k, n) for (i = k; k < n ? i < n : i > n; k < n ? i += 1 : i -= 1)\n#define ll int\n#define si(x) scanf(\"%d\", &x)\n#define sl(x) scanf(\"%lld\", &x)\n#define ss(s) scanf(\"%s\", s)\n#define pi(x) printf(\"%d\\n\", x)\n#de... |
3,560 | <p>There is a <code>50 x 50</code> chessboard with <strong>one</strong> knight and some pawns on it. You are given two integers <code>kx</code> and <code>ky</code> where <code>(kx, ky)</code> denotes the position of the knight, and a 2D array <code>positions</code> where <code>positions[i] = [x<sub>i</sub>, y<sub>i</su... | 2 | {
"code": "class Solution {\npublic:\nint dx[8] = {-2, -1, 1, 2, 2, 1, -1, -2};\nint dy[8] = {1, 2, 2, 1, -1, -2, -2, -1};\nvector<vector<int>> bfs(int sx, int sy) {\n vector<vector<int>> dist(50, vector<int>(50, 1e8));\n queue<pair<int, int>> q;\n dist[sx][sy] = 0;\n q.push({sx, sy});\n while (!q.empt... |
3,560 | <p>There is a <code>50 x 50</code> chessboard with <strong>one</strong> knight and some pawns on it. You are given two integers <code>kx</code> and <code>ky</code> where <code>(kx, ky)</code> denotes the position of the knight, and a 2D array <code>positions</code> where <code>positions[i] = [x<sub>i</sub>, y<sub>i</su... | 2 | {
"code": "#include <vector>\n#include <queue>\n#include <algorithm>\n#include <cmath>\n#include <unordered_map>\nusing namespace std;\n\nclass Solution {\n vector<pair<int, int>> knightMoves = {{2, 1}, {2, -1}, {-2, 1}, {-2, -1},\n {1, 2}, {1, -2}, {-1, 2}, {-1, -2}};\n ... |
3,560 | <p>There is a <code>50 x 50</code> chessboard with <strong>one</strong> knight and some pawns on it. You are given two integers <code>kx</code> and <code>ky</code> where <code>(kx, ky)</code> denotes the position of the knight, and a 2D array <code>positions</code> where <code>positions[i] = [x<sub>i</sub>, y<sub>i</su... | 2 | {
"code": "/*\n\tName :- Tafheem Ahemad\n*/\n#include<bits/stdc++.h>\n#include<ext/pb_ds/assoc_container.hpp>\n#include<ext/pb_ds/tree_policy.hpp>\nusing namespace std;\nusing namespace __gnu_pbds;\n#define ll long long int\n#define ld long double\n#define F first\n#define S second\nconst int MOD=998244353;\n#define ... |
3,560 | <p>There is a <code>50 x 50</code> chessboard with <strong>one</strong> knight and some pawns on it. You are given two integers <code>kx</code> and <code>ky</code> where <code>(kx, ky)</code> denotes the position of the knight, and a 2D array <code>positions</code> where <code>positions[i] = [x<sub>i</sub>, y<sub>i</su... | 2 | {
"code": "int dp[16][1<<15][2];\nclass Solution {\npublic:\n int row[8] = {-1,-2,-2,-1,1,2,2,1};\n int col[8] = {-2,-1,1,2,2,1,-1,-2};\n int helper(vector<vector<vector<int>>> &dist,int prev,int mask,int &n,int role,vector<vector<int>>& positions,int &r,int &c){\n if(mask==((1<<n) - 1)) return 0;\n ... |
3,560 | <p>There is a <code>50 x 50</code> chessboard with <strong>one</strong> knight and some pawns on it. You are given two integers <code>kx</code> and <code>ky</code> where <code>(kx, ky)</code> denotes the position of the knight, and a 2D array <code>positions</code> where <code>positions[i] = [x<sub>i</sub>, y<sub>i</su... | 2 | {
"code": "class Solution {\npublic:\n int dx[8]={2,2,1,1,-1,-1,-2,-2};\n int dy[8]={1,-1,2,-2,2,-2,1,-1};\n int fun(int i,int val,vector<vector<int>> &positions,vector<vector<vector<int>>> &dis,int p,vector<vector<int>> &dp){\n int n=positions.size(),ans;\n if(val==pow(2,n)-1){\n re... |
3,560 | <p>There is a <code>50 x 50</code> chessboard with <strong>one</strong> knight and some pawns on it. You are given two integers <code>kx</code> and <code>ky</code> where <code>(kx, ky)</code> denotes the position of the knight, and a 2D array <code>positions</code> where <code>positions[i] = [x<sub>i</sub>, y<sub>i</su... | 2 | {
"code": "class Solution {\n vector<vector<int>> directions={{2,1},{2,-1},{-2,1},{-2,-1},{1,2},{-1,2},{1,-2},{-1,-2}};\n vector<vector<int>> dp;\n void bfs(int x,int y,int ind,vector<vector<int>> &minDist,vector<vector<int>> &pos){\n vector<vector<int>> dis(50,vector<int>(50,-1));\n queue<pair... |
3,560 | <p>There is a <code>50 x 50</code> chessboard with <strong>one</strong> knight and some pawns on it. You are given two integers <code>kx</code> and <code>ky</code> where <code>(kx, ky)</code> denotes the position of the knight, and a 2D array <code>positions</code> where <code>positions[i] = [x<sub>i</sub>, y<sub>i</su... | 2 | {
"code": "class Solution {\npublic:\n vector<pair<int, int>> knightMoves = {{-2, -1}, {-2, 1}, {2, -1}, {2, 1},\n {-1, -2}, {1, -2}, {-1, 2}, {1, 2}};\n \n // BFS to calculate the minimum moves from (kx, ky) to (px, py)\n int bfs(int kx, int ky, int px, int py) {\... |
3,560 | <p>There is a <code>50 x 50</code> chessboard with <strong>one</strong> knight and some pawns on it. You are given two integers <code>kx</code> and <code>ky</code> where <code>(kx, ky)</code> denotes the position of the knight, and a 2D array <code>positions</code> where <code>positions[i] = [x<sub>i</sub>, y<sub>i</su... | 2 | {
"code": "class Solution {\npublic:\n int min_m[16][16];\n int calc(int src,int idx,vector<vector<int>>& pos)\n {\n queue<pair<int,int>>q;\n int x=pos[src][0];\n int y=pos[src][1];\n q.push({x,y});\n vector<vector<int>>moves={{-1,-2} ,{-2,-1} ,{-2,1} ,{-1,2} ,{1,2} , {2,1}... |
3,560 | <p>There is a <code>50 x 50</code> chessboard with <strong>one</strong> knight and some pawns on it. You are given two integers <code>kx</code> and <code>ky</code> where <code>(kx, ky)</code> denotes the position of the knight, and a 2D array <code>positions</code> where <code>positions[i] = [x<sub>i</sub>, y<sub>i</su... | 2 | {
"code": "class Solution {\npublic:\n int maxMoves(int kx, int ky, vector<vector<int>>& positions) {\n vector<pair<int, int>> knight = {{1,2}, {2,1}, {1,-2}, {-2,1}, {-1,2}, {2,-1}, {-1,-2}, {-2,-1}};\n \n auto bfs = [&](int i) {\n int x = positions[i][0], y = positions[i][1];\n ... |
3,560 | <p>There is a <code>50 x 50</code> chessboard with <strong>one</strong> knight and some pawns on it. You are given two integers <code>kx</code> and <code>ky</code> where <code>(kx, ky)</code> denotes the position of the knight, and a 2D array <code>positions</code> where <code>positions[i] = [x<sub>i</sub>, y<sub>i</su... | 2 | {
"code": "class Solution {\npublic:\n int dx[8] = {2, 2, -2, -2, 1, -1, 1, -1};\n int dy[8] = {1, -1, 1, -1, 2, 2, -2, -2};\n \n bool ok(int x, int y) {\n return x >= 0 && x < 50 && y >= 0 && y < 50;\n }\n \n int bfs(int xi, int yi, int xf, int yf) {\n bool vis[50][50] = {0};\n ... |
3,560 | <p>There is a <code>50 x 50</code> chessboard with <strong>one</strong> knight and some pawns on it. You are given two integers <code>kx</code> and <code>ky</code> where <code>(kx, ky)</code> denotes the position of the knight, and a 2D array <code>positions</code> where <code>positions[i] = [x<sub>i</sub>, y<sub>i</su... | 2 | {
"code": "class Solution {\npublic:\n vector<vector<int>> dir={{2,1},{2,-1},{-2,1},{-2,-1},{1,2},{1,-2},{-1,2},{-1,-2}}; \n int maxMoves(int kx, int ky, vector<vector<int>>& positions) {\n vector<vector<int>> visited(50,vector<int>(50,0));\n int n=positions.size();\n vector<vector<vector<i... |
3,560 | <p>There is a <code>50 x 50</code> chessboard with <strong>one</strong> knight and some pawns on it. You are given two integers <code>kx</code> and <code>ky</code> where <code>(kx, ky)</code> denotes the position of the knight, and a 2D array <code>positions</code> where <code>positions[i] = [x<sub>i</sub>, y<sub>i</su... | 2 | {
"code": "\nclass Solution {\npublic:\n int dp[15][(1<<15)][2];\n int dist[50][50][50][50];\n int bfs(int x1,int y1,int x2,int y2)\n {\n queue<pair<int,int>> q;\n q.push({x1,y1});\n vector<vector<int>> vis(50,vector<int> (50,-1));\n vis[x1][y1] = 0;\n int dx[] = { -2, -... |
3,560 | <p>There is a <code>50 x 50</code> chessboard with <strong>one</strong> knight and some pawns on it. You are given two integers <code>kx</code> and <code>ky</code> where <code>(kx, ky)</code> denotes the position of the knight, and a 2D array <code>positions</code> where <code>positions[i] = [x<sub>i</sub>, y<sub>i</su... | 2 | {
"code": "class Solution {\npublic:\n int maxMoves(int kx, int ky, vector<vector<int>>& positions) {\n int n = positions.size();\n vector<vector<vector<int>>> dist(n, vector<vector<int>>(50, vector<int>(50, INT_MAX)));\n\n auto bfs = [&](int k) {\n int dirs[8][2] = {1, 2, 2, 1, -1,... |
3,560 | <p>There is a <code>50 x 50</code> chessboard with <strong>one</strong> knight and some pawns on it. You are given two integers <code>kx</code> and <code>ky</code> where <code>(kx, ky)</code> denotes the position of the knight, and a 2D array <code>positions</code> where <code>positions[i] = [x<sub>i</sub>, y<sub>i</su... | 2 | {
"code": "int x[] = {1, 2, 1, 2, -1, -2, -1, -2};\nint y[] = {2, 1, -2, -1, 2, 1, -2, -1};\n\nclass Solution {\n int dp[80000][17];\n int shortest[17][17];\n int n;\n unordered_map<int, unordered_map<int, int>> um;\n\n void compute_from_A_to_B(int src_ind, vector<vector<int>>& P){\n vector<vect... |
3,560 | <p>There is a <code>50 x 50</code> chessboard with <strong>one</strong> knight and some pawns on it. You are given two integers <code>kx</code> and <code>ky</code> where <code>(kx, ky)</code> denotes the position of the knight, and a 2D array <code>positions</code> where <code>positions[i] = [x<sub>i</sub>, y<sub>i</su... | 2 | {
"code": "class Solution {\npublic:\n pair<int, int> dirs[8] = {{-2, -1}, {-2, 1}, {2, -1}, {2, 1}, {-1, 2}, {1, 2}, {-1, -2}, {1, -2}};\n int maxMoves(int kx, int ky, vector<vector<int>>& positions) {\n int state = 0;\n vector<unordered_map<int, int>> memo(2);\n unordered_map<int, int> me... |
3,560 | <p>There is a <code>50 x 50</code> chessboard with <strong>one</strong> knight and some pawns on it. You are given two integers <code>kx</code> and <code>ky</code> where <code>(kx, ky)</code> denotes the position of the knight, and a 2D array <code>positions</code> where <code>positions[i] = [x<sub>i</sub>, y<sub>i</su... | 2 | {
"code": "class Solution {\n const int dx[8] = {-2, -2, -1, -1, 1, 1, 2, 2};\n const int dy[8] = {-1, 1, -2, 2, -2, 2, -1, 1};\n\n int pawnCount; \n vector<vector<int>> dp; \n vector<vector<int>> distances; \n\n void calculateDistances(int kx, int ky, const vector<vector<int>>& positions) {\n ... |
3,560 | <p>There is a <code>50 x 50</code> chessboard with <strong>one</strong> knight and some pawns on it. You are given two integers <code>kx</code> and <code>ky</code> where <code>(kx, ky)</code> denotes the position of the knight, and a 2D array <code>positions</code> where <code>positions[i] = [x<sub>i</sub>, y<sub>i</su... | 2 | {
"code": "#define f first\n#define s second\n\nclass Solution {\npublic:\n\n using ll=long long;\n vector<vector<ll>> dist[50][50];\n ll dx[8]={1,1,-1,-1,2,2,-2,-2};\n ll dy[8]={2,-2,2,-2,1,-1,1,-1};\n bool done=false;\n ll dp[2][16][1LL<<15];\n vector<pair<ll,ll>> neigh(ll i,ll j)\n {\n ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.