output
stringlengths
52
181k
instruction
stringlengths
296
182k
#include <bits/stdc++.h> using namespace std; inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; } template <class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); } inline int readInt() { int x; scanf("%d", &x); return x; } const double E...
### Prompt Generate a CPP solution to the following problem: Furik and Rubik take part in a relay race. The race will be set up on a large square with the side of n meters. The given square is split into n × n cells (represented as unit squares), each cell has some number. At the beginning of the race Furik stands i...
#include <bits/stdc++.h> using namespace std; const double eps = 1e-5; const int inf = (1 << 31) - 1; const int hinf = 1000000000; const int mod = 1000000007; int dat[500][500]; int dp[305][305][305]; int dp2[305][305][305]; int main() { int n; scanf("%d", &n); for (int i = 1; i <= n; i++) for (int j = 1; j <...
### Prompt Develop a solution in CPP to the problem described below: Furik and Rubik take part in a relay race. The race will be set up on a large square with the side of n meters. The given square is split into n × n cells (represented as unit squares), each cell has some number. At the beginning of the race Furik ...
#include <bits/stdc++.h> using namespace std; const int N = 2e6; const long long mod = 1e9 + 7; const long long inf = 1e9; long long a[610][610], f[2][610][610]; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); cerr.tie(nullptr); int n; cin >> n; for (int i = 0; i <= 600...
### Prompt Please create a solution in Cpp to the following problem: Furik and Rubik take part in a relay race. The race will be set up on a large square with the side of n meters. The given square is split into n × n cells (represented as unit squares), each cell has some number. At the beginning of the race Furik ...
#include <bits/stdc++.h> using namespace std; int dp[0x12d * 2][0x12d][0x12d]; int v[0x12d][0x12d]; int max(int a, int b, int c, int d) { if (a < b) a = b; if (a < c) a = c; if (a < d) a = d; return a; } int main() { int N; cin >> N; for (int i = 1; i <= N; ++i) for (int j = 1; j <= N; ++j) scanf("%d"...
### Prompt Construct a cpp code solution to the problem outlined: Furik and Rubik take part in a relay race. The race will be set up on a large square with the side of n meters. The given square is split into n × n cells (represented as unit squares), each cell has some number. At the beginning of the race Furik sta...
#include <bits/stdc++.h> using namespace std; int a[307][307]; int f[607][307][307]; int moves[][4] = {{1, 0, 1, 0}, {1, 0, 0, 1}, {0, 1, 1, 0}, {0, 1, 0, 1}}; int main() { int n; cin >> n; for (int(i) = (int)(0); (i) < (int)(n); ++(i)) for (int(j) = (int)(0); (j) < (int)(n); ++(j)) cin >> a[i][j]; fill(&f[...
### Prompt In CPP, your task is to solve the following problem: Furik and Rubik take part in a relay race. The race will be set up on a large square with the side of n meters. The given square is split into n × n cells (represented as unit squares), each cell has some number. At the beginning of the race Furik stand...
#include <bits/stdc++.h> using namespace std; const int maxn = 305; const int maxint = 999999999; int dp[2][maxn][maxn]; int a[maxn][maxn]; int n; int main() { while (scanf("%d", &n) != EOF) { for (int i = 1; i <= n; i++) for (int j = 1; j <= n; j++) scanf("%d", &a[i][j]); dp[1][1][1] = a[1][1]; for...
### Prompt Your challenge is to write a CPP solution to the following problem: Furik and Rubik take part in a relay race. The race will be set up on a large square with the side of n meters. The given square is split into n × n cells (represented as unit squares), each cell has some number. At the beginning of the r...
#include <bits/stdc++.h> using namespace std; inline int ADD(int a, int b) { a += b; if (a >= 1000000007) a -= 1000000007; return (int)a; } inline void ADDTO(int &a, int b) { a += b; if (a >= 1000000007) a -= 1000000007; } inline void SUBTO(int &a, int b) { a -= b; if (a < 0) a += 1000000007; } inline int...
### Prompt Your challenge is to write a cpp solution to the following problem: Furik and Rubik take part in a relay race. The race will be set up on a large square with the side of n meters. The given square is split into n × n cells (represented as unit squares), each cell has some number. At the beginning of the r...
#include <bits/stdc++.h> using namespace std; int n; vector<vector<int> > v, dp; int main() { scanf("%d", &n); v.resize(n + 1, vector<int>(n + 1, 0)); dp.resize(n + 1, vector<int>(n + 1, -1000000007)); for (int i = 1; i <= n; ++i) { for (int j = 1; j <= n; ++j) scanf("%d", &v[i][j]); } dp[1][1] = v[1][1...
### Prompt Develop a solution in Cpp to the problem described below: Furik and Rubik take part in a relay race. The race will be set up on a large square with the side of n meters. The given square is split into n × n cells (represented as unit squares), each cell has some number. At the beginning of the race Furik ...
#include <bits/stdc++.h> using namespace std; int n, dp[301][301][301], vis[301][301][301], a[301][301]; int valid(int x, int y) { return (x >= 1 && x <= n && y >= 1 && y <= n); } int solve(int x1, int y1, int x2) { int y2 = x1 + y1 - x2; if (!valid(x1, y1) || !valid(x2, y2)) return -10000000; if (x1 == n && y1 =...
### Prompt Please create a solution in Cpp to the following problem: Furik and Rubik take part in a relay race. The race will be set up on a large square with the side of n meters. The given square is split into n × n cells (represented as unit squares), each cell has some number. At the beginning of the race Furik ...
#include <bits/stdc++.h> using namespace std; const int N = 305; int n, a[N][N], dp[N + N][N][N]; int rec(int x1, int y1, int x2, int y2) { if (x1 > n || y1 > n || x2 > n || y2 > n) return -(int)1e9; if (x1 == x2 && y1 == y2 && x1 == n && y1 == n) return a[n][n]; if (dp[x1 + y1][x1][x2] != -(int)1e9) return dp[x1...
### Prompt Construct a Cpp code solution to the problem outlined: Furik and Rubik take part in a relay race. The race will be set up on a large square with the side of n meters. The given square is split into n × n cells (represented as unit squares), each cell has some number. At the beginning of the race Furik sta...
#include <bits/stdc++.h> using namespace std; const long long inf = (long long)1e14; const double eps = 1e-10; const double pi = acos(-1.0); int a[305][610]; int dp[305][305][610]; int n; int main() { cin >> n; for (int i = 1; i <= n; i++) { for (int j = 1; j <= n; j++) { scanf("%d", &a[i][j + i]); } ...
### Prompt Please create a solution in Cpp to the following problem: Furik and Rubik take part in a relay race. The race will be set up on a large square with the side of n meters. The given square is split into n × n cells (represented as unit squares), each cell has some number. At the beginning of the race Furik ...
#include <bits/stdc++.h> #pragma comment(linker, "/STACK:200000000") using namespace std; template <typename T> inline T Abs(T x) { return (x >= 0) ? x : -x; } template <typename T> inline T sqr(T x) { return x * x; } const int INF = (int)1E9; const long long INF64 = (long long)1E18; const long double EPS = 1E-9; c...
### Prompt Please provide a Cpp coded solution to the problem described below: Furik and Rubik take part in a relay race. The race will be set up on a large square with the side of n meters. The given square is split into n × n cells (represented as unit squares), each cell has some number. At the beginning of the r...
#include <bits/stdc++.h> using namespace std; int dp[2][310][310], tab[310][310]; int n, k; int main() { int i, j, tem, mm; int be, fo; scanf("%d", &n); for (i = 1; i <= n; i++) for (j = 1; j <= n; j++) scanf("%d", &tab[i][j]); memset(dp, -16, sizeof(dp)); dp[0][0][0] = tab[1][1]; be = 0; for (k = 1...
### Prompt Construct a CPP code solution to the problem outlined: Furik and Rubik take part in a relay race. The race will be set up on a large square with the side of n meters. The given square is split into n × n cells (represented as unit squares), each cell has some number. At the beginning of the race Furik sta...
#include <bits/stdc++.h> using namespace std; const int N = 2e6; const long long mod = 1e9 + 7; const long long inf = 1e9; long long a[610][610], f[2][610][610]; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); cerr.tie(nullptr); int n; cin >> n; for (int i = 0; i <= 600...
### Prompt Please formulate a Cpp solution to the following problem: Furik and Rubik take part in a relay race. The race will be set up on a large square with the side of n meters. The given square is split into n × n cells (represented as unit squares), each cell has some number. At the beginning of the race Furik ...
#include <bits/stdc++.h> using namespace std; const long long inf = (long long)1e14; const double eps = 1e-10; const double pi = acos(-1.0); long long a[750][750]; long long dp[302][302][3]; int n; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n; for (int i = 1; i <= n; i++) { ...
### Prompt Your challenge is to write a cpp solution to the following problem: Furik and Rubik take part in a relay race. The race will be set up on a large square with the side of n meters. The given square is split into n × n cells (represented as unit squares), each cell has some number. At the beginning of the r...
#include <bits/stdc++.h> using namespace std; const long double EPS = 1e-8; const long double PI = 3.1415926535897932384626433832795; const long double E = 2.7182818284; const int INF = 1000000000; int main(void) { int n, i, j, g; cin >> n; int a[n][n]; for (int i = 0; i < int(n); i++) for (int j = 0; j < i...
### Prompt Please formulate a Cpp solution to the following problem: Furik and Rubik take part in a relay race. The race will be set up on a large square with the side of n meters. The given square is split into n × n cells (represented as unit squares), each cell has some number. At the beginning of the race Furik ...
#include <bits/stdc++.h> using namespace std; const int N = 2e6; const long long mod = 1e9 + 7; const long long inf = 1e9; long long a[610][610], f[2][610][610]; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); cerr.tie(nullptr); int n; cin >> n; for (int i = 0; i <= n; ...
### Prompt Your task is to create a CPP solution to the following problem: Furik and Rubik take part in a relay race. The race will be set up on a large square with the side of n meters. The given square is split into n × n cells (represented as unit squares), each cell has some number. At the beginning of the race ...
#include <bits/stdc++.h> using namespace std; int N, Mat[400][400]; int f[610][310][310]; void Init() { scanf("%d", &N); for (int i = 1; i <= N; i++) for (int j = 1; j <= N; j++) scanf("%d", &Mat[i][j]); } void Work() { for (int i = 0; i <= 2 * N; i++) for (int j = 0; j <= N; j++) for (int k = 0; k ...
### Prompt Construct a CPP code solution to the problem outlined: Furik and Rubik take part in a relay race. The race will be set up on a large square with the side of n meters. The given square is split into n × n cells (represented as unit squares), each cell has some number. At the beginning of the race Furik sta...
#include <bits/stdc++.h> #pragma comment(linker, "/STACK:60777216") using namespace std; int n; int d[300][300]; int dp[300][300][300]; bool was[300][300][300]; int dx[] = {1, 0}; int dy[] = {0, 1}; inline bool valid(int i, int j, int k) { int l = i + j - k; if (i >= 0 && i < n && j >= 0 && j < n) { if (k >= 0 ...
### Prompt Generate a Cpp solution to the following problem: Furik and Rubik take part in a relay race. The race will be set up on a large square with the side of n meters. The given square is split into n × n cells (represented as unit squares), each cell has some number. At the beginning of the race Furik stands i...
#include <bits/stdc++.h> using namespace std; int arr[302][302], n, memory[302][302][302]; int MX(int a, int b) { return (a > b) ? a : b; } int dp(int r1, int c1, int r2) { if (r1 == n - 1 && c1 == n - 1) { return arr[r1][c1]; } if (memory[r1][c1][r2] != -1) { return memory[r1][c1][r2]; } int c2, mx =...
### Prompt Please formulate a Cpp solution to the following problem: Furik and Rubik take part in a relay race. The race will be set up on a large square with the side of n meters. The given square is split into n × n cells (represented as unit squares), each cell has some number. At the beginning of the race Furik ...
#include <bits/stdc++.h> using namespace std; int ara[303][303], mem[303][303][303], n; bool vis[303][303][303]; int dx[2] = {0, 1}; int dy[2] = {1, 0}; int dp(int x1, int y1, int x2, int y2) { if (x1 == x2 && y1 == y2 && x1 == y1 && x1 == n - 1) return ara[n - 1][n - 1]; if (x2 > x1 || y2 < y1 || max({x1, x2, y1, ...
### Prompt Your challenge is to write a cpp solution to the following problem: Furik and Rubik take part in a relay race. The race will be set up on a large square with the side of n meters. The given square is split into n × n cells (represented as unit squares), each cell has some number. At the beginning of the r...
#include <bits/stdc++.h> const int inf = 1000 * 1000 * 1000; int dp[599][300][300], a[300][300], shift[4][2] = {{0, 0}, {-1, 0}, {0, -1}, {-1, -1}}; int main() { int n; scanf("%d", &n); int maxt = 2 * n - 1; for (int i = 0; i < maxt; ++i) for (int j = 0; j < n; ++j) for (int k = 0; k < n; ++k) dp[...
### Prompt Your task is to create a Cpp solution to the following problem: Furik and Rubik take part in a relay race. The race will be set up on a large square with the side of n meters. The given square is split into n × n cells (represented as unit squares), each cell has some number. At the beginning of the race ...
#include <bits/stdc++.h> using namespace std; int N; int A[300][300]; int M[600][300][300]; int dx[] = {1, 0}, dy[] = {0, 1}; int main() { cin >> N; for (int i = 0; i < N; i++) for (int j = 0; j < N; j++) cin >> A[i][j]; memset(M, 128, sizeof(M)); M[0][0][0] = A[0][0]; for (int i = 0; i < 2 * N - 2; i++) ...
### Prompt Please create a solution in Cpp to the following problem: Furik and Rubik take part in a relay race. The race will be set up on a large square with the side of n meters. The given square is split into n × n cells (represented as unit squares), each cell has some number. At the beginning of the race Furik ...
#include <bits/stdc++.h> using namespace std; const int infl = 1e8 + 5; int n, m, k, q, x, y, f, val, t = 1, i, j; int ind = -1, cnt, sz, sm, ans, mx = -1, mn = infl; int a[304][304], dp[304 + 304][304][304]; int rec(int d, int x1, int x2) { if (d > n + n - 2) return 0; if (x1 >= n || x2 >= n) return -infl; int y...
### Prompt Please create a solution in cpp to the following problem: Furik and Rubik take part in a relay race. The race will be set up on a large square with the side of n meters. The given square is split into n × n cells (represented as unit squares), each cell has some number. At the beginning of the race Furik ...
#include <bits/stdc++.h> using namespace std; int a[305][305], dp[610][305][305]; int n; void chu() { for (int i = 1; i <= n + n - 1; i++) for (int j = 0; j <= n; j++) for (int k = 0; k <= n; k++) dp[i][j][k] = -1000000; } int main() { while (scanf("%d", &n) != -1) { chu(); for (int i = 0; i <= n;...
### Prompt Please provide a cpp coded solution to the problem described below: Furik and Rubik take part in a relay race. The race will be set up on a large square with the side of n meters. The given square is split into n × n cells (represented as unit squares), each cell has some number. At the beginning of the r...
#include <bits/stdc++.h> using namespace std; int n, C[300][300]; int A[2][300][300], now = 0, ans = 0; int get(int now, int i1, int i2) { if (i1 < 0 || i2 < 0) return -(int)HUGE_VAL; return A[now][i1][i2]; } int main() { cin >> n; for (int i = 0; i < n; ++i) for (int j = 0; j < n; ++j) cin >> C[i][j]; fo...
### Prompt In Cpp, your task is to solve the following problem: Furik and Rubik take part in a relay race. The race will be set up on a large square with the side of n meters. The given square is split into n × n cells (represented as unit squares), each cell has some number. At the beginning of the race Furik stand...
#include <bits/stdc++.h> using namespace std; using ll = long long; using ii = pair<int, int>; const int N = 3e2 + 5; const int MOD = 1e9 + 7; const int INF = 2e9; const int dr4[] = {1, -1, 0, 0}; const int dc4[] = {0, 0, 1, -1}; const int dr8[] = {-1, -1, 0, 1, 1, 1, 0, -1}; const int dc8[] = {0, 1, 1, 1, 0, -1, -1, -...
### Prompt In CPP, your task is to solve the following problem: Furik and Rubik take part in a relay race. The race will be set up on a large square with the side of n meters. The given square is split into n × n cells (represented as unit squares), each cell has some number. At the beginning of the race Furik stand...
#include <bits/stdc++.h> using namespace std; int n, result = 0, f[605][305][305], a[1000][1000]; void readdata() { cin >> n; for (int i = 1; i <= n; i++) { for (int j = 1; j <= n; j++) { cin >> a[i][j]; } } } void solve() { for (int d = 0; d <= 2 * n + 1; d++) { for (int c1 = 0; c1 <= d; c1++...
### Prompt Please formulate a cpp solution to the following problem: Furik and Rubik take part in a relay race. The race will be set up on a large square with the side of n meters. The given square is split into n × n cells (represented as unit squares), each cell has some number. At the beginning of the race Furik ...
#include <bits/stdc++.h> using namespace std; const int N = 2e6; const long long mod = 1e9 + 7; const long long inf = 1e9; long long a[610][610], f[2][610][610]; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); cerr.tie(nullptr); int n; cin >> n; for (int i = 0; i <= 310...
### Prompt Your challenge is to write a CPP solution to the following problem: Furik and Rubik take part in a relay race. The race will be set up on a large square with the side of n meters. The given square is split into n × n cells (represented as unit squares), each cell has some number. At the beginning of the r...
#include <bits/stdc++.h> using namespace std; int n; int a[1005][1005]; int dp[605][303][303]; int calc(int t, int c, int cc) { if (t == 2 * (n - 1)) { if (c == n && cc == n) return a[n][n]; else return -(1e8); } if (dp[t][c][cc] != -1) return dp[t][c][cc]; int r = 2 + t - c; int rr = 2 + ...
### Prompt In Cpp, your task is to solve the following problem: Furik and Rubik take part in a relay race. The race will be set up on a large square with the side of n meters. The given square is split into n × n cells (represented as unit squares), each cell has some number. At the beginning of the race Furik stand...
#include <bits/stdc++.h> using namespace std; bool valid(long long i, long long j, long long n, long long m) { if (i >= 0 && i < n && j >= 0 && j < m) return true; return false; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); long long n; cin >> n; vector<vector<long long> > a(n, vector<lo...
### Prompt In CPP, your task is to solve the following problem: Furik and Rubik take part in a relay race. The race will be set up on a large square with the side of n meters. The given square is split into n × n cells (represented as unit squares), each cell has some number. At the beginning of the race Furik stand...
#include <bits/stdc++.h> using namespace std; const int maxn = 305; const int maxint = 999999999; int dp[2][maxn][maxn]; int a[maxn][maxn]; int n; bool judge(int x, int y) { return (x >= 1 && y <= n); } int main() { while (scanf("%d", &n) != EOF) { for (int i = 1; i <= n; i++) for (int j = 1; j <= n; j++) s...
### Prompt Your challenge is to write a Cpp solution to the following problem: Furik and Rubik take part in a relay race. The race will be set up on a large square with the side of n meters. The given square is split into n × n cells (represented as unit squares), each cell has some number. At the beginning of the r...
#include <bits/stdc++.h> using namespace std; int m[300][300], dp[2 * 300][300][300]; int main() { int n, i, j, k, val; cin >> n; for (i = 0; i < n; i++) { for (j = 0; j < n; j++) { cin >> m[i][j]; } } dp[0][0][0] = m[0][0]; for (i = 0; i < n; i++) { for (j = 0; j < n; j++) { for (k ...
### Prompt Your challenge is to write a CPP solution to the following problem: Furik and Rubik take part in a relay race. The race will be set up on a large square with the side of n meters. The given square is split into n × n cells (represented as unit squares), each cell has some number. At the beginning of the r...
#include <bits/stdc++.h> using namespace std; const int N = 2e6; const long long mod = 1e9 + 7; const long long inf = 1e9; long long a[610][610], f[2][610][610]; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); cerr.tie(nullptr); int n; cin >> n; for (int i = 0; i <= 310...
### Prompt Develop a solution in Cpp to the problem described below: Furik and Rubik take part in a relay race. The race will be set up on a large square with the side of n meters. The given square is split into n × n cells (represented as unit squares), each cell has some number. At the beginning of the race Furik ...
#include <bits/stdc++.h> using namespace std; int arr[303][303]; int dp[606][303][303]; int main() { int n; scanf("%d", &n); for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { scanf("%d", arr[i] + j); } } for (int i = 0; i < 2 * (n - 1) + 1; i++) for (int j = 0; j < n; j++) fo...
### Prompt Generate a cpp solution to the following problem: Furik and Rubik take part in a relay race. The race will be set up on a large square with the side of n meters. The given square is split into n × n cells (represented as unit squares), each cell has some number. At the beginning of the race Furik stands i...
#include <bits/stdc++.h> using namespace std; const int N = 303, inf = 0x3f3f3f3f; int a[N][N], dp[N][N][N + N], n; int f(int x1, int y1, int x2, int y2) { if (~dp[x1][x2][x1 + y1]) return dp[x1][x2][x1 + y1]; if (x1 == n && y1 == n) return a[n][n]; int t = a[x1][y1] + a[x2][y2] - (x1 == x2 && y1 == y2) * a[x1][y...
### Prompt Please create a solution in CPP to the following problem: Furik and Rubik take part in a relay race. The race will be set up on a large square with the side of n meters. The given square is split into n × n cells (represented as unit squares), each cell has some number. At the beginning of the race Furik ...
#include <bits/stdc++.h> using namespace std; const long long N = 1e3 + 5; const long long INF = 1e9 + 7; long long n, a[N][N], b[2][N][N]; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); scanf("%lld", &n); for (long long i = 0; i < n; i++) for (long long j = 0; j < n; j++) s...
### Prompt In CPP, your task is to solve the following problem: Furik and Rubik take part in a relay race. The race will be set up on a large square with the side of n meters. The given square is split into n × n cells (represented as unit squares), each cell has some number. At the beginning of the race Furik stand...
#include <bits/stdc++.h> using namespace std; const int MAXN = 305; int n; int mat[MAXN][MAXN]; int dp[MAXN * 2][MAXN][MAXN]; int get_len_of_row(int i) { if (i <= n) return i; return 2 * n - i; } int offset[4][2] = {{-1, 0}, {-1, -1}, {0, -1}, {0, 0}}; bool is_valid(int x, int i) { int len = get_len_of_row(i); ...
### Prompt Please provide a cpp coded solution to the problem described below: Furik and Rubik take part in a relay race. The race will be set up on a large square with the side of n meters. The given square is split into n × n cells (represented as unit squares), each cell has some number. At the beginning of the r...
#include <bits/stdc++.h> using namespace std; int dp[305 << 1][305][305]; int a[305][305], n; int way[4][2] = {{0, 0}, {0, 1}, {1, 0}, {1, 1}}; int main() { while (scanf("%d", &n) != EOF) { for (int i = 1; i <= n; i++) for (int j = 1; j <= n; j++) scanf("%d", &a[i][j]); memset(dp, 0x81, sizeof(dp)); ...
### Prompt Generate a cpp solution to the following problem: Furik and Rubik take part in a relay race. The race will be set up on a large square with the side of n meters. The given square is split into n × n cells (represented as unit squares), each cell has some number. At the beginning of the race Furik stands i...
#include <bits/stdc++.h> using namespace std; const int maxn = 305; const int maxint = 999999999; int dp[2][maxn][maxn]; int a[maxn][maxn]; int n; bool judge(int x, int y) { return (x >= 1 && x <= n && y >= 1 && y <= n); } int main() { while (scanf("%d", &n) != EOF) { for (int i = 1; i <= n; i++) for (int j...
### Prompt Your task is to create a CPP solution to the following problem: Furik and Rubik take part in a relay race. The race will be set up on a large square with the side of n meters. The given square is split into n × n cells (represented as unit squares), each cell has some number. At the beginning of the race ...
#include <bits/stdc++.h> using namespace std; int ddx[] = {-1, 0, 1, 0, -1, -1, 1, 1}; int ddy[] = {0, 1, 0, -1, -1, 1, -1, 1}; bool inSize(int c, int l, int r) { if (c >= l && c <= r) return true; return false; } template <class T> inline void checkmin(T &a, T b) { if (a == -1 || a > b) a = b; } template <class ...
### Prompt Create a solution in cpp for the following problem: Furik and Rubik take part in a relay race. The race will be set up on a large square with the side of n meters. The given square is split into n × n cells (represented as unit squares), each cell has some number. At the beginning of the race Furik stands...
#include <bits/stdc++.h> template <class T> bool read(T &x) { char *s; s = (char *)malloc(10); if (sizeof(x) == 1) strcpy(s + 1, " %c"); else if (sizeof(x) == 4) strcpy(s + 1, "%d"); else if (sizeof(x) == 8) strcpy(s + 1, "%lld"); int k = scanf(s + 1, &x); free(s); return k != -1; } using na...
### Prompt Generate a Cpp solution to the following problem: Furik and Rubik take part in a relay race. The race will be set up on a large square with the side of n meters. The given square is split into n × n cells (represented as unit squares), each cell has some number. At the beginning of the race Furik stands i...
#include <bits/stdc++.h> using namespace std; const long double eps = 1e-9; const long double pi = acos(-1.0); const long double inf = 1000 * 1000 * 1000; #pragma comment(linker, "/STACK:36777216") long long gcd(long long a, long long b) { return (b == 0) ? a : gcd(b, a % b); } long long xabs(long long a) { return a > ...
### Prompt Your task is to create a CPP solution to the following problem: Furik and Rubik take part in a relay race. The race will be set up on a large square with the side of n meters. The given square is split into n × n cells (represented as unit squares), each cell has some number. At the beginning of the race ...
#include <bits/stdc++.h> using namespace std; const int MAX = 310; const int inf = 1e6; int mod = 1e9 + 7, a[MAX][MAX]; int dp[MAX][MAX][2 * MAX]; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int n; cin >> n; for (int i = 0; i < n + 2; i++) for (int j = 0; j < n + 2; j++) a[i][j] = -inf; ...
### Prompt Please provide a Cpp coded solution to the problem described below: Furik and Rubik take part in a relay race. The race will be set up on a large square with the side of n meters. The given square is split into n × n cells (represented as unit squares), each cell has some number. At the beginning of the r...
#include <bits/stdc++.h> using namespace std; template <typename G1, typename G2 = G1, typename G3 = G1> struct triple { G1 first; G2 second; G3 T; }; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int n; cin >> n; vector<vector<int>> v(n, vector<int>(n + 1)); for (int i = 0; i < n; i++) f...
### Prompt Your task is to create a cpp solution to the following problem: Furik and Rubik take part in a relay race. The race will be set up on a large square with the side of n meters. The given square is split into n × n cells (represented as unit squares), each cell has some number. At the beginning of the race ...
#include <bits/stdc++.h> using namespace std; const int N = 2e6; const long long mod = 1e9 + 7; const long long inf = 1e9; long long a[610][610], f[2][610][610]; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); cerr.tie(nullptr); int n; cin >> n; for (int i = 0; i <= 310...
### Prompt Construct a Cpp code solution to the problem outlined: Furik and Rubik take part in a relay race. The race will be set up on a large square with the side of n meters. The given square is split into n × n cells (represented as unit squares), each cell has some number. At the beginning of the race Furik sta...
#include <bits/stdc++.h> using namespace std; const int INF = 1e9; int dp[604][302][302], n, arr[302][302]; bool check(int i, int j) { if (i > n || i < 1) return false; if (j > n || j < 1) return false; return true; } int solve() { cin >> n; for (int i = 1; i <= n; i++) for (int j = 1; j <= n; j++) cin >>...
### Prompt Generate a Cpp solution to the following problem: Furik and Rubik take part in a relay race. The race will be set up on a large square with the side of n meters. The given square is split into n × n cells (represented as unit squares), each cell has some number. At the beginning of the race Furik stands i...
#include <bits/stdc++.h> using namespace std; const int N = 2e6; const long long mod = 1e9 + 7; const long long inf = 1e9; long long a[610][610], f[2][610][610]; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); cerr.tie(nullptr); int n; cin >> n; for (int i = 0; i <= 600...
### Prompt Please formulate a Cpp solution to the following problem: Furik and Rubik take part in a relay race. The race will be set up on a large square with the side of n meters. The given square is split into n × n cells (represented as unit squares), each cell has some number. At the beginning of the race Furik ...
#include <bits/stdc++.h> using namespace std; int a[300][300]; int d[2 * 300 - 1][300][300]; int main() { unsigned int n; cin >> n; for (unsigned int i = 0; i < n; ++i) { for (unsigned int j = 0; j < n; ++j) { cin >> a[i][j]; } } d[0][0][0] = a[0][0]; for (unsigned int s = 1; s <= 2 * n - 2; +...
### Prompt Please provide a cpp coded solution to the problem described below: Furik and Rubik take part in a relay race. The race will be set up on a large square with the side of n meters. The given square is split into n × n cells (represented as unit squares), each cell has some number. At the beginning of the r...
#include <bits/stdc++.h> using namespace std; typedef char* cstr; const int oo = (~0u) >> 1; const long long int ool = (~0ull) >> 1; const double inf = 1e100; const double eps = 1e-8; const double pi = acos(-1.0); template <typename type> inline void cmax(type& a, const type& b) { if (a < b) a = b; } template <typena...
### Prompt Please create a solution in cpp to the following problem: Furik and Rubik take part in a relay race. The race will be set up on a large square with the side of n meters. The given square is split into n × n cells (represented as unit squares), each cell has some number. At the beginning of the race Furik ...
#include <bits/stdc++.h> using namespace std; int i, j, l, n, a[301][301], f[601][301][301], ii, jj, ans = -1000000000; int add(int n, int i, int j) { if (i == j) return a[n - i][i]; else return a[n - i][i] + a[n - j][j]; } int main() { cin >> n; for (i = 0; i < n; i++) for (j = 0; j < n; j++) cin >...
### Prompt Develop a solution in cpp to the problem described below: Furik and Rubik take part in a relay race. The race will be set up on a large square with the side of n meters. The given square is split into n × n cells (represented as unit squares), each cell has some number. At the beginning of the race Furik ...
#include <bits/stdc++.h> using namespace std; const int N = 333; int dp[2][N][N]; int max(int a, int b, int c) { return max(max(a, b), c); } int max(int a, int b, int c, int d) { return max(max(a, b), max(c, d)); } int a[N][N]; int DP(int h, int i, int j) { if (i <= 0 || h - i <= 0 || j <= 0 || h - j <= 0) return...
### Prompt Generate a Cpp solution to the following problem: Furik and Rubik take part in a relay race. The race will be set up on a large square with the side of n meters. The given square is split into n × n cells (represented as unit squares), each cell has some number. At the beginning of the race Furik stands i...
#include <bits/stdc++.h> #pragma comment(linker, "/STACK:60000000") using namespace std; const double PI = acos(-1.0); const double eps = 1e-12; const int INF = (1 << 30) - 1; const long long LLINF = ((long long)1 << 62) - 1; const int maxn = 310; int di[] = {0, 1}; int dj[] = {1, 0}; int a[maxn][maxn]; int n, m; int f...
### Prompt Generate a cpp solution to the following problem: Furik and Rubik take part in a relay race. The race will be set up on a large square with the side of n meters. The given square is split into n × n cells (represented as unit squares), each cell has some number. At the beginning of the race Furik stands i...
#include <bits/stdc++.h> using namespace std; int M, N, a[333][333], dp[611][311][311]; int dx[2] = {1, 0}; int dy[2] = {0, 1}; void fresh(int &x, int v) { if (x < v) x = v; } int main() { int i, j, k; while (scanf("%d", &N) == 1) { M = N; for (i = 0; i < 611; i++) for (j = 0; j < 311; j++) ...
### Prompt Your challenge is to write a cpp solution to the following problem: Furik and Rubik take part in a relay race. The race will be set up on a large square with the side of n meters. The given square is split into n × n cells (represented as unit squares), each cell has some number. At the beginning of the r...
#include <bits/stdc++.h> using namespace std; int f[305][305][305]; int p[305][305]; int main() { int n; scanf("%d", &n); for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) scanf("%d", &p[i][j]); f[0][0][0] = p[0][0]; for (int x1 = 0; x1 < n; x1++) for (int y1 = 0; y1 < n; y1++) if (x1 + y1...
### Prompt Create a solution in Cpp for the following problem: Furik and Rubik take part in a relay race. The race will be set up on a large square with the side of n meters. The given square is split into n × n cells (represented as unit squares), each cell has some number. At the beginning of the race Furik stands...
#include <bits/stdc++.h> const int N = 310; const int inf = 0x3f3f3f3f; using namespace std; int a[N][N], dp[3][N][N], n; int main() { int n; scanf("%d", &n); for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) scanf("%d", &a[i][j]); for (int k = 0; k <= 2; k++) for (int i = 0; i < n; i++) for...
### Prompt Please provide a CPP coded solution to the problem described below: Furik and Rubik take part in a relay race. The race will be set up on a large square with the side of n meters. The given square is split into n × n cells (represented as unit squares), each cell has some number. At the beginning of the r...
#include <bits/stdc++.h> using namespace std; int a[350][350]; int dp[305][305][305 * 2 + 5]; int main() { int n; while (~scanf("%d", &n)) { for (int i = 0; i <= n; i++) { for (int j = 0; j <= n; j++) { for (int k = 0; k <= 2 * n; k++) { dp[i][j][k] = -0x3f3f3f3f; } } }...
### Prompt Please provide a CPP coded solution to the problem described below: Furik and Rubik take part in a relay race. The race will be set up on a large square with the side of n meters. The given square is split into n × n cells (represented as unit squares), each cell has some number. At the beginning of the r...
#include <bits/stdc++.h> using namespace std; template <class stl> void DBGSTL(stl a) { for (__typeof((a).begin()) i = (a).begin(); i != (a).end(); i++) { cerr << *i << " "; } cerr << "\n"; return; } using namespace std; int mem[305][305][305]; int done[305][305][305]; int grid[305][305]; int n; int dp(int ...
### Prompt Develop a solution in Cpp to the problem described below: Furik and Rubik take part in a relay race. The race will be set up on a large square with the side of n meters. The given square is split into n × n cells (represented as unit squares), each cell has some number. At the beginning of the race Furik ...
#include <bits/stdc++.h> using namespace std; const int N = 305; const int inf = 0x3f3f3f3f; const double eps = 1e-5; int n, c; int dp[605][N][N], a[N][N]; int max(int a, int b, int c, int d) { return max(max(a, b), max(c, d)); } int main() { int n; scanf("%d", &n); for (int i = 1; i <= n; i++) for (int j = 1...
### Prompt Please formulate a CPP solution to the following problem: Furik and Rubik take part in a relay race. The race will be set up on a large square with the side of n meters. The given square is split into n × n cells (represented as unit squares), each cell has some number. At the beginning of the race Furik ...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0); long long n; cin >> n; long long a[n + 1][n + 1]; for (long long i = 1; i <= n; i++) { for (long long j = 1; j <= n; j++) { cin >> a[i][j]; } } int dp[2 * n][n + 1][n + 1]; ...
### Prompt Please create a solution in Cpp to the following problem: Furik and Rubik take part in a relay race. The race will be set up on a large square with the side of n meters. The given square is split into n × n cells (represented as unit squares), each cell has some number. At the beginning of the race Furik ...
#include <bits/stdc++.h> using namespace std; const int N = 302; int f[2][N][N]; int a[N][N]; const int Dir[4][2] = {{0, 0}, {-1, 0}, {-1, -1}, {0, -1}}; int main() { int i, j, x1, x2, x1p, x2p, k, n; int xs, xe; cin >> n; for (i = 0; i < n; i++) for (j = 0; j < n; j++) scanf("%d", &a[i][j]); f[0][0][0] =...
### Prompt Please formulate a Cpp solution to the following problem: Furik and Rubik take part in a relay race. The race will be set up on a large square with the side of n meters. The given square is split into n × n cells (represented as unit squares), each cell has some number. At the beginning of the race Furik ...
#include <bits/stdc++.h> using namespace std; int n; int a[303 + 303][303]; int d[303 + 303][303][303]; int main() { scanf("%d", &n); for (int i = 0; i < n; ++i) for (int j = 0; j < n; ++j) scanf("%d", &a[i + j][j]); for (int diag = 0; diag < n + n - 1; ++diag) for (int i = 0; i < n; ++i) for (int j...
### Prompt Develop a solution in cpp to the problem described below: Furik and Rubik take part in a relay race. The race will be set up on a large square with the side of n meters. The given square is split into n × n cells (represented as unit squares), each cell has some number. At the beginning of the race Furik ...
#include <bits/stdc++.h> using namespace std; inline long long rd() { long long _x = 0; int _ch = getchar(), _f = 1; for (; !isdigit(_ch) && (_ch != '-') && (_ch != EOF); _ch = getchar()) ; if (_ch == '-') { _f = 0; _ch = getchar(); } for (; isdigit(_ch); _ch = getchar()) _x = _x * 10 + _ch - '0...
### Prompt Please provide a cpp coded solution to the problem described below: Urpal lives in a big city. He has planned to meet his lover tonight. The city has n junctions numbered from 1 to n. The junctions are connected by m directed streets, all the roads have equal length. Urpal lives in junction a and the dat...
#include <bits/stdc++.h> using namespace std; const int maxn = 110, inf = 1e5; bool forb[maxn], good[maxn][maxn]; int dis[maxn][maxn], dis2[maxn][maxn], d[maxn][maxn], dp[maxn], n; vector<int> wh[maxn]; void floyd(int dis[][maxn]) { for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { if (forb[i] || ...
### Prompt Generate a CPP solution to the following problem: Urpal lives in a big city. He has planned to meet his lover tonight. The city has n junctions numbered from 1 to n. The junctions are connected by m directed streets, all the roads have equal length. Urpal lives in junction a and the date is planned in a ...
#include <bits/stdc++.h> using namespace std; const int N = 105; vector<int> adj[N]; vector<int> vec[N]; int dis[N][N]; bool es[N][N]; int ans[N]; int st[N], ed[N]; bool mark[N]; int d[N]; queue<int> q; void dfs(int v, int d) { if (mark[v] || ans[v] < d) { return; } mark[v] = true; for (auto u : adj[v]) { ...
### Prompt In CPP, your task is to solve the following problem: Urpal lives in a big city. He has planned to meet his lover tonight. The city has n junctions numbered from 1 to n. The junctions are connected by m directed streets, all the roads have equal length. Urpal lives in junction a and the date is planned in...
#include <bits/stdc++.h> using namespace std; int get() { int f = 0, v = 0; char ch; while (!isdigit(ch = getchar())) if (ch == '-') break; if (ch == '-') f = 1; else v = ch - '0'; while (isdigit(ch = getchar())) v = v * 10 + ch - '0'; if (f) return -v; else return v; } const int max...
### Prompt In cpp, your task is to solve the following problem: Urpal lives in a big city. He has planned to meet his lover tonight. The city has n junctions numbered from 1 to n. The junctions are connected by m directed streets, all the roads have equal length. Urpal lives in junction a and the date is planned in...
#include <bits/stdc++.h> using namespace std; int dis[105][105], Q[105][105][105], n, m, S, T, dp[105], g[105], pt, i, j, A, B, from[105], to[105], k, QQ, l; const int inf = 453266144; bool FLAG; int main() { scanf("%d%d%d%d", &n, &m, &S, &T); for (i = 1; i <= n; i++) for (j = 1; j <= n; j++) dis[i][j] = in...
### Prompt Develop a solution in cpp to the problem described below: Urpal lives in a big city. He has planned to meet his lover tonight. The city has n junctions numbered from 1 to n. The junctions are connected by m directed streets, all the roads have equal length. Urpal lives in junction a and the date is plann...
#include <bits/stdc++.h> using namespace std; inline int read() { int x = 0; char c = getchar(); while (c < '0' || c > '9') c = getchar(); while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar(); return x; } inline int min(int a, int b) { return a < b ? a : b; } inline int max(int a, int b) { return ...
### Prompt Construct a cpp code solution to the problem outlined: Urpal lives in a big city. He has planned to meet his lover tonight. The city has n junctions numbered from 1 to n. The junctions are connected by m directed streets, all the roads have equal length. Urpal lives in junction a and the date is planned ...
#include <bits/stdc++.h> using namespace std; const int N = 105, K = N, inf = 1e9 + 7; int n, m, a, b, k, s[K], t[K]; int g[N][N], dist[N][N], deg[N][K], f[N][K]; bool must[N][K]; struct data { int i, j, val; void extend(); }; deque<data> q; void data::extend() { if (f[i][j]) return; f[i][j] = val; if (must[i...
### Prompt In Cpp, your task is to solve the following problem: Urpal lives in a big city. He has planned to meet his lover tonight. The city has n junctions numbered from 1 to n. The junctions are connected by m directed streets, all the roads have equal length. Urpal lives in junction a and the date is planned in...
#include <bits/stdc++.h> using namespace std; const int MAXN = 105, INF = 1e8; int n, m, start, fin, d[MAXN][MAXN], en[MAXN]; int cnt[MAXN], dp[MAXN][MAXN]; bool has[MAXN][MAXN], must[MAXN][MAXN]; vector<int> out[MAXN]; int main() { ios_base::sync_with_stdio(false); cin >> n >> m >> start >> fin; memset(d, 63, si...
### Prompt Create a solution in cpp for the following problem: Urpal lives in a big city. He has planned to meet his lover tonight. The city has n junctions numbered from 1 to n. The junctions are connected by m directed streets, all the roads have equal length. Urpal lives in junction a and the date is planned in ...
#include <bits/stdc++.h> using namespace std; const int maxn = 250; int n, m, num, cnt; int a[maxn][maxn], b[maxn][maxn], S[maxn], T[maxn]; int ans[maxn], vis[maxn], dp[maxn], p[maxn][maxn]; int dfs(int u, int v) { if (vis[u] == cnt) return dp[u]; vis[u] = cnt; int Ans = -1; for (int i = 1; i <= n; i++) if ...
### Prompt Your task is to create a CPP solution to the following problem: Urpal lives in a big city. He has planned to meet his lover tonight. The city has n junctions numbered from 1 to n. The junctions are connected by m directed streets, all the roads have equal length. Urpal lives in junction a and the date is...
#include <bits/stdc++.h> using namespace std; template <class T> inline T min(T &a, T &b) { return a < b ? a : b; } template <class T> inline T max(T &a, T &b) { return a > b ? a : b; } template <class T> void read(T &x) { char ch; while ((ch = getchar()) && !isdigit(ch)) ; x = ch - '0'; while ((ch = ge...
### Prompt Generate a Cpp solution to the following problem: Urpal lives in a big city. He has planned to meet his lover tonight. The city has n junctions numbered from 1 to n. The junctions are connected by m directed streets, all the roads have equal length. Urpal lives in junction a and the date is planned in a ...
#include <bits/stdc++.h> using namespace std; const int NMax = 110; struct pii { int x, y; }; pii mp(int x, int y) { pii ret; ret.x = x; ret.y = y; return ret; } int N, M, S, T, K; int G[NMax][NMax], cnt[NMax], good[NMax][NMax], cost[NMax][NMax]; pii bus[NMax]; vector<int> must[NMax], route[NMax]; int main() ...
### Prompt Develop a solution in Cpp to the problem described below: Urpal lives in a big city. He has planned to meet his lover tonight. The city has n junctions numbered from 1 to n. The junctions are connected by m directed streets, all the roads have equal length. Urpal lives in junction a and the date is plann...
#include <bits/stdc++.h> using namespace std; const int inf = 0x3f3f3f3f; int n, m, a, b, k, s[105], t[105], g[105][105], cnt[105], dp[105][105]; bool must[105][105]; bool on(int i, int j) { return g[s[i]][j] + g[j][t[i]] == g[s[i]][t[i]]; } int main() { scanf("%d%d%d%d", &n, &m, &a, &b); memset(g, 0x3f, sizeof g);...
### Prompt Develop a solution in Cpp to the problem described below: Urpal lives in a big city. He has planned to meet his lover tonight. The city has n junctions numbered from 1 to n. The junctions are connected by m directed streets, all the roads have equal length. Urpal lives in junction a and the date is plann...
#include <bits/stdc++.h> using namespace std; const int N = 101; const int I = 1 << 28; int d[N][N], cnt[N][N], s[N], t[N], lev[N], ans[N], z[N], cur, n, m, a, b, w; bool c[N][N]; int BFS(int v, int u) { if (lev[v] == cur) return ans[v]; lev[v] = cur; int res = -1; for (int i = 1; i <= n; i++) if (d[v][i] =...
### Prompt Please provide a cpp coded solution to the problem described below: Urpal lives in a big city. He has planned to meet his lover tonight. The city has n junctions numbered from 1 to n. The junctions are connected by m directed streets, all the roads have equal length. Urpal lives in junction a and the dat...
#include <bits/stdc++.h> using namespace std; vector<pair<int, int> > edge; int flo[120][120], flo2[120][120], dp[120][120], menda[120][120], com; int st[120], en[120]; vector<int> vc[120]; void sho(int n) { for (int i = 1; i <= n; i++) { for (int j = 1; j <= n; j++) { if (i == j) continue; flo[i][j] ...
### Prompt Construct a Cpp code solution to the problem outlined: Urpal lives in a big city. He has planned to meet his lover tonight. The city has n junctions numbered from 1 to n. The junctions are connected by m directed streets, all the roads have equal length. Urpal lives in junction a and the date is planned ...
#include <bits/stdc++.h> using namespace std; const int maxn = 110; const int inf = 100000000; vector<int> g[maxn][maxn], gb[maxn][maxn]; int dist[maxn][maxn], st[maxn], en[maxn], q[maxn], d2[maxn][maxn]; bool onpath[maxn][maxn], gone[maxn], calced[maxn], cp[maxn], cutp[maxn][maxn]; int main() { int n, m, t1, t2, i, ...
### Prompt Develop a solution in CPP to the problem described below: Urpal lives in a big city. He has planned to meet his lover tonight. The city has n junctions numbered from 1 to n. The junctions are connected by m directed streets, all the roads have equal length. Urpal lives in junction a and the date is plann...
#include <bits/stdc++.h> using namespace std; const int RLEN = 1 << 20 | 1; inline char gc() { static char ibuf[RLEN], *ib, *ob; (ob == ib) && (ob = (ib = ibuf) + fread(ibuf, 1, RLEN, stdin)); return (ob == ib) ? EOF : *ib++; } inline int read() { char ch = getchar(); int res = 0, f = 1; while (!isdigit(ch)...
### Prompt Your challenge is to write a cpp solution to the following problem: Urpal lives in a big city. He has planned to meet his lover tonight. The city has n junctions numbered from 1 to n. The junctions are connected by m directed streets, all the roads have equal length. Urpal lives in junction a and the dat...
#include <bits/stdc++.h> using namespace std; const int MAX = 109, INF = 1e9; vector<int> bus[MAX][MAX], g[MAX]; int dis[MAX][MAX], ted[MAX], pos[MAX][MAX], n, m, st, en, k, bes = INF; bool been[MAX], big[MAX][MAX]; int main() { ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); cin >> n >> m >> st >> en, st--,...
### Prompt Please create a solution in CPP to the following problem: Urpal lives in a big city. He has planned to meet his lover tonight. The city has n junctions numbered from 1 to n. The junctions are connected by m directed streets, all the roads have equal length. Urpal lives in junction a and the date is plann...
#include <bits/stdc++.h> using namespace std; template <class T> inline T sqr(T x) { return x * x; } template <class T> inline void upmin(T &t, T tmp) { if (t > tmp) t = tmp; } template <class T> inline void upmax(T &t, T tmp) { if (t < tmp) t = tmp; } inline int sgn(double x) { if (abs(x) < 1e-9) return 0; r...
### Prompt In cpp, your task is to solve the following problem: Urpal lives in a big city. He has planned to meet his lover tonight. The city has n junctions numbered from 1 to n. The junctions are connected by m directed streets, all the roads have equal length. Urpal lives in junction a and the date is planned in...
#include <bits/stdc++.h> using namespace std; namespace runzhe2000 { const int INF = 1000000000; int n, m, a, b, d[105][105], timer, ecnt, vis[105], cnt[105], buscnt, s[105], t[105], must[105][105], an[105], last[105], f[105]; struct edge { int next, to; } e[105 * 105]; void addedge(int a, int b) { e[++ecnt] = ...
### Prompt Please formulate a CPP solution to the following problem: Urpal lives in a big city. He has planned to meet his lover tonight. The city has n junctions numbered from 1 to n. The junctions are connected by m directed streets, all the roads have equal length. Urpal lives in junction a and the date is plann...
#include <bits/stdc++.h> using namespace std; inline char gc() { static const long long L = 233333; static char sxd[L], *sss = sxd, *ttt = sxd; if (sss == ttt) { ttt = (sss = sxd) + fread(sxd, 1, L, stdin); if (sss == ttt) { return EOF; } } return *sss++; } inline char readalpha() { char c...
### Prompt In CPP, your task is to solve the following problem: Urpal lives in a big city. He has planned to meet his lover tonight. The city has n junctions numbered from 1 to n. The junctions are connected by m directed streets, all the roads have equal length. Urpal lives in junction a and the date is planned in...
#include <bits/stdc++.h> using namespace std; const int N = 110, inf = 1e6; int dis[N][N], dp[N], mem[N], s[N], t[N], n, m, a, b; vector<int> V[N]; void init() { for (int i = 0; i < N; i++) V[i].clear(), mem[i] = inf; return; } void relax(int src, int sink) { init(); mem[sink] = dp[sink]; if (dis[src][sink] =...
### Prompt Your challenge is to write a cpp solution to the following problem: Urpal lives in a big city. He has planned to meet his lover tonight. The city has n junctions numbered from 1 to n. The junctions are connected by m directed streets, all the roads have equal length. Urpal lives in junction a and the dat...
#include <bits/stdc++.h> using namespace std; int N, M, K, A, B; int P1[102], P2[102]; int D[102][102], F[102]; int can[102][102]; bool is[102][102]; vector<int> V[102], W[102]; queue<int> Q; int main() { cin >> N >> M >> A >> B; for (int i = 1, nod1, nod2; i <= M; ++i) { cin >> nod1 >> nod2; V[nod1].push_b...
### Prompt Generate a cpp solution to the following problem: Urpal lives in a big city. He has planned to meet his lover tonight. The city has n junctions numbered from 1 to n. The junctions are connected by m directed streets, all the roads have equal length. Urpal lives in junction a and the date is planned in a ...
#include <bits/stdc++.h> using namespace std; template <class T1, class T2, class T3 = hash<T1>> using umap = unordered_map<T1, T2, T3>; template <class T> using uset = unordered_set<T>; template <class T> using vec = vector<T>; const long long infll = numeric_limits<long long>::max() >> 1; const int inf = numeric_limi...
### Prompt Construct a CPP code solution to the problem outlined: Urpal lives in a big city. He has planned to meet his lover tonight. The city has n junctions numbered from 1 to n. The junctions are connected by m directed streets, all the roads have equal length. Urpal lives in junction a and the date is planned ...
#include <bits/stdc++.h> using namespace std; int s[105], f[105], d[105][105], ans[105], e[105], A, B, N, M, K; bool a[105][105], b[105]; void init() { memset(d, 63, sizeof(d)); scanf("%d%d%d%d", &N, &M, &A, &B); for (int i = 1; i <= N; i++) d[i][i] = 0; for (int i = 1, x, y; i <= M; i++) scanf("%d%d", &x, &y),...
### Prompt Your challenge is to write a Cpp solution to the following problem: Urpal lives in a big city. He has planned to meet his lover tonight. The city has n junctions numbered from 1 to n. The junctions are connected by m directed streets, all the roads have equal length. Urpal lives in junction a and the dat...
#include <bits/stdc++.h> template <class T> void read(T &x) { int f = 1; char c = getchar(); x = 0; while (c < '0' || c > '9') { if (c == '-') f = -1; c = getchar(); } while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar(); x *= f; } template <class T> void write(T x) { int len = 0; ...
### Prompt Your challenge is to write a CPP solution to the following problem: Urpal lives in a big city. He has planned to meet his lover tonight. The city has n junctions numbered from 1 to n. The junctions are connected by m directed streets, all the roads have equal length. Urpal lives in junction a and the dat...
#include <bits/stdc++.h> using namespace std; int n, m, k, vs[200], a, b, d[2000][2000], aa[2000], bb[2000], ans = -1; int que[2000000], dist[20000], vis[20000], f[2000], tot = 0, dp[2000]; int bo[2000][2000], head[200000], line = 0, p[2000][2000]; int dfs(int x, int s, int k) { if (vis[x] == tot) return dp[x]; int...
### Prompt Please formulate a CPP solution to the following problem: Urpal lives in a big city. He has planned to meet his lover tonight. The city has n junctions numbered from 1 to n. The junctions are connected by m directed streets, all the roads have equal length. Urpal lives in junction a and the date is plann...
#include <bits/stdc++.h> using namespace std; inline int getint() { static char c; while ((c = getchar()) < '0' || c > '9') ; int res = c - '0'; while ((c = getchar()) >= '0' && c <= '9') res = res * 10 + c - '0'; return res; } template <class T> inline void relax(T &a, const T &b) { if (b > a) a = b; }...
### Prompt Your task is to create a Cpp solution to the following problem: Urpal lives in a big city. He has planned to meet his lover tonight. The city has n junctions numbered from 1 to n. The junctions are connected by m directed streets, all the roads have equal length. Urpal lives in junction a and the date is...
#include <bits/stdc++.h> using namespace std; struct Edge { int v, next; } edge[1000010]; int head[110]; int pos; void insert(int x, int y) { edge[pos].v = y; edge[pos].next = head[x]; head[x] = pos++; } int g[110][110]; int x[110]; int y[110]; int dp[110][110]; bool only[110][110]; int main() { int n, m, src...
### Prompt Construct a CPP code solution to the problem outlined: Urpal lives in a big city. He has planned to meet his lover tonight. The city has n junctions numbered from 1 to n. The junctions are connected by m directed streets, all the roads have equal length. Urpal lives in junction a and the date is planned ...
#include <bits/stdc++.h> using namespace std; const int maxn = 100 + 10; int n, m, A, B, T, U[maxn], V[maxn]; int dis[maxn][maxn], pass[maxn][maxn]; int g[maxn], f[maxn]; bool vis[maxn]; bool OnRoad(int S, int x, int T) { return dis[S][x] + dis[x][T] == dis[S][T]; } int dfs(int u, int T) { if (u == T) return f[u]; ...
### Prompt Construct a cpp code solution to the problem outlined: Urpal lives in a big city. He has planned to meet his lover tonight. The city has n junctions numbered from 1 to n. The junctions are connected by m directed streets, all the roads have equal length. Urpal lives in junction a and the date is planned ...
#include <bits/stdc++.h> using namespace std; int dp[111][111]; int path[111][111]; int dst[111][111]; vector<int> adj[111]; int st[111], ed[111]; int n, m, src, tar; int k; int main() { cin >> n >> m >> src >> tar; for (int i = 0; i < 111; i++) for (int j = 0; j < 111; j++) dst[i][j] = 0x3f3f3f3f; for (int i...
### Prompt Your challenge is to write a CPP solution to the following problem: Urpal lives in a big city. He has planned to meet his lover tonight. The city has n junctions numbered from 1 to n. The junctions are connected by m directed streets, all the roads have equal length. Urpal lives in junction a and the dat...
#include <bits/stdc++.h> using namespace std; const int maxn = 105; vector<int> must[maxn], lsb[maxn]; vector<int> f[maxn]; int n, m, xc, yc, start, over, k, tc, td, ans; int dp[maxn][maxn], maps[maxn][maxn], vis[maxn][maxn]; pair<int, int> bus[maxn]; int getdis(int xc, int yc, int k) { int rc, fc, cs; int dis[maxn...
### Prompt Your challenge is to write a cpp solution to the following problem: Urpal lives in a big city. He has planned to meet his lover tonight. The city has n junctions numbered from 1 to n. The junctions are connected by m directed streets, all the roads have equal length. Urpal lives in junction a and the dat...
#include <bits/stdc++.h> using namespace std; const int MAXN = 105, MOD = 998244353; inline void ADD(int& x, int y) { x += y; if (x >= MOD) x -= MOD; } int N, M, K, S, T, G[MAXN][MAXN], s[MAXN], t[MAXN], f[MAXN], dis[MAXN][MAXN], D[MAXN][MAXN], cnt[MAXN][MAXN]; queue<int> Q; int main() { scanf("%d%d%d%d", &N,...
### Prompt Please provide a CPP coded solution to the problem described below: Urpal lives in a big city. He has planned to meet his lover tonight. The city has n junctions numbered from 1 to n. The junctions are connected by m directed streets, all the roads have equal length. Urpal lives in junction a and the dat...
#include <bits/stdc++.h> const int oo = 0x3f3f3f3f; template <typename T> inline bool chkmax(T &a, T b) { return a < b ? a = b, true : false; } template <typename T> inline bool chkmin(T &a, T b) { return a > b ? a = b, true : false; } const int MAXN = 105; const int MAXK = 105; int N, M, K, A, B; int G[MAXN][MAXN]...
### Prompt Construct a cpp code solution to the problem outlined: Urpal lives in a big city. He has planned to meet his lover tonight. The city has n junctions numbered from 1 to n. The junctions are connected by m directed streets, all the roads have equal length. Urpal lives in junction a and the date is planned ...
#include <bits/stdc++.h> using namespace std; const int N = int(1e2) + 7; const int inf = int(1e6); int x[N], y[N], u, v, n, m, s, t, k; int d[N][N], f[N][N], must[N][N], dis[N], deg[N][N]; bool del[N][N]; queue<int> q; vector<int> adj[N], rg[N][N]; bool can(int s, int t, int x) { return d[s][x] + d[x][t] == d[s][t] ...
### Prompt Develop a solution in cpp to the problem described below: Urpal lives in a big city. He has planned to meet his lover tonight. The city has n junctions numbered from 1 to n. The junctions are connected by m directed streets, all the roads have equal length. Urpal lives in junction a and the date is plann...
#include <bits/stdc++.h> using namespace std; const long long INF = 1e18 + 10; const long long MN = 105; long long d[MN][MN]; long long n, m, k, st, en; long long S[MN], T[MN]; vector<long long> D[MN][MN]; long long cmp; long long dist[MN], sv[MN]; void init() { cin >> n >> m >> st >> en; --st, --en; fill(dist, d...
### Prompt Please provide a Cpp coded solution to the problem described below: Urpal lives in a big city. He has planned to meet his lover tonight. The city has n junctions numbered from 1 to n. The junctions are connected by m directed streets, all the roads have equal length. Urpal lives in junction a and the dat...
#include <bits/stdc++.h> using namespace std; const double pi = acos(0) * 2; template <class T> inline T abs1(T a) { return a < 0 ? -a : a; } template <class T> inline T max1(T a, T b) { return a > b ? a : b; } template <class T> inline T min1(T a, T b) { return a < b ? a : b; } template <class T> inline T gcd1(T...
### Prompt Please create a solution in CPP to the following problem: Urpal lives in a big city. He has planned to meet his lover tonight. The city has n junctions numbered from 1 to n. The junctions are connected by m directed streets, all the roads have equal length. Urpal lives in junction a and the date is plann...
#include <bits/stdc++.h> using namespace std; const int MOD = (int)1e9 + 7; const int FFTMOD = 1007681537; const int INF = (int)1e9; const long long LINF = (long long)1e18; const long double PI = acos((long double)-1); const long double EPS = 1e-9; inline long long gcd(long long a, long long b) { long long r; while...
### Prompt Create a solution in CPP for the following problem: Urpal lives in a big city. He has planned to meet his lover tonight. The city has n junctions numbered from 1 to n. The junctions are connected by m directed streets, all the roads have equal length. Urpal lives in junction a and the date is planned in ...
#include <bits/stdc++.h> using namespace std; int mp[105][105]; int s[105], t[105], res[105]; int num[105]; vector<int> p[105][105]; int a, b; int n, m, k; int main() { memset(mp, 120, sizeof(mp)); int inf = mp[0][0]; scanf("%d%d%d%d", &n, &m, &a, &b); for (int i = 1; i <= n; ++i) mp[i][i] = 0; int t1, t2; ...
### Prompt Your task is to create a CPP solution to the following problem: Urpal lives in a big city. He has planned to meet his lover tonight. The city has n junctions numbered from 1 to n. The junctions are connected by m directed streets, all the roads have equal length. Urpal lives in junction a and the date is...