Search is not available for this dataset
name stringlengths 2 112 | description stringlengths 29 13k | source int64 1 7 | difficulty int64 0 25 | solution stringlengths 7 983k | language stringclasses 4
values |
|---|---|---|---|---|---|
214_E. Relay Race | 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 in a cell with coordinates (1, 1), and Rubik stands in a cell wi... | 2 | 11 | #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... | CPP |
214_E. Relay Race | 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 in a cell with coordinates (1, 1), and Rubik stands in a cell wi... | 2 | 11 | #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... | CPP |
214_E. Relay Race | 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 in a cell with coordinates (1, 1), and Rubik stands in a cell wi... | 2 | 11 | #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... | CPP |
214_E. Relay Race | 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 in a cell with coordinates (1, 1), and Rubik stands in a cell wi... | 2 | 11 | #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);
... | CPP |
214_E. Relay Race | 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 in a cell with coordinates (1, 1), and Rubik stands in a cell wi... | 2 | 11 | #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));
... | CPP |
214_E. Relay Race | 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 in a cell with coordinates (1, 1), and Rubik stands in a cell wi... | 2 | 11 | #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... | CPP |
214_E. Relay Race | 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 in a cell with coordinates (1, 1), and Rubik stands in a cell wi... | 2 | 11 | #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 ... | CPP |
214_E. Relay Race | 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 in a cell with coordinates (1, 1), and Rubik stands in a cell wi... | 2 | 11 | import java.util.Scanner;
public class E {
static int end;
static int[][] vals;
static int[][][] dp;
static int[] dx = new int[] { 1, 0 };
static int[] dy = new int[] { 0, 1 };
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int size = sc.nextInt(... | JAVA |
214_E. Relay Race | 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 in a cell with coordinates (1, 1), and Rubik stands in a cell wi... | 2 | 11 | #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... | CPP |
214_E. Relay Race | 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 in a cell with coordinates (1, 1), and Rubik stands in a cell wi... | 2 | 11 | #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 > ... | CPP |
214_E. Relay Race | 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 in a cell with coordinates (1, 1), and Rubik stands in a cell wi... | 2 | 11 | #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;
... | CPP |
214_E. Relay Race | 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 in a cell with coordinates (1, 1), and Rubik stands in a cell wi... | 2 | 11 | import java.io.*;
import java.util.*;
public class cf214e {
public static void main(String[] args) {
FastIO in = new FastIO(), out = in;
int n = in.nextInt();
int[][] v = new int[n][n];
for(int i=0; i<n; i++) for(int j=0; j<n; j++) v[i][j] = in.nextInt();
int numDiag = 2*n-1;
int[][][] dp = n... | JAVA |
214_E. Relay Race | 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 in a cell with coordinates (1, 1), and Rubik stands in a cell wi... | 2 | 11 | #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... | CPP |
214_E. Relay Race | 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 in a cell with coordinates (1, 1), and Rubik stands in a cell wi... | 2 | 11 | #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... | CPP |
214_E. Relay Race | 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 in a cell with coordinates (1, 1), and Rubik stands in a cell wi... | 2 | 11 | import java.util.Scanner;
import java.io.OutputStream;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.InputStream;
/**
* Built using CHelper plug-in
* Actual solution is at the top
* @author George Marcus
*/
public class Main {
public static void main(String[] args) {
InputStream inputSt... | JAVA |
214_E. Relay Race | 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 in a cell with coordinates (1, 1), and Rubik stands in a cell wi... | 2 | 11 | #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 >>... | CPP |
214_E. Relay Race | 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 in a cell with coordinates (1, 1), and Rubik stands in a cell wi... | 2 | 11 | #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... | CPP |
214_E. Relay Race | 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 in a cell with coordinates (1, 1), and Rubik stands in a cell wi... | 2 | 11 | #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; +... | CPP |
214_E. Relay Race | 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 in a cell with coordinates (1, 1), and Rubik stands in a cell wi... | 2 | 11 | #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... | CPP |
214_E. Relay Race | 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 in a cell with coordinates (1, 1), and Rubik stands in a cell wi... | 2 | 11 | #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 >... | CPP |
214_E. Relay Race | 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 in a cell with coordinates (1, 1), and Rubik stands in a cell wi... | 2 | 11 | #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... | CPP |
214_E. Relay Race | 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 in a cell with coordinates (1, 1), and Rubik stands in a cell wi... | 2 | 11 | import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;
public class round131E {
static BufferedReader br = new BufferedReader(new InputStreamReader(
System.in));
static StringTokenizer st = new StringTokenizer("");
static int... | JAVA |
214_E. Relay Race | 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 in a cell with coordinates (1, 1), and Rubik stands in a cell wi... | 2 | 11 | #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... | CPP |
214_E. Relay Race | 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 in a cell with coordinates (1, 1), and Rubik stands in a cell wi... | 2 | 11 | #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++)
... | CPP |
214_E. Relay Race | 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 in a cell with coordinates (1, 1), and Rubik stands in a cell wi... | 2 | 11 | #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... | CPP |
214_E. Relay Race | 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 in a cell with coordinates (1, 1), and Rubik stands in a cell wi... | 2 | 11 | #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... | CPP |
214_E. Relay Race | 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 in a cell with coordinates (1, 1), and Rubik stands in a cell wi... | 2 | 11 | #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;
}
}
}... | CPP |
214_E. Relay Race | 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 in a cell with coordinates (1, 1), and Rubik stands in a cell wi... | 2 | 11 | #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 ... | CPP |
214_E. Relay Race | 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 in a cell with coordinates (1, 1), and Rubik stands in a cell wi... | 2 | 11 | #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... | CPP |
214_E. Relay Race | 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 in a cell with coordinates (1, 1), and Rubik stands in a cell wi... | 2 | 11 | #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];
... | CPP |
214_E. Relay Race | 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 in a cell with coordinates (1, 1), and Rubik stands in a cell wi... | 2 | 11 | #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] =... | CPP |
214_E. Relay Race | 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 in a cell with coordinates (1, 1), and Rubik stands in a cell wi... | 2 | 11 | #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... | CPP |
238_E. Meeting Her | 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 restaurant in junction b. He wants to use public transportation... | 2 | 11 | #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... | CPP |
238_E. Meeting Her | 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 restaurant in junction b. He wants to use public transportation... | 2 | 11 | #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] || ... | CPP |
238_E. Meeting Her | 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 restaurant in junction b. He wants to use public transportation... | 2 | 11 | #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]) {
... | CPP |
238_E. Meeting Her | 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 restaurant in junction b. He wants to use public transportation... | 2 | 11 | #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... | CPP |
238_E. Meeting Her | 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 restaurant in junction b. He wants to use public transportation... | 2 | 11 | #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... | CPP |
238_E. Meeting Her | 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 restaurant in junction b. He wants to use public transportation... | 2 | 11 | #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 ... | CPP |
238_E. Meeting Her | 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 restaurant in junction b. He wants to use public transportation... | 2 | 11 | #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... | CPP |
238_E. Meeting Her | 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 restaurant in junction b. He wants to use public transportation... | 2 | 11 | #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... | CPP |
238_E. Meeting Her | 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 restaurant in junction b. He wants to use public transportation... | 2 | 11 | #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 ... | CPP |
238_E. Meeting Her | 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 restaurant in junction b. He wants to use public transportation... | 2 | 11 | #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... | CPP |
238_E. Meeting Her | 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 restaurant in junction b. He wants to use public transportation... | 2 | 11 | #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() ... | CPP |
238_E. Meeting Her | 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 restaurant in junction b. He wants to use public transportation... | 2 | 11 | #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);... | CPP |
238_E. Meeting Her | 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 restaurant in junction b. He wants to use public transportation... | 2 | 11 | #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] =... | CPP |
238_E. Meeting Her | 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 restaurant in junction b. He wants to use public transportation... | 2 | 11 | #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] ... | CPP |
238_E. Meeting Her | 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 restaurant in junction b. He wants to use public transportation... | 2 | 11 | #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, ... | CPP |
238_E. Meeting Her | 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 restaurant in junction b. He wants to use public transportation... | 2 | 11 | #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)... | CPP |
238_E. Meeting Her | 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 restaurant in junction b. He wants to use public transportation... | 2 | 11 | #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--,... | CPP |
238_E. Meeting Her | 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 restaurant in junction b. He wants to use public transportation... | 2 | 11 | #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... | CPP |
238_E. Meeting Her | 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 restaurant in junction b. He wants to use public transportation... | 2 | 11 | #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] = ... | CPP |
238_E. Meeting Her | 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 restaurant in junction b. He wants to use public transportation... | 2 | 11 | #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... | CPP |
238_E. Meeting Her | 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 restaurant in junction b. He wants to use public transportation... | 2 | 11 | #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] =... | CPP |
238_E. Meeting Her | 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 restaurant in junction b. He wants to use public transportation... | 2 | 11 | #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... | CPP |
238_E. Meeting Her | 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 restaurant in junction b. He wants to use public transportation... | 2 | 11 | #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... | CPP |
238_E. Meeting Her | 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 restaurant in junction b. He wants to use public transportation... | 2 | 11 | #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),... | CPP |
238_E. Meeting Her | 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 restaurant in junction b. He wants to use public transportation... | 2 | 11 | #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;
... | CPP |
238_E. Meeting Her | 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 restaurant in junction b. He wants to use public transportation... | 2 | 11 | #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... | CPP |
238_E. Meeting Her | 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 restaurant in junction b. He wants to use public transportation... | 2 | 11 | #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;
}... | CPP |
238_E. Meeting Her | 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 restaurant in junction b. He wants to use public transportation... | 2 | 11 | #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... | CPP |
238_E. Meeting Her | 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 restaurant in junction b. He wants to use public transportation... | 2 | 11 | #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];
... | CPP |
238_E. Meeting Her | 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 restaurant in junction b. He wants to use public transportation... | 2 | 11 | #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... | CPP |
238_E. Meeting Her | 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 restaurant in junction b. He wants to use public transportation... | 2 | 11 | #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... | CPP |
238_E. Meeting Her | 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 restaurant in junction b. He wants to use public transportation... | 2 | 11 | #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,... | CPP |
238_E. Meeting Her | 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 restaurant in junction b. He wants to use public transportation... | 2 | 11 | #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]... | CPP |
238_E. Meeting Her | 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 restaurant in junction b. He wants to use public transportation... | 2 | 11 | #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] ... | CPP |
238_E. Meeting Her | 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 restaurant in junction b. He wants to use public transportation... | 2 | 11 | #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... | CPP |
238_E. Meeting Her | 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 restaurant in junction b. He wants to use public transportation... | 2 | 11 | #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... | CPP |
238_E. Meeting Her | 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 restaurant in junction b. He wants to use public transportation... | 2 | 11 | #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... | CPP |
238_E. Meeting Her | 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 restaurant in junction b. He wants to use public transportation... | 2 | 11 | #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;
... | CPP |
238_E. Meeting Her | 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 restaurant in junction b. He wants to use public transportation... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
void readi(int &x) {
int v = 0, f = 1;
char c = getchar();
while (!isdigit(c) && c != '-') c = getchar();
if (c == '-')
f = -1;
else
v = v * 10 + c - '0';
while (isdigit(c = getchar())) v = v * 10 + c - '0';
x = v * f;
}
void readll(long long &x) {
l... | CPP |
238_E. Meeting Her | 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 restaurant in junction b. He wants to use public transportation... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
const int maxn = 201;
int read() {
int x = 0, f = 1;
char ch = getchar();
while (ch < '0' || ch > '9') {
if (ch == '-') f = -1;
ch = getchar();
}
while (ch >= '0' && ch <= '9') {
x = x * 10 + ch - '0';
ch = getchar();
}
return x * f;
}
int n, m... | CPP |
238_E. Meeting Her | 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 restaurant in junction b. He wants to use public transportation... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const int MAXN = 105;
int n, m, a, b;
int dis[MAXN][MAXN];
int ans[MAXN], temp[MAXN];
vector<int> ms[MAXN];
vector<int> vec[MAXN][MAXN];
int s[MAXN], t[MAXN];
void solved(int cas) {
int x, y;
scanf("%d %d %d %d", &n, &m, &a, &b);
memset(dis... | CPP |
238_E. Meeting Her | 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 restaurant in junction b. He wants to use public transportation... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
const int maxn = 105;
vector<int> G1[maxn];
int n, m, a, b, q, mp[maxn][maxn], must[maxn][maxn], num[maxn];
int dist[maxn], vis[maxn], p[maxn], fb[maxn], tb[maxn], dp[maxn], Md[maxn];
struct Heap {
int u, d;
Heap(int _u = 0, int _d = 0) {
u = _u;
d = _d;
}
b... | CPP |
238_E. Meeting Her | 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 restaurant in junction b. He wants to use public transportation... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
int i, j, k, n, m, S, T, x, y, num;
int a[110][110], b[110][110], s[110], t[110], an[110], h[110], f[110],
c[110][110];
int dfs(int x, int y) {
if (h[x] == num) return f[x];
h[x] = num;
int i, ans = -1;
for (i = 1; i <= n; i++)
if (a[x][i] == 1 && a[x][i] + ... | CPP |
238_E. Meeting Her | 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 restaurant in junction b. He wants to use public transportation... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
inline int read() {
int sum = 0;
char c = getchar();
bool f = 0;
while (c < '0' || c > '9') {
if (c == '-') f = 1;
c = getchar();
}
while (c >= '0' && c <= '9') {
sum = sum * 10 + c - '0';
c = getchar();
}
if (f) return -sum;
return sum;
}
... | CPP |
238_E. Meeting Her | 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 restaurant in junction b. He wants to use public transportation... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
int i, j, k, n, m, S, T, x, y, num;
int a[110][110], b[110][110], s[110], t[110], an[110], h[110], f[110],
c[110][110];
int dfs(int x, int y) {
if (h[x] == num) return f[x];
h[x] = num;
int i, ans = -1;
for (i = 1; i <= n; i++)
if (a[x][i] == 1 && a[x][i] + ... | CPP |
238_E. Meeting Her | 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 restaurant in junction b. He wants to use public transportation... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
const int N = 110;
const int inf = 100000000;
int dis[N][N], c[N][N], res[N];
int s[N], t[N], tmp[N], ans[N];
int n, m, vs, vt, x, y, tim;
int dfs(int x, int y) {
if (tmp[x] == tim) return res[x];
tmp[x] = tim;
int mx = -1;
for (int i = 1; i <= n; i++)
if (dis[x... | CPP |
238_E. Meeting Her | 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 restaurant in junction b. He wants to use public transportation... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
vector<int> e[101];
int n, m, a, b, k, s[101], t[101], r[101], d[101][101], seen[101], next_seen;
bool must[101][101];
int main() {
scanf("%d %d %d %d", &n, &m, &a, &b);
for (int i = 1; i <= n; i++)
for (int j = 1; j <= n; j++) d[i][j] = i == j ? 0 : 1000000000;
w... | CPP |
238_E. Meeting Her | 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 restaurant in junction b. He wants to use public transportation... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
const int MAXN = 100 + 10, INF = INT_MAX / 2;
int n, m, a, b, dis[MAXN][MAXN], dp[MAXN][MAXN], cnt[MAXN];
vector<int> adj[MAXN], g[MAXN][MAXN], vec[MAXN];
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin >> n >> m >> a >> b, a--, b--;
for (i... | CPP |
238_E. Meeting Her | 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 restaurant in junction b. He wants to use public transportation... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
bool debug = false;
int n, m, k;
int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
long long ln, lk, lm;
int dis[105][105];
int S, T, ans[105], cnt, h[105], f[105];
int b[105][105], must[105][105];
vector<pair<int, int>> bus;
int dfs(int x, int t) {
if (h[x] == cnt) retur... | CPP |
238_E. Meeting Her | 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 restaurant in junction b. He wants to use public transportation... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
const int N = 105, inf = 1e9;
int n, d[N][N], c, m, s[N], t[N], v[N], g[N][N], p[N], q[N], e[N][N];
int dfs(int a, int k) {
if (v[a] == c) return q[a];
v[a] = c, q[a] = -1;
for (int i = 1; i <= n; i++)
if (d[a][i] == 1 && d[a][t[k]] == d[i][t[k]] + 1)
q[a] =... | CPP |
238_E. Meeting Her | 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 restaurant in junction b. He wants to use public transportation... | 2 | 11 | #include <bits/stdc++.h>
template <class K>
inline bool chkmin(K &a, K b) {
return a > b ? a = b, true : false;
}
template <class K>
inline bool chkmax(K &a, K b) {
return a < b ? a = b, true : false;
}
using namespace std;
const int oo = 0x3f3f3f3f;
const int maxn = 200 + 1;
int N, M, K, G[maxn][maxn], path[maxn][... | CPP |
238_E. Meeting Her | 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 restaurant in junction b. He wants to use public transportation... | 2 | 11 | #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 ... | CPP |
238_E. Meeting Her | 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 restaurant in junction b. He wants to use public transportation... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
const int maxn = 205;
int n, m, K, T, dis[maxn][maxn], A, B, s[maxn], t[maxn];
int cnt, head[maxn], to[maxn * maxn], nex[maxn * maxn];
int tot[maxn], tmp[maxn], tp;
int stk[maxn], l;
bool bj[maxn][maxn];
int dp[maxn], DP[maxn], vis[maxn];
void add(int x, int y) {
to[++cnt... | CPP |
238_E. Meeting Her | 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 restaurant in junction b. He wants to use public transportation... | 2 | 11 | import static java.util.Arrays.fill;
import java.io.*;
import java.util.*;
public class E {
private static void solve() throws IOException {
int n = nextInt(), edges = nextInt();
int goFrom = nextInt() - 1, goTo = nextInt() - 1;
boolean[][] can = new boolean[n][n];
for (int i = 0; i < edges; i++) {
int f... | JAVA |
238_E. Meeting Her | 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 restaurant in junction b. He wants to use public transportation... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
int D[110][110], n, m, q, E[110];
vector<int> A[110][110];
int Res[110];
vector<int> M[110];
int CM[110][110];
int main() {
int i, j, v, nv, l, k, a, b, q, v1, v2;
bool fl = 1;
scanf("%d%d%d%d", &n, &m, &a, &b), a--, b--;
for (i = 0; i < n; i++)
for (j = 0; j < ... | CPP |
238_E. Meeting Her | 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 restaurant in junction b. He wants to use public transportation... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
const int maxN = 105;
const int maxM = maxN * maxN;
const int INF = 0x3f3f3f3f;
int a[maxN][maxN];
int b[maxN][maxN];
int c[maxN][maxN];
int s[maxN];
int t[maxN];
int ans[maxN];
int g[maxN], f[maxN];
int N, M, S, T;
int cnt;
int dfs(int x, int y) {
if (g[x] == cnt) return... | CPP |
238_E. Meeting Her | 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 restaurant in junction b. He wants to use public transportation... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
int Get() {
char c;
while (c = getchar(), c < '0' || c > '9')
;
int X = 0;
while (c >= '0' && c <= '9') {
X = X * 10 + c - 48;
c = getchar();
}
return X;
}
const int inf = 1000000000;
int main() {
int N = Get(), M = Get(), S = Get() - 1, T = Get() ... | CPP |
238_E. Meeting Her | 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 restaurant in junction b. He wants to use public transportation... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
const int maxn = 105;
int h[maxn], H[maxn][maxn], n, fi, se, m, qq, amad[maxn][maxn], dp[maxn],
Ans[maxn];
bool mad[maxn];
bool e[maxn];
pair<long long, long long> a[maxn];
queue<int> q;
vector<int> v[maxn], g[maxn], kh, ert[maxn][maxn];
void dfs(int i, int R) {
for (... | CPP |
238_E. Meeting Her | 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 restaurant in junction b. He wants to use public transportation... | 2 | 11 | #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... | CPP |
238_E. Meeting Her | 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 restaurant in junction b. He wants to use public transportation... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
int g[105][105];
int n, m, S, T;
int d[105][105], cnt[105][105] = {0};
int U[105], V[105];
int nu;
int f[105][105];
int lef[105][105] = {0};
int vis[105][105] = {0};
int on(int u, int s, int t) {
if (d[s][u] + d[u][t] != d[s][t]) return 0;
if (cnt[s][u] * cnt[u][t] == c... | CPP |
238_E. Meeting Her | 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 restaurant in junction b. He wants to use public transportation... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
const int N = 109;
const int INF = 0x3f3f3f3f;
int m, n, a, b;
int dis[N][N];
int sv[N], tv[N], s, t;
vector<int> to[N];
bool reachable[N], tmp[N];
bool dfs(int now) {
if (reachable[now]) {
return true;
}
if (now == t) {
return false;
}
int siz = to[now].s... | CPP |
238_E. Meeting Her | 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 restaurant in junction b. He wants to use public transportation... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
inline int read() {
int sum = 0;
char c = getchar();
bool f = 0;
while (c < '0' || c > '9') {
if (c == '-') f = 1;
c = getchar();
}
while (c >= '0' && c <= '9') {
sum = sum * 10 + c - '0';
c = getchar();
}
if (f) return -sum;
return sum;
}
... | CPP |
238_E. Meeting Her | 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 restaurant in junction b. He wants to use public transportation... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
constexpr int N = 100 + 10;
constexpr int MOD = 1e9 + 7;
int n, m, a, b, dist[N], main_dist[N][N], u, v, s[N], t[N], limit,
new_dist[N][N];
vector<int> node[N], bus[N];
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin >> n >> m >> a >>... | CPP |
238_E. Meeting Her | 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 restaurant in junction b. He wants to use public transportation... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
int vis[105], T, num[105], dp[105], f[105][105], n, m, K, DP[105], s[105],
t[105];
bool b[105][105];
int min(int a, int b) { return a < b ? a : b; }
int max(int a, int b) { return a > b ? a : b; }
int dfs(int u, int k) {
if (vis[u] == T) return DP[u];
int tmp = -1;
... | CPP |
238_E. Meeting Her | 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 restaurant in junction b. He wants to use public transportation... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
const int N = 100 + 5;
const int inf = 1e9;
int f[N][N], n, m, A, B, nb;
int S[N], T[N];
vector<int> pss[N][N];
int res[N], t[N];
void relax(int &a, int b) {
if (a < b) a = b;
}
void upd(int &a, int b) {
if (a > b) a = b;
}
void floyd() {
for (int i = 1; i <= n; i++)
... | CPP |
238_E. Meeting Her | 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 restaurant in junction b. He wants to use public transportation... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
const int maxn = 100;
int dist[maxn][maxn];
int d[maxn][maxn];
int used[maxn][maxn];
vector<vector<int> > es;
int bus[maxn][maxn];
int cnt[maxn];
int main() {
int n, m, a, b;
while (scanf("%d%d%d%d", &n, &m, &a, &b) >= 1) {
--a, --b;
es = vector<vector<int> >(n)... | CPP |
238_E. Meeting Her | 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 restaurant in junction b. He wants to use public transportation... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
template <class T>
inline void read(T& num) {
num = 0;
bool f = true;
char ch = getchar();
while (ch < '0' || ch > '9') {
if (ch == '-') f = false;
ch = getchar();
}
while (ch >= '0' && ch <= '9') {
num = num * 10 + ch - '0';
ch = getchar();
}
... | CPP |
238_E. Meeting Her | 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 restaurant in junction b. He wants to use public transportation... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
int n, m, A, B, inf = 1e9, f[110][110], x, y, K, g[110][110], Cnt[110],
d[110][110];
bool vis[110][110], V[110][110], Must[110][110];
vector<int> E1[110], E2[110], E[110][110];
queue<pair<int, int> > h;
void read(int &x) {
char ch = getchar();
int mark =... | CPP |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.