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
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 inf = INT_MAX / 4; int n, m, k, s[MAXN], t[MAXN], d[MAXN][MAXN], a, b, h[MAXN], dp[MAXN][MAXN]; vector<int> maybe[MAXN], must[MAXN], adj[MAXN], nxt[MAXN][MAXN]; bool visit[MAXN]; inline void get() { cin >> n >> m >> a >> b; 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; const int inf = 0x03030303; int n, m, dis[120][120], ans[120], x, y, i, j, k, s, t, q, tail[120], tmp[120], f[120]; bool must[120][120], bo[120]; int dfs(int x, int t) { if (x == t) return ans[t]; if (bo[x]) return f[x]; bo[x] = 1; f[x] = 0; for (int i = 1; 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> 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 n, m, K, S, T, tot; int f[110][110], num[110][110], go[110][110], s[110], t[110], Ans[110], Dp[110]; int Vis[110]; inline int read() { int x = 0, f = 1; char ch = getchar(); while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); } 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; const int maxn = 100 + 15; int n, m, s, t, x, y, k; int a[maxn][maxn]; int c[maxn][maxn]; int b[maxn][maxn]; int f[maxn]; int ls[maxn]; int xx[maxn], yy[maxn]; int vis[maxn], sum; int done(int x, int y) { if (vis[x] == sum) return ls[x]; vis[x] = sum; int ans = -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; inline int read() { int x = 0, f = 1; char c = getchar(); while (!isdigit(c)) { if (c == '-') f = -f; c = getchar(); } while (isdigit(c)) { x = x * 10 + c - '0'; c = getchar(); } return x * f; } const int maxn = 1e2 + 5; int vis[maxn], NOW, num...
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; #pragma GCC optimize("O2,no-stack-protector,unroll-loops,fast-math") const long long maxn = 1e2 + 10, maxm = 1e5 + 10, lg = 20, mod = 1e9 + 7, inf = 1e18; long long n, m, a, b, K, dp[maxn], pd[maxn]; vector<pair<long long, long long> > bus; long long g[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; int n, m, p, S, T; int dis[105][105], tmp[105], vis[105], tme; int ans[105], s[105], t[105], c[105][105], mark[105]; inline int rd() { int x = 0, f = 1; char ch = getchar(); while (ch > '9' || ch < '0') { if (ch == '-') f = -1; ch = getchar(); } while (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 N = 105; int f[N][N], ans[N], rp[N], S, T, s[N], t[N], n, m, k, vis[N], cho; int must[N][N]; int ct[N][N]; int dfs(int x, int y) { if (vis[x] == cho) return rp[x]; vis[x] = cho; int res = -1; for (int j = (1); j <= (int)n; j++) if (f[x][j] == 1 && f[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; const int MAXN = 101, MAXM = 10001; int n, m, S, T, s[MAXN], t[MAXN], vis[MAXN], dis[MAXN][MAXN], dp[MAXN], g[MAXN], e, K; bool pass[MAXN][MAXN]; int dfs(int u, int M) { if (u == M) return dp[M]; if (vis[u]) return g[u]; vis[u] = 1; g[u] = 0; for (int i = 1; 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 = 100 + 7; const int inf = 0x3f3f3f3f; const long long INF = 0x3f3f3f3f3f3f3f3f; const int mod = 1e9 + 7; const double eps = 1e-8; const double PI = acos(-1); template <class T, class S> inline void add(T &a, S b) { a += b; if (a >= mod) a -= mod; } template...
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; int d[111][111]; int ans[111]; int k; int s[111]; int t[111]; bool g[111][111]; int r[111]; int main() { cin >> n >> m >> a >> b; a--, b--; for (int i = (0); i < (n); i++) for (int j = (0); j < (n); j++) { if (i == j) d[i][j] = 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; struct Edge { int next, to; } ed[10000 + 5]; int last[100 + 5], inf = 1e9, dp[100 + 5][100 + 5], dis[100 + 5][100 + 5], s[100 + 5], t[100 + 5], n, m, q, ecnt = 0, a, b; bool must[100 + 5][100 + 5], vis[100 + 5][100 + 5]; void add(int u, int v) { ed[++...
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 Num> inline void read(Num &x) { char c; int flag = 1; while ((c = getchar()) < '0' || c > '9') if (c == '-') flag = -1; x = c - '0'; while ((c = getchar()) >= '0' && c <= '9') x = x * 10 + c - '0'; x *= flag; } template <class Num> inline voi...
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, c = getchar(), f = 0; for (; c > '9' || c < '0'; f = c == '-', c = getchar()) ; for (; c >= '0' && c <= '9'; x = (x << 1) + (x << 3) + c - '0', c = getchar()) ; return f ? -x : x; } inline void write(int x) { if (x < 0) putch...
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, c = getchar(), f = 0; for (; c > '9' || c < '0'; f = c == '-', c = getchar()) ; for (; c >= '0' && c <= '9'; x = (x << 1) + (x << 3) + c - '0', c = getchar()) ; return f ? -x : x; } inline void write(int x) { if (x < 0) putch...
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, q, st, fn, dis[((int)105)][((int)105)]; int s[((int)105)], t[((int)105)], d[((int)105)][((int)105)], out[((int)105)][((int)105)]; vector<int> vec[((int)105)][((int)105)]; bool change[((int)105)][((int)105)], mark[((int)105)][((int)105)]; deque<pair<int, 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> int may[110][110][110]; int dis[110][110]; int app[110][110]; int n, m, a, b, k; int s[110], t[110]; int cost[110][110], cnt[110][110]; int q1[10010], q2[10010], head, tail; int h[110]; bool done() { int i, j, s, val, flag = 0; for (i = 1; i <= k; ++i) for (j = 1; j <= n; ++j) { f...
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 + 77; int n, m, S, T, t, Es[N], Et[N], d[N][N], dp[N], f[N]; bool E[N][N]; vector<int> V[N]; int main() { memset(d, 50, sizeof d); memset(dp, 50, sizeof dp); scanf("%d %d %d %d", &n, &m, &S, &T); dp[T] = 0; for (int i = 1; i <= n; ++i) d[i][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 MN = 105, INF = 200; int n, m, dis[MN][MN], d[MN][MN], st[MN], fn[MN], mark[MN]; vector<int> good[MN], all[MN], vec[INF]; void floyd() { for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) dis[i][j] = INF; for (int i = 0; i < n; i++) dis[i][i] = 0; f...
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; const int maxn = 201; 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; 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
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; int st, fin, n, m, i, j, k, q, kt; int a[N][N], b[N][N][N], g[N][N], ta[N], tb[N], ans[N], v[N]; vector<int> u[N][N]; int main() { scanf("%d%d%d%d", &n, &m, &st, &fin); st--, fin--; memset(a, 0, sizeof(a)); for (i = 0; i < m; ++i) { int qs, qf...
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> int n, m, a, b; int map[107][107]; int s[107], t[107]; int need[107][107]; int cnt[107], ans[107]; bool vis[107]; int tmp[107]; int f(int x, int y) { if (vis[x] == 1) return tmp[x]; vis[x] = 1; int now = -1; for (int i = 1; i <= n; ++i) { if (map[x][i] == 1 && map[x][t[y]] == map[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 long long maxn = 101; const long long mod = 1e9 + 7; const long long inf = 1e9 + 500; long long ger[maxn][maxn]; long long minn[maxn][maxn]; long long mint[maxn][maxn]; long long dp[maxn]; long long hazf[maxn]; long long n; void del(long long a) { hazf[a] = 1; f...
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 java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.LinkedList; import java.util.Queue; import java.util.StringTokenizer; import java.util.TreeMap; public...
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; const int N = 110; int st, fin, n, m, i, j, k, q, kt; int a[N][N], b[N][N][N], g[N][N], ta[N], tb[N], ans[N], v[N]; vector<int> u[N][N]; int main() { scanf("%d%d%d%d", &n, &m, &st, &fin); st--, fin--; memset(a, 0, sizeof(a)); for (i = 0; i < m; ++i) { int qs, qf...
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 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 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 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] == cnt[s][t]) return 2; ret...
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 = 1 << 25; int n, m, s, t, T, dis[maxn][maxn], Dp[maxn], dp[maxn]; int A[maxn], B[maxn], cnt, vis[maxn], ss[maxn * 2]; bool b[maxn][maxn]; int dfs(int u, int k) { if (vis[u] == cnt) return Dp[u]; int tmp = -1; vis[u] = cnt; 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; const int MAXN = 100 + 10; int n, m, a, b, k, di[MAXN]; int Q_[MAXN], L_, R_; bool mark[MAXN]; vector<int> pars[MAXN]; struct sp { int len = 0; vector<vector<int>> levels; vector<int> cntl; vector<int> distl; vector<int> befor(int id) { vector<int> rs; 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; const int maxn = 110; const int INF = 0x3f3f3f3f; int n, m, a, b, t; int from[maxn], to[maxn]; int dist[maxn][maxn]; int incur[maxn][maxn]; bool vis[maxn]; int g[maxn], f[maxn]; int dfs(int cur, int aim) { if (cur == aim) return f[cur]; if (vis[cur] == true) return g[cu...
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; constexpr int N = 100 + 10; constexpr int MOD = 1e9 + 7; long long 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 >...
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 = 111; int st, fin, n, m, i, j, k, q, kt; int a[N][N], b[N][N][N], g[N][N], ta[N], tb[N], ans[N], v[N]; vector<int> u[N][N]; int main() { scanf("%d %d %d %d", &n, &m, &st, &fin); st--; fin--; memset(a, 0, sizeof(a)); for (i = 0; i < m; i++) { int q...
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 d[109][109], n, m, dis[109][109], must[109][109]; vector<int> Next[109][109], V[109]; int main() { int a, b; memset(d, 0x3f, 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 = 0; 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 inf = 0x3f3f3f3f, N = 105; int n, m, k, cnt, fl[N], num[N], dp[N], dp2[N], s[N], t[N], f[N][N]; bool vis[N][N]; inline int dfs(int x, int k) { if (fl[x] == cnt) return dp2[x]; int res = -1; fl[x] = cnt; for (int y = 1; y <= n; ++y) if (f[x][y] == 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 INF = 0x3f3f3f3f; const int inf = 0x3f; const int MAXN = 105; int g[MAXN][MAXN]; int s[MAXN], t[MAXN]; int D[MAXN], bs[MAXN]; bool can[MAXN][MAXN]; int main() { int n, m, a, b, k; scanf("%d%d%d%d", &n, &m, &a, &b); --a, --b; memset(g, inf, sizeof(g)); fo...
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 f[109][109], n, m, s, t, b_num, dp[109], vis[109], Dp[109], T; map<int, int> mp; struct bus { int s, t; int vis[109]; vector<int> q; void st() { memset(vis, 0, sizeof(vis)); int cnt = 0; for (int now : q) vis[now] = f[s][now] + 1; } } b[109]; int 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; int d[200][200], b[200][200], n, m, inf = 1e9, k, U[200], V[200], child[200][200], dp[200][200], S, T, pd[200][200], A[50000], B[50000], way[200][200]; int onpath(int k1, int k2, int k3) { if (d[k1][k2] + d[k2][k3] != d[k1][k3]) return 0; if (way[k1][k2] * way[k...
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]; int n, m, S, T; int tot[105], wz[105]; int q; int p[105]; int st[105], en[105]; bool ok[105][105]; int ans[105]; int bz[105], totnum; int f[105]; int dfs(int w, int to) { if (bz[w] == totnum) return f[w]; bz[w] = totnum; int ret = -1; 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> G1[maxn]; int n, m, a, b, q, mp[maxn][maxn], must[maxn][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; } bool operato...
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 B_INF = 0x3f; const int MAXN = 105; int g[MAXN][MAXN]; int s[MAXN], t[MAXN]; int ans[MAXN], bs[MAXN]; bool can[MAXN][MAXN]; int main() { int n, m, a, b, k; scanf("%d%d%d%d", &n, &m, &a, &b); --a, --b; memset(g, B_INF, 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 maxn = 110; const int INF = 0x3f3f3f3f; int n, m, a, b, t; int from[maxn], to[maxn]; int dist[maxn][maxn]; int incur[maxn][maxn]; bool vis[maxn]; int g[maxn], f[maxn]; int dfs(int cur, int aim) { if (cur == aim) return f[cur]; if (vis[cur] == true) return g[cu...
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> int vis[105], T, num[105], Dp[105], f[105][105], n, m, 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; vis[u] = T; for (int 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; const long double pi = 3.14159265359; template <typename T> T abs(T x) { return x > 0 ? x : -x; } template <typename T> T sqr(T x) { return x * x; } template <typename T> void chmin(T &x, T y) { x = min(x, y); } template <typename T> void chmax(T &x, T y) { x = 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; template <typename T> bool updmn(T& A, const T& B) { return A > B ? A = B, 1 : 0; } template <typename T> bool updmx(T& A, const T& B) { return A < B ? A = B, 1 : 0; } const int INF = 0x3f3f3f3f; const int maxn = 110; const int maxb = 110; int n, m, S, T; int G[maxn][ma...
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 = 1e9; const long long INF = 1e18; const int maxn = 110; int S[maxn], T[maxn], b[maxn][maxn], d[maxn][maxn], f[maxn], g[maxn], h[maxn]; vector<int> G[maxn][maxn]; int main() { int n, m, s, t; scanf("%d%d%d%d", &n, &m, &s, &t); s--; t--; 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 = 100; int dist[maxn][maxn]; int d[maxn][maxn]; int used[maxn][maxn]; vector<vector<int> > es; int bus[maxn][maxn], onlybus[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 = ve...
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 MN = 105, INF = 200; int n, m, dis[MN][MN], d[MN][MN], st[MN], fn[MN], mark[MN]; vector<int> good[MN], all[MN], vec[INF]; void floyd() { for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) dis[i][j] = INF; for (int i = 0; i < n; i++) dis[i][i] = 0; f...
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 + 10; const int inf = 1e8; vector<int> adj[N], vec[N], g[N][N]; int dis[N][N], dp[N][N], cnt[N]; int main() { ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0); int n, m, a, b; cin >> n >> m >> a >> b; a--; b--; for (int i = 0; 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> #pragma GCC optimize("Ofast,no-stack-protector,unroll-loops") #pragma GCC optimize("no-stack-protector,fast-math") using namespace std; const long long N = 200, OO = 1e9 + 7, T = 1e6 + 10, mod = 1e9 + 7, P = 6151, SQ = 280, lg = 70; long long dis[N], s[N], t[N], dp[N][N], dk[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; 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; int inf = 1e9; int dist[111][111]; bool must[111][111]; int ans[111]; int from[111], to[111]; int f[111]; bool vis[111]; int n, m, q, s, t; int dfs(int x, int y) { if (x == y) return ans[y]; if (vis[x]) return f[x]; vis[x] = 1; f[x] = 0; 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; int dis[111][111], dp[111][111]; vector<int> g[111], bus[111]; int bx[111], by[111], m, n, t, src, des; bool pass[111][111]; int main() { int u, v; scanf("%d%d%d%d", &n, &m, &src, &des); for (int i = 1; i <= n; i++) for (int j = 1; j <= n; j++) if (i != j) 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 long long MAXN = 1e2 + 10; const long long INF = 1e9 + 10; vector<long long> dag[MAXN][MAXN]; vector<long long> f[MAXN]; vector<long long> e[MAXN]; vector<long long> in[MAXN]; vector<long long> out[MAXN]; queue<long long> q; long long s[MAXN]; long long t[MAXN]; long ...
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> u[101][101]; int dis[101][101]; int fr[101], to[101]; int ans[101], c[101]; int main() { int n, m, a, b; scanf("%d%d%d%d", &n, &m, &a, &b); memset(dis, 0x23, sizeof(dis)); memset(ans, 0x23, sizeof(ans)); for (int i = 0; i < m; i++) { int u, 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; const int N = 1e4, M = 1e5; int gi() { int w = 0; bool q = 1; char c = getchar(); while ((c < '0' || c > '9') && c != '-') c = getchar(); if (c == '-') q = 0, c = getchar(); while (c >= '0' && c <= '9') w = w * 10 + c - '0', c = getchar(); return q ? w : -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 = 110, INF = 1e9; long long n, m, a, b, k, s[maxn], t[maxn], dist[maxn][maxn], dis[maxn], ans[maxn]; vector<int> vec[maxn], edges[maxn]; queue<int> q; bool mark[maxn], vis[maxn]; inline void setdist() { for (int i = 0; i < maxn; ++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; int n, m, g[1100][1100], S, T, s[1100], t[1100], dp[1100], cnt[1100], Ans[1100]; bool cut[1100][1100], vis[1100]; inline int read() { int x = 0, f = 1; char ch = getchar(); while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); } while (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> #pragma GCC optimize("O2") using namespace std; const int N = 1e2 + 5; const long long mod = 1e9 + 7; const long long mod2 = 998244353; const long long inf = 8e18; const int LOG = 22; long long pw(long long a, long long b, long long M) { return (!b ? 1 : (b & 1 ? (a * pw(a * 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 n, m, a, b, k, d[111][111], s[111], t[111], r[111], now, seen, used[111]; bool must[111][111]; int main() { cin >> n >> m >> a >> b; a--, b--; for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) if (i != j) d[i][j] = 1000000000; for (int i = 0; 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; const int inf = 1 << 29; int dis[maxn][maxn]; int s[maxn], t[maxn]; int a, b, n, m, p, f[maxn], g[maxn]; vector<int> juc[maxn][maxn]; bool judge(int u, int v, int w) { return dis[u][v] == dis[u][w] + dis[w][v]; } 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> using namespace std; template <class T> inline void read(T& x) { bool fu = 0; char c; for (c = getchar(); c <= 32; c = getchar()) ; if (c == '-') fu = 1, c = getchar(); for (x = 0; c > 32; c = getchar()) x = x * 10 + c - '0'; if (fu) x = -x; }; template <class T> inline void rea...
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 N = 109; int a, b, n, m, f[N][N], dp[N][N], ways[N][N], s[N], q[N * N][2], deg[N][N], t[N]; bool inq[N][N]; inline int onpath(int x, int s, int t) { if (f[s][x] + f[x][t] != f[s][t]) return 0; return 1 + (ways[s][x] * ways[x][t] == ways[s][t]); } int main() { scanf("%d%d%d%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; 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 Maxn = 105, inf = 999999999 + 208; int n, m, st, en, dist[Maxn][Maxn]; int aim[Maxn], tot; int f[Maxn], g[Maxn]; bool iscut[Maxn][Maxn], visi[Maxn]; int dfs(int cur, int aim) { if (cur == aim) return f[cur]; if (visi[cur]) return g[cur]; visi[cur] = 1; g[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 inf = ~0U >> 1; const long long INF = ~0ULL >> 1; template <class T> inline void read(T &n) { char c; for (c = getchar(); !(c >= '0' && c <= '9'); c = getchar()) ; n = c - '0'; for (c = getchar(); c >= '0' && c <= '9'; c = getchar()) n = n * 10 + 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 = 105; const int INF = 1e8; int n, m, start, fin; int d[N][N], en[N]; int cnt[N], dp[N][N]; bool has[N][N]; bool must[N][N]; vector<int> out[N]; int main() { scanf("%d%d%d%d", &n, &m, &start, &fin); memset(d, 63, sizeof d); for (int i = 1; i <= n; i++) d[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 MAX_N = 100 + 10, INF = ~0U >> 3; const int MOD = int(1e9) + 7; int n, m, vs, vt; int dist[MAX_N][MAX_N], cnt[MAX_N][MAX_N]; int nB; int st[MAX_N], ed[MAX_N]; bool e[MAX_N][MAX_N]; int dp[MAX_N][MAX_N]; bool mustPass(int u, int v, int mid) { return dist[u][mid] ...
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> int n, m, N; int f[105][105], dp[105], Dp[105], vis[105]; int s[105], t[105], num[105], b[105][105]; int dfs(int x, int y) { if (vis[x] == N) return Dp[x]; int tmp = -1; vis[x] = N; for (int i = 1; i <= n; ++i) if (f[x][i] == 1 && f[x][t[y]] == f[i][t[y]] + 1) tmp = std::max(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; int n, m, s, t, u, v, f[110], dis[110][110], q[110], head, tail, cnt[110][110]; bool flag[110], cut[110][110]; struct edge { int v; edge *nxt; } pool[20100], *tp = pool, *fst1[110], *fst2[110]; void dfs(int x, int k) { flag[x] = 1; for (edge *i = fst1[x]; i; i = 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
import java.io.IOException; import java.util.Arrays; import java.util.InputMismatchException; import java.util.ArrayList; import java.io.OutputStream; import java.io.PrintWriter; import java.util.Queue; import java.util.LinkedList; import java.util.Collection; import java.io.InputStream; /** * Built using CHelper plu...
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
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.LinkedList; import java.util.Queue; import java.util.StringTokenizer; import java.util.TreeMap; public...
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; const int N = 105, inf = 1e9; int n, m, st, ed; int G[N][N]; vector<int> g[N][N]; int s[N], t[N], K; vector<int> bus[N]; vector<int> *vv; int cnt[N], vis[N], TOT; bool MOB[N][N]; bool *uu, Good[N][N], Flag[N]; bool dfs(int u) { if (vis[u] == TOT) return uu[u]; vis[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; template <class T> inline void upmax(T& a, T b) { if (a < b) a = b; } template <class T> inline void upmin(T& a, T b) { if (a > b) a = b; } const int maxn = 103; const int maxm = 200007; const int mod = 1000000007; const int inf = 0x7fffffff; const double eps = 1e-7; ty...
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_N(105); const int Max_K(105); int N, M, S, T, G[Max_N][Max_N], K, A[Max_K], B[Max_K], Cnt[Max_N]; bool Must[Max_K][Max_N]; int Dist[Max_N][Max_K]; bool InQ[Max_N][Max_K]; vector<pair<int, int> > Go[Max_N][Max_K]; bool update(int u, int x) { int Ret(0); 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; const int N = 110; int n, m, s, t, d[N][N], ans[N][N], deg[N][N]; bool vis[N][N]; vector<int> who[N], adj[N]; vector<int> upd[N][N]; int main() { ios::sync_with_stdio(false), cin.tie(0), cout.tie(0); cin >> n >> m >> s >> t; --s, --t; for (int i = 0; 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 N = 110; const int INF = 0x3f3f3f3f; int n, m, a, b, bk; int g[N][N], g2[N][N], tg[N][N]; int flg[N][N]; int S[N], T[N]; int f[N], h[N], vi[N]; inline bool ckmin(int &a, int b) { return b < a ? a = b, 1 : 0; } inline bool on(int a, int u, int v) { return g[u][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> const int maxn = 105; const int INF = 1e9; using namespace std; int n, m, a, b, k; int f[maxn][maxn], dis[maxn][maxn], d[maxn][maxn]; int e[maxn * maxn][2], s[maxn], t[maxn]; bool sure[maxn][maxn]; vector<int> adj[maxn]; void floyd(int out, int f[][maxn]) { for (int i = 0; i < n; i++) { f...
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[int(1e2) + 10][int(1e2) + 10]; vector<pair<int, int> > com[int(1e2) + 10]; int n, m, s, e; int ans[int(1e2) + 10], tt[int(1e2) + 10]; bool mark[int(1e2) + 10]; int dfs(int v, int tail) { if (v == tail) return ans[v]; if (mark[v]) return tt[v]; mark[v] = true; ...
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() { char ch = getchar(); long long ret = 0, sgn = 1; while (ch < '0' || ch > '9') { if (ch == '-') sgn = -1; ch = getchar(); } while (ch >= '0' && ch <= '9') ret = ret * 10 + ch - '0', ch = getchar(); return ret * sgn; } inline void o...
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 + 2; int dis[maxn][maxn], cnt[maxn], ans[maxn][maxn], inf = 1e8; vector<int> adj[maxn], bus[maxn], nei[maxn][maxn]; int main() { int n, m, a, b; cin >> n >> m >> a >> b; a--; b--; for (int i = 0; i < n; i++) { for (int j = 0; j < n; 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; int n, m, a, b, dist[111][111], from[111], to[111], ans, f[111], g[111], t; bool can[111][111], visit[111]; inline int dfs(int x, int aim) { if (x == aim) return f[x]; if (visit[x] == true) return g[x]; visit[x] = true; g[x] = 0; for (int i = 1; i <= n; i++) 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; void debug_out() { cerr << '\n'; } template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) { cerr << " " << H; debug_out(T...); } const long long MAXN = 1e2 + 10, INF = 1e9; long long n, m, k, a, b, u, v, floyd[MAXN][MAXN], second[MAXN], t[MAXN], ...
CPP
263_C. Circle of Numbers
One day Vasya came up to the blackboard and wrote out n distinct integers from 1 to n in some order in a circle. Then he drew arcs to join the pairs of integers (a, b) (a ≠ b), that are either each other's immediate neighbors in the circle, or there is number c, such that a and с are immediate neighbors, and b and c ar...
2
9
#include <bits/stdc++.h> using namespace std; const int MAX = 100005; const int INF = 1 << 28; const double EPS = 1e-7; int N; int v[MAX]; bool mark[MAX]; vector<int> G[MAX]; map<int, set<int> > M; bool fill(int a, int b, int c) { v[0] = a; v[1] = 1; v[2] = b; v[3] = c; for (int i = 1; i <= (N); ++i) mark[i] ...
CPP
263_C. Circle of Numbers
One day Vasya came up to the blackboard and wrote out n distinct integers from 1 to n in some order in a circle. Then he drew arcs to join the pairs of integers (a, b) (a ≠ b), that are either each other's immediate neighbors in the circle, or there is number c, such that a and с are immediate neighbors, and b and c ar...
2
9
//package C; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; import java.util.TreeSet; public class Solution { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st; int n, an; int[][...
JAVA
263_C. Circle of Numbers
One day Vasya came up to the blackboard and wrote out n distinct integers from 1 to n in some order in a circle. Then he drew arcs to join the pairs of integers (a, b) (a ≠ b), that are either each other's immediate neighbors in the circle, or there is number c, such that a and с are immediate neighbors, and b and c ar...
2
9
#include <bits/stdc++.h> using namespace std; long long int inf = 1e18; long long int p = 1e9 + 7; long long int power(long long int x, long long int y, long long int p) { long long int res = 1; x = x % p; while (y > 0) { if (y & 1) res = (res * x) % p; y = y >> 1; x = (x * x) % p; } return res; }...
CPP
263_C. Circle of Numbers
One day Vasya came up to the blackboard and wrote out n distinct integers from 1 to n in some order in a circle. Then he drew arcs to join the pairs of integers (a, b) (a ≠ b), that are either each other's immediate neighbors in the circle, or there is number c, such that a and с are immediate neighbors, and b and c ar...
2
9
#include <bits/stdc++.h> using namespace std; long long abs1(long long h) { if (h < 0) return -h; else return h; } int main() { long long i, j, n, m, e, k, ot, x, y, i1, i2, i3, i4; vector<int> a, q, g; vector<vector<int> > w; vector<int> d; cin >> n; for (i = 0; i <= n + 4; i++) { q.push_ba...
CPP
263_C. Circle of Numbers
One day Vasya came up to the blackboard and wrote out n distinct integers from 1 to n in some order in a circle. Then he drew arcs to join the pairs of integers (a, b) (a ≠ b), that are either each other's immediate neighbors in the circle, or there is number c, such that a and с are immediate neighbors, and b and c ar...
2
9
#include <bits/stdc++.h> using namespace std; set<int> C[100010]; vector<int> G[100010]; int n, per[100010], cnt, vst[100010]; bool dfs(int a, int b, int f) { per[cnt++] = b; if (cnt == n + 1) return b == 1; for (int i = 0; i < 4; i++) { int u = G[b][i]; if (C[a].count(u) && u != f) { if (cnt != n &...
CPP
263_C. Circle of Numbers
One day Vasya came up to the blackboard and wrote out n distinct integers from 1 to n in some order in a circle. Then he drew arcs to join the pairs of integers (a, b) (a ≠ b), that are either each other's immediate neighbors in the circle, or there is number c, such that a and с are immediate neighbors, and b and c ar...
2
9
import java.util.*; import java.io.*; import java.awt.Point; import java.math.BigInteger; import static java.lang.Math.*; // Solution is at the bottom of code public class _C implements Runnable{ final boolean ONLINE_JUDGE = System.getProperty("ONLINE_JUDGE") != null; BufferedReader in; OutputWriter out; S...
JAVA
263_C. Circle of Numbers
One day Vasya came up to the blackboard and wrote out n distinct integers from 1 to n in some order in a circle. Then he drew arcs to join the pairs of integers (a, b) (a ≠ b), that are either each other's immediate neighbors in the circle, or there is number c, such that a and с are immediate neighbors, and b and c ar...
2
9
#include <bits/stdc++.h> using namespace std; int n, p[100005], ady[100005][4], cnt = 1; bool used[100005]; bool dfs(int nd, int t) { used[nd] = true; if (++cnt == n) { p[nd] = 1; return true; } for (int i = 0; i < 4; ++i) { if (!used[ady[nd][i]]) { p[nd] = ady[nd][i]; for (int j = 0; j ...
CPP
263_C. Circle of Numbers
One day Vasya came up to the blackboard and wrote out n distinct integers from 1 to n in some order in a circle. Then he drew arcs to join the pairs of integers (a, b) (a ≠ b), that are either each other's immediate neighbors in the circle, or there is number c, such that a and с are immediate neighbors, and b and c ar...
2
9
#include <bits/stdc++.h> using namespace std; vector<vector<int> > T; pair<int, int> find_tris(int a, int b) { int w[2] = {-1, -1}, sz = 0; for (int x : T[a]) { for (int y : T[b]) { if (x == y) { w[sz++] = y; break; } } } return pair<int, int>(w[0], w[1]); } bool uneq(int a, ...
CPP
263_C. Circle of Numbers
One day Vasya came up to the blackboard and wrote out n distinct integers from 1 to n in some order in a circle. Then he drew arcs to join the pairs of integers (a, b) (a ≠ b), that are either each other's immediate neighbors in the circle, or there is number c, such that a and с are immediate neighbors, and b and c ar...
2
9
import java.io.*; import java.util.*; public class C { static void solve() throws IOException { int n = nextInt(); int[] a = new int[2 * n]; int[] b = new int[2 * n]; for (int i = 0; i < 2 * n; i++) { a[i] = nextInt() - 1; b[i] = nextInt() - 1; } int[] answer = solve(a, b, n); if (answer == null)...
JAVA
263_C. Circle of Numbers
One day Vasya came up to the blackboard and wrote out n distinct integers from 1 to n in some order in a circle. Then he drew arcs to join the pairs of integers (a, b) (a ≠ b), that are either each other's immediate neighbors in the circle, or there is number c, such that a and с are immediate neighbors, and b and c ar...
2
9
#include <bits/stdc++.h> using namespace std; const double pi = acos(-1); const int n_ = 1e5 + 5; int n, taken[n_]; vector<int> adj[n_], ans; bool ok() { int a = 1, b = 2, f; for (int i = 3; i < n; i++, a++, b++) { f = 0; for (int x : adj[ans[a]]) { if (taken[x]) continue; if (binary_search(adj[...
CPP
263_C. Circle of Numbers
One day Vasya came up to the blackboard and wrote out n distinct integers from 1 to n in some order in a circle. Then he drew arcs to join the pairs of integers (a, b) (a ≠ b), that are either each other's immediate neighbors in the circle, or there is number c, such that a and с are immediate neighbors, and b and c ar...
2
9
import java.io.OutputStreamWriter; import java.io.BufferedWriter; import java.util.Locale; import java.io.OutputStream; import java.util.RandomAccess; import java.io.PrintWriter; import java.util.AbstractList; import java.io.Writer; import java.util.List; import java.io.IOException; import java.util.Arrays; import java...
JAVA
263_C. Circle of Numbers
One day Vasya came up to the blackboard and wrote out n distinct integers from 1 to n in some order in a circle. Then he drew arcs to join the pairs of integers (a, b) (a ≠ b), that are either each other's immediate neighbors in the circle, or there is number c, such that a and с are immediate neighbors, and b and c ar...
2
9
#include <bits/stdc++.h> #pragma warning(disable : 4996) #pragma comment(linker, "/STACK:666000000") using namespace std; const int INF = (1 << 30) - 1; const long double EPS = 1e-9; void ML(const bool v) { if (v) return; int *ass; for (;;) { ass = new int[2500000]; for (int i = 0; i < 2500000; i++) ass[i...
CPP
263_C. Circle of Numbers
One day Vasya came up to the blackboard and wrote out n distinct integers from 1 to n in some order in a circle. Then he drew arcs to join the pairs of integers (a, b) (a ≠ b), that are either each other's immediate neighbors in the circle, or there is number c, such that a and с are immediate neighbors, and b and c ar...
2
9
#include <bits/stdc++.h> using namespace std; template <typename T, typename U> inline void smin(T &a, U b) { if (a > b) a = b; } template <typename T, typename U> inline void smax(T &a, U b) { if (a < b) a = b; } template <class T> inline void gn(T &first) { char c, sg = 0; while (c = getchar(), (c > '9' || c ...
CPP