buggy_code
stringlengths
11
625k
fixed_code
stringlengths
17
625k
bug_type
stringlengths
2
4.45k
language
int64
0
8
token_count
int64
5
200k
from collections import defaultdict import sys sys.setrecursionlimit(100000) def seq(): a = 1 while True: yield a a += 1 def dfs(here, went, connect, discovery, low, answer, seq): went |= {here} discovery[here] = low[here] = next(seq) child = 0 for con in connect[here]: ...
from collections import defaultdict import sys sys.setrecursionlimit(100000) def seq(): a = 1 while True: yield a a += 1 def dfs(here, went, connect, discovery, low, answer, seq): went |= {here} discovery[here] = low[here] = next(seq) child = 0 for con in connect[here]: ...
[["-", 36, 36, 0, 656, 0, 7, 12, 652, 63, 22], ["+", 36, 36, 0, 656, 0, 7, 12, 652, 63, 22], ["-", 0, 7, 8, 196, 0, 7, 12, 652, 63, 22], ["+", 0, 7, 8, 196, 0, 7, 12, 652, 63, 22]]
5
359
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef vector<int> vint; typedef pair<int, int> pint; typedef vector<pint> vpint; #define rep(i, n) for (int i = 0; i < (n); i++) #define reps(i, f, n) for (int i = (f); i < (n); i++) #define each(it, v) ...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef vector<int> vint; typedef pair<int, int> pint; typedef vector<pint> vpint; #define rep(i, n) for (int i = 0; i < (n); i++) #define reps(i, f, n) for (int i = (f); i < (n); i++) #define each(it, v) ...
[["-", 0, 1, 0, 2, 63, 118, 28, 69, 28, 22], ["+", 0, 1, 0, 2, 63, 118, 28, 69, 28, 22], ["+", 0, 7, 8, 9, 0, 57, 64, 9, 0, 45], ["+", 0, 7, 8, 9, 0, 57, 64, 9, 0, 46]]
1
560
#include <algorithm> #include <cassert> #include <climits> #include <cmath> #include <complex> #include <cstdio> #include <cstring> #include <ctime> #include <deque> #include <iomanip> #include <iostream> #include <limits> #include <list> #include <map> #include <queue> #include <set> #include <stack> #include <string>...
#include <algorithm> #include <cassert> #include <climits> #include <cmath> #include <complex> #include <cstdio> #include <cstring> #include <ctime> #include <deque> #include <iomanip> #include <iostream> #include <limits> #include <list> #include <map> #include <queue> #include <set> #include <stack> #include <string>...
[["+", 51, 91, 28, 69, 341, 342, 0, 69, 28, 22], ["+", 28, 69, 341, 342, 0, 69, 341, 342, 0, 70], ["+", 28, 69, 341, 342, 0, 69, 341, 342, 0, 73]]
1
996
#include <bits/stdc++.h> using namespace std; struct SCC { int V; vector<vector<int>> G, rG; vector<int> vs, used, cmp; SCC() {} SCC(int sz) : V(sz), G(sz), rG(sz), used(sz), cmp(sz) {} void add(int from, int to) { G[from].push_back(to); rG[to].push_back(from); } void dfs(int v) { used[v] =...
#include <bits/stdc++.h> using namespace std; struct SCC { int V; vector<vector<int>> G, rG; vector<int> vs, used, cmp; SCC() {} SCC(int sz) : V(sz), G(sz), rG(sz), used(sz), cmp(sz) {} void add(int from, int to) { G[from].push_back(to); rG[to].push_back(from); } void dfs(int v) { used[v] =...
[["-", 0, 14, 8, 9, 0, 37, 0, 69, 28, 22], ["+", 0, 14, 8, 9, 0, 37, 0, 69, 28, 22]]
1
488
#include <cstdio> #include <map> #include <vector> using namespace std; vector<int> G[20000]; vector<int> rG[20000]; int id[20000]; int rid[20000]; int cid[20000]; void enume(int s, int &n) { if (id[s]) return; id[s] = -1; for (int t : G[s]) enume(t, n); id[s] = ++n; rid[n] = s; } void dfs(int s, in...
#include <cstdio> #include <map> #include <vector> using namespace std; vector<int> G[20000]; vector<int> rG[20000]; int id[20000]; int rid[20000]; int cid[20000]; void enume(int s, int &n) { if (id[s]) return; id[s] = -1; for (int t : G[s]) enume(t, n); id[s] = ++n; rid[n] = s; } void dfs(int s, in...
[["-", 8, 9, 0, 7, 10, 43, 49, 50, 51, 22], ["+", 8, 9, 0, 7, 10, 43, 49, 50, 51, 22]]
1
345
#define _CRT_SECURE_NO_WARNINGS #define _USE_MATH_DEFINES #include <algorithm> #include <cctype> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <string> #includ...
#define _CRT_SECURE_NO_WARNINGS #define _USE_MATH_DEFINES #include <algorithm> #include <cctype> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <string> #includ...
[["+", 12, 2, 63, 118, 28, 69, 341, 342, 0, 70], ["+", 12, 2, 63, 118, 28, 69, 341, 342, 0, 22], ["+", 12, 2, 63, 118, 28, 69, 341, 342, 0, 73]]
1
893
from sys import exit import queue V,E = [int(n) for n in input().split()] ans = [] # N = int(input()) graph = [[] for _ in range(V)] indeg = [0]*E yet = [True]*E def bfs(s): q = queue.Queue() q.put(s) while(not q.empty()): u = q.get() ans.append(u) yet[u]=False for v in grap...
from sys import exit import queue V,E = [int(n) for n in input().split()] ans = [] # N = int(input()) graph = [[] for _ in range(V)] indeg = [0]*V yet = [True]*V def bfs(s): q = queue.Queue() q.put(s) while(not q.empty()): u = q.get() ans.append(u) yet[u]=False for v in grap...
[["-", 0, 656, 0, 1, 0, 662, 12, 657, 12, 22], ["+", 0, 656, 0, 1, 0, 662, 12, 657, 12, 22], ["-", 0, 656, 0, 7, 12, 652, 3, 4, 0, 22], ["+", 0, 656, 0, 7, 12, 652, 3, 4, 0, 22]]
5
220
# -*- coding: utf-8 -*- import sys import os import pprint from queue import Queue """Topological Sort""" #fd = os.open('GRL_4_B.txt', os.O_RDONLY) #os.dup2(fd, sys.stdin.fileno()) V, E = list(map(int, input().split())) G = [[] for i in range(V)] indig = [0] * V # ??\?¬???° for i in range(V): s, t = list(map(in...
# -*- coding: utf-8 -*- import sys import os import pprint from queue import Queue """Topological Sort""" #fd = os.open('GRL_4_B_5.txt', os.O_RDONLY) #os.dup2(fd, sys.stdin.fileno()) V, E = list(map(int, input().split())) G = [[] for i in range(V)] indig = [0] * V # ??\?¬???° for i in range(E): s, t = list(map(...
[["-", 0, 656, 0, 7, 12, 652, 3, 4, 0, 22], ["+", 0, 656, 0, 7, 12, 652, 3, 4, 0, 22]]
5
207
#include <iostream> #include <queue> #include <vector> using namespace std; static const int MAX = 10000; static const int INFTY = (1 << 20); int n; int d[MAX]; class Edge { public: int t, w; Edge() {} Edge(int t, int w) : t(t), w(w) {} }; vector<Edge> G[MAX]; void bfs(int s) { for (int i = 0; i < n; i++) {...
#include <iostream> #include <queue> #include <vector> using namespace std; static const int MAX = 100000; static const int INFTY = (1 << 20); int n; int d[MAX]; class Edge { public: int t, w; Edge() {} Edge(int t, int w) : t(t), w(w) {} }; vector<Edge> G[MAX]; void bfs(int s) { for (int i = 0; i < n; i++) ...
[["-", 36, 36, 0, 30, 0, 43, 49, 50, 51, 13], ["+", 36, 36, 0, 30, 0, 43, 49, 50, 51, 13]]
1
434
#include <iostream> #include <vector> using namespace std; template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; } struct Edge { int from, to, weight; Edge(int f, int t, int w) : from(f), to(t), weight(w) {} }; using Edges = vector<Edge>; using Graph = v...
#include <iostream> #include <vector> using namespace std; template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; } struct Edge { int from, to, weight; Edge(int f, int t, int w) : from(f), to(t), weight(w) {} }; using Edges = vector<Edge>; using Graph = v...
[["+", 8, 9, 0, 43, 49, 50, 51, 4, 0, 24], ["+", 8, 9, 0, 43, 49, 50, 51, 4, 0, 13], ["+", 8, 9, 0, 43, 49, 50, 51, 4, 0, 21], ["+", 8, 9, 0, 43, 49, 50, 51, 4, 0, 22], ["+", 8, 9, 0, 43, 49, 50, 51, 4, 0, 25]]
1
383
#include <algorithm> #include <iostream> #include <vector> using namespace std; const int maxN = 1e5 + 100; int n, m; vector<pair<int, int>> g[maxN]; int mx1[maxN], mx2[maxN]; bool mark[maxN]; #define mp make_pair void input() { cin >> n; for (int i = 1; i <= n - 1; i++) { int k1, k2, w; cin >> k1 >> k2 >...
#include <algorithm> #include <iostream> #include <vector> using namespace std; const int maxN = 1e5 + 100; int n, m; vector<pair<int, int>> g[maxN]; int mx1[maxN], mx2[maxN]; bool mark[maxN]; #define mp make_pair void input() { cin >> n; for (int i = 1; i <= n - 1; i++) { int k1, k2, w; cin >> k1 >> k2 >...
[["-", 3, 4, 0, 16, 31, 69, 341, 342, 0, 13], ["+", 3, 4, 0, 16, 31, 69, 341, 342, 0, 22], ["-", 3, 4, 0, 16, 12, 69, 341, 342, 0, 13], ["+", 3, 4, 0, 16, 12, 69, 341, 342, 0, 22]]
1
350
#include <algorithm> #include <cstdio> #include <functional> #include <iostream> #include <map> #include <queue> #include <string> #include <vector> #define ll long long #define inf 999999999 #define pa pair<int, int> using namespace std; int n; vector<pa> a[100100]; vector<pa> ed; int d[100100]; void dfs(int u, int...
#include <algorithm> #include <cstdio> #include <functional> #include <iostream> #include <map> #include <queue> #include <string> #include <vector> #define ll long long #define inf 999999999 #define pa pair<int, int> using namespace std; int n; vector<pa> a[100100]; vector<pa> ed; int d[100100]; void dfs(int u, int...
[["-", 8, 9, 0, 1, 0, 16, 31, 16, 12, 22], ["+", 8, 9, 0, 1, 0, 16, 31, 16, 12, 22], ["+", 8, 9, 0, 7, 15, 16, 12, 16, 17, 33], ["+", 8, 9, 0, 7, 15, 16, 12, 16, 12, 13]]
1
396
#include <algorithm> #include <cmath> #include <cstdio> #include <cstring> #include <iostream> #include <map> #include <queue> #include <set> #include <sstream> #include <string> #include <utility> #include <vector> #define loop(i, a, b) for (int i = a; i < b; i++) #define rep(i, a) loop(i, 0, a) #define pb push_back #...
#include <algorithm> #include <cmath> #include <cstdio> #include <cstring> #include <iostream> #include <map> #include <queue> #include <set> #include <sstream> #include <string> #include <utility> #include <vector> #define loop(i, a, b) for (int i = a; i < b; i++) #define rep(i, a) loop(i, 0, a) #define pb push_back #...
[["-", 8, 123, 0, 14, 8, 9, 0, 43, 39, 40]]
1
531
#include <algorithm> #include <cassert> #include <cctype> #include <cmath> #include <cstdio> #include <cstring> #include <functional> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <vector> #define rep(i, a) REP(i, 0,...
#include <algorithm> #include <cassert> #include <cctype> #include <cmath> #include <cstdio> #include <cstring> #include <functional> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <vector> #define rep(i, a) REP(i, 0,...
[["-", 0, 14, 8, 9, 0, 1, 0, 16, 17, 152], ["-", 0, 14, 8, 9, 0, 1, 0, 16, 12, 22]]
1
453
#include <algorithm> #include <array> #include <cstdio> #include <functional> #include <iostream> #include <list> #include <numeric> #include <queue> #include <sstream> #include <stack> #include <string> #include <utility> #include <vector> #define _USE_MATH_DEFINES #include <map> #include <math.h> #define SENTINEL 1...
#include <algorithm> #include <array> #include <cstdio> #include <functional> #include <iostream> #include <list> #include <numeric> #include <queue> #include <sstream> #include <stack> #include <string> #include <utility> #include <vector> #define _USE_MATH_DEFINES #include <map> #include <math.h> #define SENTINEL 1...
[["-", 8, 9, 0, 1, 0, 2, 63, 118, 28, 22], ["-", 8, 9, 0, 1, 0, 2, 63, 118, 17, 131], ["-", 8, 9, 0, 1, 0, 2, 63, 118, 119, 120], ["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 24], ["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 25], ["-", 8, 9, 0, 7, 8, 9, 0, 1, 0, 35]]
1
578
#include <stdio.h> int main(void) { int i, j, k, n, t, l, r, ans = 0, now = 0; scanf("%d%d", &n, &t); int num[t + 2]; for (i = 0; i <= t; ++i) num[i] = 0; for (i = 0; i < n; ++i) { scanf("%d%d", &l, &r); num[l]++, num[r + 1]--; } for (i = 0; i <= t; ++i) { now += num[i]; if (ans < now...
#include <stdio.h> int main(void) { int i, j, k, n, t, l, r, ans = 0, now = 0; scanf("%d%d", &n, &t); int num[t + 1]; for (i = 0; i <= t; ++i) num[i] = 0; for (i = 0; i < n; ++i) { scanf("%d%d", &l, &r); num[l]++, num[r]--; } for (i = 0; i <= t; ++i) { now += num[i]; if (ans < now) ...
[["-", 8, 9, 0, 43, 49, 80, 81, 16, 12, 13], ["+", 8, 9, 0, 43, 49, 80, 81, 16, 12, 13], ["-", 12, 27, 28, 69, 341, 342, 0, 16, 17, 72], ["-", 12, 27, 28, 69, 341, 342, 0, 16, 12, 13]]
1
160
#include <bits/stdc++.h> #define lp(i, n) for (int i = 0; i < n; i++) #define lpin(a, i, n) \ for (int i = 0; i < n; i++) { \ cin >> a[i]; \ } us...
#include <bits/stdc++.h> #define lp(i, n) for (int i = 0; i < n; i++) #define lpin(a, i, n) \ for (int i = 0; i < n; i++) { \ cin >> a[i]; \ } us...
[["-", 36, 36, 0, 30, 0, 43, 49, 80, 81, 13], ["+", 36, 36, 0, 30, 0, 43, 49, 80, 81, 13], ["-", 0, 11, 31, 69, 341, 342, 0, 16, 17, 72], ["-", 0, 11, 31, 69, 341, 342, 0, 16, 12, 13], ["-", 0, 14, 8, 9, 0, 7, 15, 16, 12, 13], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 12, 13]]
1
152
#include <algorithm> #include <iostream> using namespace std; int a[100010]; int main() { int N, T, e, q, maxn = 0; cin >> N >> T; for (int i = 0; i < N; i++) { cin >> e >> q; a[e]++; a[q]--; } for (int i = 1; i <= T; i++) { a[i] += a[i - 1]; maxn = max(maxn, a[i]); } cout << maxn <<...
#include <algorithm> #include <iostream> using namespace std; int a[100010]; int main() { int N, T, e, q, maxn = 0; cin >> N >> T; for (int i = 0; i < N; i++) { cin >> e >> q; a[e]++; a[q]--; } for (int i = 1; i <= T + 1; i++) { a[i] += a[i - 1]; maxn = max(maxn, a[i - 1]); } cout <<...
[["+", 8, 9, 0, 7, 15, 16, 12, 16, 17, 72], ["+", 8, 9, 0, 7, 15, 16, 12, 16, 12, 13], ["+", 3, 4, 0, 69, 341, 342, 0, 16, 17, 33], ["+", 3, 4, 0, 69, 341, 342, 0, 16, 12, 13]]
1
122
#include <bits/stdc++.h> using namespace std; #define REP(i, n) for (int i = 0; i < n; i++) int main() { cin.tie(0); ios::sync_with_stdio(false); int n, t; cin >> n >> t; vector<int> A(t + 2, 0); REP(i, n) { int l, r; cin >> l >> r; A[l]++; A[r + 1]--; } for (int i = 1; i <= t + 1; i...
#include <bits/stdc++.h> using namespace std; #define REP(i, n) for (int i = 0; i < n; i++) int main() { cin.tie(0); ios::sync_with_stdio(false); int n, t; cin >> n >> t; vector<int> A(t + 1, 0); REP(i, n) { int l, r; cin >> l >> r; A[l]++; A[r]--; } for (int i = 1; i <= t + 1; i++) ...
[["-", 0, 43, 49, 50, 51, 4, 0, 16, 12, 13], ["+", 0, 43, 49, 50, 51, 4, 0, 16, 12, 13], ["-", 0, 27, 28, 69, 341, 342, 0, 16, 17, 72], ["-", 0, 27, 28, 69, 341, 342, 0, 16, 12, 13]]
1
154
#include <bits/stdc++.h> using namespace std; #define REP(i, n) for (int i = 0; i < (n); i++) #define REAP(i, a, n) for (int i = (a); i < (n); i++) #define YES cout << "Yes" << endl #define NO cout << "No" << endl #define fr first #define sc second #define pb push_back #define All(v) v.begin(), v.end() typedef long lo...
#include <bits/stdc++.h> using namespace std; #define REP(i, n) for (int i = 0; i < (n); i++) #define REAP(i, a, n) for (int i = (a); i < (n); i++) #define YES cout << "Yes" << endl #define NO cout << "No" << endl #define fr first #define sc second #define pb push_back #define All(v) v.begin(), v.end() typedef long lo...
[["+", 8, 9, 0, 43, 49, 50, 51, 69, 28, 22], ["+", 0, 43, 49, 50, 51, 69, 341, 342, 0, 70], ["+", 0, 43, 49, 50, 51, 69, 341, 342, 0, 73]]
1
162
from itertools import accumulate n, t = map(int, input().split()) a = [0] * (t + 2) for l, r in (map(int, input().split()) for _ in range(n)): a[l] += 1 a[r + 1] -= 1 print(max(accumulate(a)))
from itertools import accumulate n, t = map(int, input().split()) a = [0] * (t + 1) for l, r in (map(int, input().split()) for _ in range(n)): a[l] += 1 a[r] -= 1 print(max(accumulate(a)))
[["-", 0, 662, 12, 657, 12, 23, 0, 657, 12, 612], ["+", 0, 662, 12, 657, 12, 23, 0, 657, 12, 612], ["-", 0, 1, 0, 677, 31, 206, 206, 657, 17, 72], ["-", 0, 1, 0, 677, 31, 206, 206, 657, 12, 612]]
5
82
#include <bits/stdc++.h> using namespace std; signed main() { int n, ma[1111][1111] = {}; cin >> n; for (int i = 0; i < n; i++) { int x1, y1, x2, y2; cin >> x1 >> y1 >> x2 >> y2; ma[x1][y1]++; ma[x1][y2]--; ma[x2][y1]--; ma[x1][y2]++; } for (int i = 0; i <= 1001; i++) for (int j = ...
#include <bits/stdc++.h> using namespace std; signed main() { int n, ma[1111][1111] = {}; cin >> n; for (int i = 0; i < n; i++) { int x1, y1, x2, y2; cin >> x1 >> y1 >> x2 >> y2; ma[x1][y1]++; ma[x1][y2]--; ma[x2][y1]--; ma[x2][y2]++; } for (int i = 0; i <= 1001; i++) for (int j = ...
[["-", 0, 27, 28, 69, 28, 69, 341, 342, 0, 22], ["+", 0, 27, 28, 69, 28, 69, 341, 342, 0, 22], ["-", 3, 4, 0, 69, 28, 69, 341, 342, 0, 22], ["+", 0, 69, 28, 69, 341, 342, 0, 16, 31, 22], ["+", 0, 69, 28, 69, 341, 342, 0, 16, 17, 33], ["+", 0, 69, 28, 69, 341, 342, 0, 16, 12, 13], ["-", 12, 2, 3, 4, 0, 69, 341, 342, 0, ...
1
224
#include <iostream> #include <vector> struct Square { int x1, y1, x2, y2; }; std::istream &operator>>(std::istream &is, Square &s) { return is >> s.x1 >> s.y1 >> s.x2 >> s.y2; } int main() { int n; std::cin >> n; constexpr int max_coord = 1000; std::vector<std::vector<int>> map(max_coord + 1, ...
#include <iostream> #include <vector> struct Square { int x1, y1, x2, y2; }; std::istream &operator>>(std::istream &is, Square &s) { return is >> s.x1 >> s.y1 >> s.x2 >> s.y2; } int main() { int n; std::cin >> n; constexpr int max_coord = 1000; std::vector<std::vector<int>> map(max_coord + 1, ...
[["-", 64, 1, 0, 11, 12, 69, 341, 342, 0, 13], ["+", 64, 1, 0, 11, 12, 69, 341, 342, 0, 22]]
1
367
import java.io.*; import java.util.Arrays; class Main { static final int INF = Integer.MAX_VALUE / 2; static final PrintWriter out = new PrintWriter(System.out); static class Edge { int from; int to; int cost; Edge(int from, int to, int cost) { this.from = from; this.to = to; ...
import java.io.*; import java.util.Arrays; class Main { static final int INF = Integer.MAX_VALUE / 2; static final PrintWriter out = new PrintWriter(System.out); static class Edge { int from; int to; int cost; Edge(int from, int to, int cost) { this.from = from; this.to = to; ...
[["-", 15, 15, 0, 16, 12, 16, 12, 504, 516, 22], ["-", 15, 15, 0, 16, 12, 16, 12, 504, 0, 70], ["-", 15, 15, 0, 16, 12, 16, 12, 504, 0, 73], ["-", 0, 1, 0, 11, 12, 16, 12, 504, 516, 22], ["-", 0, 1, 0, 11, 12, 16, 12, 504, 0, 70], ["-", 0, 1, 0, 11, 12, 16, 12, 504, 0, 73]]
3
525
#include <bits/stdc++.h> #define REP(i, n) for (long long i = 0; i < (n); i++) using namespace std; template <typename V, typename Weight> class Dijekstra { private: struct edge { Weight dist; V node; V prev; bool operator<(edge const &a) const { return dist < a.dist; } bool operator>(edge const &...
#include <bits/stdc++.h> #define REP(i, n) for (long long i = 0; i < (n); i++) using namespace std; template <typename V, typename Weight> class Dijekstra { private: struct edge { Weight dist; V node; V prev; bool operator<(edge const &a) const { return dist < a.dist; } bool operator>(edge const &...
[["-", 8, 9, 0, 1, 0, 2, 63, 118, 119, 120], ["+", 8, 9, 0, 1, 0, 2, 63, 118, 119, 120]]
1
619
/* ダイトストラ法自作ライブラリ*/ /* option1:経路復元 => TRACE_ROUTE定義,trace配列に復元情報 option2:全頂点への最短距離 => ALL_VERTEX定義,ans配列に情報*/ /*頂点の開始番号を気をつける必要なし*/ #include <bits/stdc++.h> #define REP(i, n) for (long i = 0; i < (n); i++) #define FOR(i, a, b) for (long i = (a); i < (b); i++) #define dump1d_arr(array, i) ...
/* ダイトストラ法自作ライブラリ*/ /* option1:経路復元 => TRACE_ROUTE定義,trace配列に復元情報 option2:全頂点への最短距離 => ALL_VERTEX定義,ans配列に情報*/ /*頂点の開始番号を気をつける必要なし*/ #include <bits/stdc++.h> #define REP(i, n) for (long i = 0; i < (n); i++) #define FOR(i, a, b) for (long i = (a); i < (b); i++) #define dump1d_arr(array, i) ...
[["+", 0, 1, 0, 2, 3, 4, 0, 16, 17, 33], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 12, 13]]
1
661
#include <bits/stdc++.h> #define ff first #define ss second #define pb push_back using namespace std; typedef long long ll; const ll INF = 0x3f3f3f3f3f3f3f3f; ll d[100005]; int n, m, r; vector<pair<ll, int>> G[100005]; priority_queue<pair<ll, int>, vector<pair<ll, int>>, greater<pair<ll, int>>> pq; int main() { cin...
#include <bits/stdc++.h> #define ff first #define ss second #define pb push_back using namespace std; typedef long long ll; const ll INF = 0x3f3f3f3f3f3f3f3f; ll d[100005]; int n, m, r; vector<pair<ll, int>> G[100005]; priority_queue<pair<ll, int>, vector<pair<ll, int>>, greater<pair<ll, int>>> pq; int main() { cin...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 31, 22], ["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 18], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 18], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 22], ["-", 0, 83, 0, 69, 341, 342, 0, 118, 119, 120], ["+", 0, 83, 0, 69, 341, 342, 0, 118, 119, 120]]
1
337
#include <bits/stdc++.h> #define INF 1000000000 using namespace std; typedef pair<int, int> pii; namespace MyLib { class Dijkstra { struct edge { int to, cost; edge(int to_, int cost_) : to(to_), cost(cost_) {} }; bool isdirected; vector<int> d; vector<vector<edge>> G; int V, E; public: Dijkstra...
#include <bits/stdc++.h> #define INF 1000000000 using namespace std; typedef pair<int, int> pii; namespace MyLib { class Dijkstra { struct edge { int to, cost; edge(int to_, int cost_) : to(to_), cost(cost_) {} }; bool isdirected; vector<int> d; vector<vector<edge>> G; int V, E; public: Dijkstra...
[["-", 0, 14, 0, 357, 0, 358, 0, 4, 0, 22], ["+", 0, 14, 0, 357, 0, 358, 0, 4, 0, 22]]
1
510
#include <bits/stdc++.h> using namespace std; int m, n, r; vector<pair<int, int>> graph[100010]; int dist[100010] = {}; int main() { cin >> n >> m >> r; int a, b, c; for (int i = 0; i < m; i++) { cin >> a >> b >> c; graph[a].push_back(make_pair(b, c)); } queue<pair<int, int>> que; for (int i = ...
#include <bits/stdc++.h> using namespace std; int m, n, r; vector<pair<int, int>> graph[100010]; int dist[100010] = {}; int main() { cin >> n >> m >> r; int a, b, c; for (int i = 0; i < m; i++) { cin >> a >> b >> c; graph[a].push_back(make_pair(b, c)); } queue<pair<int, int>> que; for (int i = ...
[["-", 64, 1, 0, 16, 31, 16, 12, 5, 0, 6], ["+", 64, 1, 0, 16, 31, 16, 12, 5, 0, 6]]
1
352
#include <bits/stdc++.h> using namespace std; #define int long long const int N = 2e5; const int INF = 1e9; typedef pair<int, int> P; struct edge { int to, cost; }; vector<edge> G[N]; void dikstra(int s, int V) { priority_queue<P, vector<P>, greater<P>> que; int d[N]; // sからの最短距離 fill(d, d + N, INF); d[s] ...
#include <bits/stdc++.h> using namespace std; #define int long long const int N = 2e5; const int INF = 1e9; typedef pair<int, int> P; struct edge { int to, cost; }; vector<edge> G[N]; void dikstra(int s, int V) { priority_queue<P, vector<P>, greater<P>> que; int d[N]; // sからの最短距離 fill(d, d + N, INF); d[s] ...
[["+", 64, 1, 0, 16, 31, 16, 12, 5, 0, 62]]
1
363
#include "bits/stdc++.h" using namespace std; typedef long long lint; #define MAXN 100010 // d,edge,g,P,q lint d[MAXN]; struct edge { int to; lint cost; }; vector<edge> g[MAXN]; typedef pair<lint, int> P; priority_queue<P, vector<P>, greater<P>> q; void pfs(int s) { d[s] = 0; q.push({0, s}); lint cd, v; w...
#include "bits/stdc++.h" using namespace std; typedef long long lint; #define MAXN 100010 // d,edge,g,P,q lint d[MAXN]; struct edge { int to; lint cost; }; vector<edge> g[MAXN]; typedef pair<lint, int> P; priority_queue<P, vector<P>, greater<P>> q; void pfs(int s) { d[s] = 0; q.push({0, s}); lint cd, v; w...
[["-", 0, 57, 64, 1, 0, 16, 12, 5, 0, 6], ["+", 64, 1, 0, 16, 31, 16, 12, 5, 0, 6], ["+", 8, 9, 0, 57, 64, 1, 0, 16, 17, 151], ["+", 8, 9, 0, 57, 64, 1, 0, 16, 12, 22]]
1
323
#include <bits/stdc++.h> using namespace std; const int INF = 1'000'000'000; struct Edge { int to, cost; }; using P = pair<int, int>; int V, E; vector<vector<Edge>> graph; vector<int> dist; void Dijkstra(int s) { priority_queue<P, vector<P>, greater<P>> pq; pq.push({0, s}); dist[s] = 0; while (!pq.empty()...
#include <bits/stdc++.h> using namespace std; const int INF = 1'000'000'000; struct Edge { int to, cost; }; using P = pair<int, int>; int V, E; vector<vector<Edge>> graph; vector<int> dist; void Dijkstra(int s) { priority_queue<P, vector<P>, greater<P>> pq; pq.push({0, s}); dist[s] = 0; while (!pq.empty()...
[["-", 0, 14, 8, 9, 0, 7, 15, 16, 12, 22], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 12, 22]]
1
327
// // Created by user on 10/12/17. // #ifndef GRAPH_GRAPH_H #define GRAPH_GRAPH_H #include <memory> #include <vector> class Vertex; class Edge; using spVertex = std::shared_ptr<Vertex>; using wpVertex = std::weak_ptr<Vertex>; using spEdge = std::shared_ptr<Edge>; using wpEdge = std::weak_ptr<Edge>; class Vertex { ...
// // Created by user on 10/12/17. // #ifndef GRAPH_GRAPH_H #define GRAPH_GRAPH_H #include <memory> #include <vector> class Vertex; class Edge; using spVertex = std::shared_ptr<Vertex>; using wpVertex = std::weak_ptr<Vertex>; using spEdge = std::shared_ptr<Edge>; using wpEdge = std::weak_ptr<Edge>; class Vertex { ...
[["-", 0, 14, 8, 9, 0, 7, 15, 16, 12, 22], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 12, 22]]
1
1,528
#include <algorithm> #include <cstdio> #include <cstring> #include <ctype.h> #include <functional> #include <iomanip> #include <iostream> #include <math.h> #include <queue> #include <sstream> #include <stack> #include <stdio.h> #include <string> #include <utility> #include <vector> using namespace std; #define FOR(i,...
#include <algorithm> #include <cstdio> #include <cstring> #include <ctype.h> #include <functional> #include <iomanip> #include <iostream> #include <math.h> #include <queue> #include <sstream> #include <stack> #include <stdio.h> #include <string> #include <utility> #include <vector> using namespace std; #define FOR(i,...
[["+", 0, 57, 15, 339, 51, 91, 28, 23, 0, 24], ["+", 0, 57, 15, 339, 51, 91, 28, 23, 0, 25]]
1
283
#include <cstdio> #include <queue> using namespace std; #define REP(i, j) for (int i = 0; i < (j); i++) #define MAX_V 100000 #define INF 100000000 struct edge { int to, cost; }; // to,cost typedef pair<int, int> P; // first:Minimum distance/second:Vertex number int V; vector<edge> G[MAX_V];...
#include <cstdio> #include <queue> using namespace std; #define REP(i, j) for (int i = 0; i < (j); i++) #define MAX_V 100000 #define INF 2147483647 struct edge { int to, cost; }; // to,cost typedef pair<int, int> P; // first:Minimum distance/second:Vertex number int V; vector<edge> G[MAX_V]...
[["-", 36, 36, 36, 36, 0, 30, 0, 58, 51, 59], ["+", 36, 36, 36, 36, 0, 30, 0, 58, 51, 59], ["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 47], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 20]]
1
369
n_V, n_E = map(int, input().split()) G = [[] for i in range(n_V)] # 読み込み for i in range(n_E): v, e = map(int, input().split()) G[v].append(e) # for i in range(n_V): stack = [i] visited = set() flag = False while stack != []: current = stack.pop() for e in G[current]: ...
n_V, n_E = map(int, input().split()) G = [[] for i in range(n_V)] # 読み込み for i in range(n_E): v, e = map(int, input().split()) G[v].append(e) # flag = False for i in range(n_V): stack = [i] visited = set() while stack != []: current = stack.pop() for e in G[current]: ...
[["+", 36, 36, 0, 656, 0, 1, 0, 662, 31, 22], ["+", 36, 36, 0, 656, 0, 1, 0, 662, 0, 32], ["+", 36, 36, 0, 656, 0, 1, 0, 662, 12, 147], ["-", 0, 7, 8, 196, 0, 1, 0, 662, 31, 22], ["-", 0, 7, 8, 196, 0, 1, 0, 662, 0, 32], ["-", 0, 7, 8, 196, 0, 1, 0, 662, 12, 147]]
5
146
import java.util.ArrayList; import java.util.LinkedList; import java.util.Scanner; public class Main { @SuppressWarnings("unchecked") public static void main(String[] args) { Scanner s = new Scanner(System.in); String[] firstLine = s.nextLine().split(" "); int vertexCnt = Integer.parseInt(firstLine[0]...
import java.util.ArrayList; import java.util.LinkedList; import java.util.Scanner; public class Main { @SuppressWarnings("unchecked") public static void main(String[] args) { Scanner s = new Scanner(System.in); String[] firstLine = s.nextLine().split(" "); int vertexCnt = Integer.parseInt(firstLine[0]...
[["-", 0, 195, 8, 196, 0, 7, 15, 16, 12, 22], ["+", 0, 195, 8, 196, 0, 7, 15, 16, 12, 22]]
3
625
#include <algorithm> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <iostream> #include <map> #include <queue> #include <set> #include <sstream> #include <utility> #include <vector> using namespace std; typedef long long ll; typedef pair<int, int> P; vector<int> G[10005]; int V, E, F[...
#include <algorithm> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <iostream> #include <map> #include <queue> #include <set> #include <sstream> #include <utility> #include <vector> using namespace std; typedef long long ll; typedef pair<int, int> P; vector<int> G[10005]; int V, E, F[...
[["-", 0, 2, 3, 4, 0, 2, 3, 4, 0, 22], ["+", 0, 2, 3, 4, 0, 2, 3, 4, 0, 22]]
1
372
#include <algorithm> #include <iostream> #include <queue> #include <vector> using namespace std; vector<int> topological_sort(const vector<vector<int>> &G) { const int N = G.size(); vector<int> indeg(N, 0); for (auto &&vs : G) { for (int v : vs) { indeg[v]++; } } queue<int> Q; for (int i = 0;...
#include <algorithm> #include <iostream> #include <queue> #include <vector> using namespace std; vector<int> topological_sort(const vector<vector<int>> &G) { const int N = G.size(); vector<int> indeg(N, 0); for (auto &&vs : G) { for (int v : vs) { indeg[v]++; } } queue<int> Q; for (int i = 0;...
[["-", 0, 14, 8, 9, 0, 7, 15, 16, 12, 22], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 12, 22]]
1
283
#include <bits/stdc++.h> using namespace std; vector<int> x[12000]; int n, m, a, b, dist[12000], c[12000]; int main() { cin >> n >> m; for (int i = 0; i < m; i++) { cin >> a >> b; x[a].push_back(b); c[b]++; } queue<int> Q; for (int i = 0; i < n; i++) { if (c[i] == 0) Q.push(i); } whi...
#include <bits/stdc++.h> using namespace std; vector<int> x[12000]; int n, m, a, b, dist[12000], c[12000]; int main() { cin >> n >> m; for (int i = 0; i < m; i++) { cin >> a >> b; x[a].push_back(b); c[b]++; } queue<int> Q; for (int i = 0; i < n; i++) { if (c[i] == 0) Q.push(i); } whi...
[["-", 0, 57, 15, 339, 51, 16, 31, 69, 28, 22], ["+", 0, 57, 15, 339, 51, 16, 31, 69, 28, 22]]
1
274
#include <cassert> #include <iostream> #include <queue> #include <vector> using namespace std; using Weight = int; using Capacity = int; struct Edge { int src, dst; Weight weight; Edge(int s, int d, Weight w) : src(s), dst(d), weight(w) {} }; using Edges = vector<Edge>; using Graph = vector<Edges>; using Array =...
#include <cassert> #include <iostream> #include <queue> #include <vector> using namespace std; using Weight = int; using Capacity = int; struct Edge { int src, dst; Weight weight; Edge(int s, int d, Weight w) : src(s), dst(d), weight(w) {} }; using Edges = vector<Edge>; using Graph = vector<Edges>; using Array =...
[["-", 0, 14, 8, 9, 0, 7, 15, 16, 12, 22], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 12, 22]]
1
389
#define _CRT_SECURE_NO_WARNINGS #include <iostream> #include <list> #include <queue> #include <vector> using namespace std; static const int MAX = 10000; vector<int> G[MAX]; list<int> out; bool V[MAX]; int N; int indeg[MAX]; void bfs(int s) { queue<int> q; q.push(s); V[s] = true; while (!q.empty()) { in...
#define _CRT_SECURE_NO_WARNINGS #include <iostream> #include <list> #include <queue> #include <vector> using namespace std; static const int MAX = 10000; vector<int> G[MAX]; list<int> out; bool V[MAX]; int N; int indeg[MAX]; void bfs(int s) { queue<int> q; q.push(s); V[s] = true; while (!q.empty()) { in...
[["-", 0, 7, 8, 9, 0, 1, 0, 27, 17, 29], ["+", 0, 7, 8, 9, 0, 1, 0, 27, 17, 68]]
1
419
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_4_B // BFS algorithm #include <iostream> #include <queue> #include <vector> using namespace std; int main(int argc, char **argv) { int V, E; cin >> V >> E; vector<vector<int>> A(V); vector<int> B(V); for (int i = 0; i < E; i++) { int s, t; ...
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_4_B // BFS algorithm #include <iostream> #include <queue> #include <vector> using namespace std; int main(int argc, char **argv) { int V, E; cin >> V >> E; vector<vector<int>> A(V); vector<int> B(V); for (int i = 0; i < E; i++) { int s, t; ...
[["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 106], ["+", 0, 57, 15, 339, 51, 16, 12, 69, 28, 22], ["+", 15, 339, 51, 16, 12, 69, 341, 342, 0, 70], ["+", 15, 339, 51, 16, 12, 69, 341, 342, 0, 22], ["+", 15, 339, 51, 16, 12, 69, 341, 342, 0, 73]]
1
253
#include <bits/stdc++.h> using namespace std; static const int MAX = 100000; static const int INF = (1 << 29); int N, M; vector<int> G[MAX]; bool V[MAX]; int indeg[MAX]; list<int> out; void bfs(int num) { queue<int> que; que.push(num); while (!que.empty()) { int now = que.front(); que.pop(); out.pus...
#include <bits/stdc++.h> using namespace std; static const int MAX = 100000; static const int INF = (1 << 29); int N, M; vector<int> G[MAX]; bool V[MAX]; int indeg[MAX]; list<int> out; void bfs(int num) { queue<int> que; que.push(num); while (!que.empty()) { int now = que.front(); que.pop(); out.pus...
[["-", 0, 14, 8, 9, 0, 7, 15, 16, 12, 22], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 12, 22]]
1
391
#include <algorithm> #include <iostream> #include <queue> #include <vector> using namespace std; static const int MAX = 10000; vector<int> G[MAX]; int indegs[MAX]; bool visited[MAX]; void visit(int x) { cout << x << endl; visited[x] = true; } void bfs(int start) { queue<int> q; q.push(start); while (!q.emp...
#include <algorithm> #include <iostream> #include <queue> #include <vector> using namespace std; static const int MAX = 10000; vector<int> G[MAX]; int indegs[MAX]; bool visited[MAX]; void visit(int x) { cout << x << endl; visited[x] = true; } void bfs(int start) { queue<int> q; q.push(start); while (!q.emp...
[["-", 0, 14, 8, 9, 0, 7, 15, 16, 12, 22], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 12, 22]]
1
279
#include <algorithm> #include <iostream> #include <list> #include <queue> #include <vector> using namespace std; static const int MAX = 100000; static const int INFTY = (1 << 29); vector<int> G[MAX]; list<int> out; bool V[MAX]; int N, indeg[MAX]; void bfs(int s) { queue<int> q; q.push(s); V[s] = true; while (...
#include <algorithm> #include <iostream> #include <list> #include <queue> #include <vector> using namespace std; static const int MAX = 100000; static const int INFTY = (1 << 29); vector<int> G[MAX]; list<int> out; bool V[MAX]; int N, indeg[MAX]; void bfs(int s) { queue<int> q; q.push(s); V[s] = true; while (...
[["-", 12, 2, 63, 118, 28, 69, 341, 342, 0, 22], ["+", 12, 2, 63, 118, 28, 69, 341, 342, 0, 22]]
1
430
#include <iostream> #include <queue> #include <vector> using namespace std; int color[10000]; int indeg[10000]; int main() { int n, m; cin >> n >> m; vector<vector<int>> g(n); for (int i = 0; i < m; ++i) { int a, b; cin >> a >> b; g[a - 1].emplace_back(b - 1); indeg[b - 1]++; } vector<in...
#include <iostream> #include <queue> #include <vector> using namespace std; int color[10000]; int indeg[10000]; int main() { int n, m; cin >> n >> m; vector<vector<int>> g(n); for (int i = 0; i < m; ++i) { int a, b; cin >> a >> b; g[a].emplace_back(b); indeg[b]++; } vector<int> out; fo...
[["-", 63, 118, 28, 69, 341, 342, 0, 16, 17, 33], ["-", 63, 118, 28, 69, 341, 342, 0, 16, 12, 13], ["-", 0, 1, 0, 2, 3, 4, 0, 16, 17, 33], ["-", 0, 1, 0, 2, 3, 4, 0, 16, 12, 13], ["-", 0, 27, 28, 69, 341, 342, 0, 16, 17, 33], ["-", 0, 27, 28, 69, 341, 342, 0, 16, 12, 13]]
1
258
#include <algorithm> #include <iostream> #include <list> #include <queue> #include <vector> using namespace std; static const int MAX = 100000; vector<int> G[MAX]; list<int> out; bool V[MAX]; int N; int indeg[MAX]; void bfs(int s) { queue<int> q; q.push(s); V[s] = true; while (!q.empty()) { int u = q.fro...
#include <algorithm> #include <iostream> #include <list> #include <queue> #include <vector> using namespace std; static const int MAX = 100000; vector<int> G[MAX]; list<int> out; bool V[MAX]; int N; int indeg[MAX]; void bfs(int s) { queue<int> q; q.push(s); V[s] = true; while (!q.empty()) { int u = q.fro...
[["+", 8, 9, 0, 1, 0, 16, 31, 16, 12, 22], ["+", 0, 14, 8, 9, 0, 1, 0, 16, 17, 152]]
1
414
#include <bits/stdc++.h> using namespace std; static const int MAX = 100000; static const int INFTY = (1 << 29); vector<int> G[MAX]; list<int> out; bool V[MAX]; int N; int indeg[MAX]; void bfs(int s) { queue<int> q; q.push(s); V[s] = true; while (!q.empty()) { int u = q.front(); q.pop(); out.push_...
#include <bits/stdc++.h> using namespace std; static const int MAX = 100000; static const int INFTY = (1 << 29); vector<int> G[MAX]; //辺の情報 list<int> out; //出力の順序 bool V[MAX]; //そのノードに対して処理をしたか int N; //ノードの数 int indeg[MAX]; //ノードの入次数 void bfs(int s) { queue<int> q; q.push(s); V[s] =...
[["-", 0, 14, 8, 9, 0, 7, 15, 16, 12, 22], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 12, 22]]
1
422
#include <iostream> #include <map> #include <sstream> #include <string> #include <vector> using namespace std; class edge { public: int weight; int nodeIdx; edge(int w, int i) { weight = w; nodeIdx = i; } }; class node { public: vector<edge> next; int height; int diameter; bool visited; no...
#include <iostream> #include <map> #include <sstream> #include <string> #include <vector> using namespace std; class edge { public: int weight; int nodeIdx; edge(int w, int i) { weight = w; nodeIdx = i; } }; class node { public: vector<edge> next; int height; int diameter; bool visited; no...
[["-", 8, 9, 0, 7, 8, 9, 0, 43, 39, 40]]
1
386
#include "bits/stdc++.h" #include <unordered_map> #include <unordered_set> #pragma warning(disable : 4996) using namespace std; using ld = long double; template <class T> using Table = vector<vector<T>>; const ld eps = 1e-9; //// < "D:\D_Download\Visual Studio ///2015\Projects\programing_contest_c++\Debug\a.txt" > "D:...
#include "bits/stdc++.h" #include <unordered_map> #include <unordered_set> #pragma warning(disable : 4996) using namespace std; using ld = long double; template <class T> using Table = vector<vector<T>>; const ld eps = 1e-9; //// < "D:\D_Download\Visual Studio ///2015\Projects\programing_contest_c++\Debug\a.txt" > "D:...
[["-", 3, 4, 0, 191, 51, 83, 0, 16, 17, 33], ["-", 3, 4, 0, 191, 51, 83, 0, 16, 12, 13]]
1
299
#include "bits/stdc++.h" using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; #define INF 1 << 30 #define LINF 1LL << 60 struct edge { ll u; ll v; ll cost; edge() {} edge(ll u, ll v, ll cost) : u(u), v(v), cost(cost) {} }; void dijkstra(ll root, ll n, vector<vecto...
#include "bits/stdc++.h" using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; #define INF 1 << 30 #define LINF 1LL << 60 struct edge { ll u; ll v; ll cost; edge() {} edge(ll u, ll v, ll cost) : u(u), v(v), cost(cost) {} }; void dijkstra(ll root, ll n, vector<vecto...
[["-", 31, 16, 12, 2, 3, 4, 0, 69, 28, 22], ["+", 31, 16, 12, 2, 3, 4, 0, 69, 28, 22]]
1
484
import java.util.ArrayList; import java.util.Arrays; import java.util.Scanner; public class Main { public static long INF = Long.MAX_VALUE / 2; public static void main(String[] args) { Scanner stdIn = new Scanner(System.in); int V = stdIn.nextInt(); int E = stdIn.nextInt(); long[][] d = new long...
import java.util.ArrayList; import java.util.Arrays; import java.util.Scanner; public class Main { public static long INF = Long.MAX_VALUE / 2; public static void main(String[] args) { Scanner stdIn = new Scanner(System.in); int V = stdIn.nextInt(); int E = stdIn.nextInt(); long[][] d = new long...
[["+", 0, 57, 15, 15, 0, 16, 12, 16, 17, 85], ["+", 0, 57, 15, 15, 0, 16, 12, 16, 12, 499]]
3
432
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.lang.reflect.Array; import java.util.ArrayList; import java.util.Arrays; public class Main { public static void main(String[] argv) throws IOException { BufferedReader br = new BufferedReader(new InputStream...
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.lang.reflect.Array; import java.util.ArrayList; import java.util.Arrays; public class Main { public static void main(String[] argv) throws IOException { BufferedReader br = new BufferedReader(new InputStream...
[["-", 8, 196, 0, 57, 15, 15, 0, 16, 17, 60], ["+", 8, 196, 0, 57, 15, 15, 0, 16, 17, 47], ["-", 0, 57, 15, 15, 0, 16, 12, 16, 12, 499], ["+", 0, 57, 15, 15, 0, 16, 12, 16, 12, 499]]
3
519
import java.util.Arrays; import java.util.LinkedList; import java.util.Scanner; class Main { public static void main(String[] args) { new Main().run(); } long INF = Long.MAX_VALUE / 10; void run() { Scanner sc = new Scanner(System.in); int V = sc.nextInt(); int E = sc.nextInt(); long[][] D = ne...
import java.util.Arrays; import java.util.LinkedList; import java.util.Scanner; class Main { public static void main(String[] args) { new Main().run(); } long INF = Long.MAX_VALUE / 10; void run() { Scanner sc = new Scanner(System.in); int V = sc.nextInt(); int E = sc.nextInt(); long[][] D = ne...
[["-", 31, 492, 3, 4, 0, 504, 516, 504, 71, 22], ["+", 31, 492, 3, 4, 0, 504, 516, 504, 71, 22]]
3
439
#include <limits.h> #include <stdio.h> #include <stdlib.h> int **dist; void Floyd(int); int main(void) { int i, j, v, e, s, t, d; scanf("%d %d", &v, &e); dist = (int **)malloc(sizeof(int *) * v); for (i = 0; i < v; i++) { dist[i] = (int *)malloc(sizeof(int) * v); for (j = 0; j < v; j++) { dist[...
#include <limits.h> #include <stdio.h> #include <stdlib.h> int **dist; void Floyd(int); int main(void) { int i, j, v, e, s, t, d; scanf("%d %d", &v, &e); dist = (int **)malloc(sizeof(int *) * v); for (i = 0; i < v; i++) { dist[i] = (int *)malloc(sizeof(int) * v); for (j = 0; j < v; j++) { dist[...
[["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
0
493
#include <algorithm> #include <iostream> using namespace std; typedef long long ll; #define rep(i, n) for (ll i = 0; i < (n); i++) #define INF (1e12) ll V, E; ll G[100][100]; int main() { cin >> V >> E; rep(i, V) rep(j, V) G[i][j] = INF; rep(i, V) G[i][i] = 0; rep(i, E) { ll s, t, d; cin >> s >> t...
#include <algorithm> #include <iostream> using namespace std; typedef long long ll; #define rep(i, n) for (ll i = 0; i < (n); i++) #define INF (1e12) ll V, E; ll G[100][100]; int main() { cin >> V >> E; rep(i, V) rep(j, V) G[i][j] = INF; rep(i, V) G[i][i] = 0; rep(i, E) { ll s, t, d; cin >> s >> t...
[["+", 0, 57, 15, 339, 51, 16, 12, 16, 17, 85], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 12, 13]]
1
283
#define _USE_MATH_DEFINES #include <algorithm> #include <cmath> #include <cstdio> #include <cstdlib> #include <iostream> #include <map> #include <queue> #include <stack> #include <string.h> #include <vector> using namespace std; typedef pair<long long int, long long int> P; long long int INF = 1e18; long long int MO...
#define _USE_MATH_DEFINES #include <algorithm> #include <cmath> #include <cstdio> #include <cstdlib> #include <iostream> #include <map> #include <queue> #include <stack> #include <string.h> #include <vector> using namespace std; typedef pair<long long int, long long int> P; long long int INF = 1e18; long long int MO...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 60], ["-", 8, 9, 0, 57, 15, 339, 51, 16, 12, 22], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 47], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13]]
1
452
#include <algorithm> #include <stdio.h> using namespace std; long long G[100 + 10][100 + 10]; int n; long long nil = -2147483648; void floy() { for (int k = 0; k < n; k++) { for (int i = 0; i < n; i++) { if (G[i][k] == nil) continue; //找指向?点K的?; for (int j = 0; j < n; j++) { if (G[k][j...
#include <algorithm> #include <stdio.h> using namespace std; long long G[100 + 10][100 + 10]; int n; long long nil = 9999999999; void floy() { for (int k = 0; k < n; k++) { for (int i = 0; i < n; i++) { if (G[i][k] == nil) continue; //找指向?点K的?; for (int j = 0; j < n; j++) { if (G[k][j]...
[["-", 36, 36, 0, 30, 0, 43, 49, 50, 51, 13], ["+", 36, 36, 0, 30, 0, 43, 49, 50, 51, 13]]
1
426
#include <algorithm> #include <iostream> #include <vector> using namespace std; static const int MAX = 100; static const long long INFTY = (1LL << 32); int n; long long d[MAX][MAX]; void floyd() { for (int k = 0; k < n; k++) { for (int i = 0; i < n; i++) { if (d[i][k] == INFTY) continue; fo...
#include <algorithm> #include <iostream> #include <vector> using namespace std; static const int MAX = 100; static const long long INFTY = (1LL << 32); int n; long long d[MAX][MAX]; void floyd() { for (int k = 0; k < n; k++) { for (int i = 0; i < n; i++) { if (d[i][k] == INFTY) continue; fo...
[["+", 0, 7, 8, 9, 0, 1, 0, 16, 31, 22], ["+", 0, 7, 8, 9, 0, 1, 0, 16, 17, 151], ["+", 0, 7, 8, 9, 0, 1, 0, 16, 12, 22], ["+", 0, 9, 0, 7, 8, 9, 0, 1, 0, 35]]
1
396
#include <bits/stdc++.h> using namespace std; #define inf 1e12 + 1 typedef long long int ll; typedef pair<ll, ll> mypair; #define rep(i, n) for (int i = 0; i < n; i++) int main() { ll v, e; cin >> v >> e; vector<vector<mypair>> g(v); vector<vector<ll>> dp(v, vector<ll>(v, inf)); ll s, t, d; rep(i, e) { ...
#include <bits/stdc++.h> using namespace std; #define inf 1e12 + 1 typedef long long int ll; typedef pair<ll, ll> mypair; #define rep(i, n) for (int i = 0; i < n; i++) int main() { ll v, e; cin >> v >> e; vector<vector<mypair>> g(v); vector<vector<ll>> dp(v, vector<ll>(v, inf)); ll s, t, d; rep(i, e) { ...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 106], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 67]]
1
339
// All Pairs Shortest Path #include <climits> #include <iostream> using namespace std; static const int MAX = 100; int V, E; long long A[MAX][MAX]; void warshallFloyd() { for (int k = 1; k < V; k++) { for (int i = 0; i < V; i++) { if (A[i][k] == LONG_LONG_MAX) continue; for (int j = 0; j < ...
// All Pairs Shortest Path #include <climits> #include <iostream> using namespace std; static const int MAX = 100; int V, E; long long A[MAX][MAX]; void warshallFloyd() { for (int k = 0; k < V; k++) { for (int i = 0; i < V; i++) { if (A[i][k] == LONG_LONG_MAX) continue; for (int j = 0; j < ...
[["-", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["+", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13]]
1
384
#include <bits/stdc++.h> using namespace std; typedef unsigned long long ull; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; typedef pair<double, double> pdd; const ull mod = 1e9 + 7; #define REP(i, n) for (int i = 0; i < (int)n; ++i) // debug #define dump(x) cerr << #x << " = " << (x) <<...
#include <bits/stdc++.h> using namespace std; typedef unsigned long long ull; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; typedef pair<double, double> pdd; const ull mod = 1e9 + 7; #define REP(i, n) for (int i = 0; i < (int)n; ++i) // debug #define dump(x) cerr << #x << " = " << (x) <<...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 60], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 47], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 17, 85], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 12, 13]]
1
672
#include <cstdio> #include <vector> #define INF 2000000000 #define M 100 #define _for(j, N) for (int i = (j); i < (N); ++i) using namespace std; long adj[100][100]; int V; int E; int main(void) { scanf("%d %d", &V, &E); long s, t, w; for (int i = 0; i < V; ++i) { for (int j = 0; j < V; ++j) { adj[i]...
#include <cstdio> #include <vector> #define INF 2000000000 #define M 100 #define _for(j, N) for (int i = (j); i < (N); ++i) using namespace std; long adj[100][100]; int V; int E; int main(void) { scanf("%d %d", &V, &E); long s, t, w; for (int i = 0; i < V; ++i) { for (int j = 0; j < V; ++j) { adj[i]...
[["-", 0, 1, 0, 2, 3, 4, 0, 16, 17, 33], ["-", 0, 1, 0, 2, 3, 4, 0, 16, 12, 13]]
1
396
// includes #include <bits/stdc++.h> // macros #define ll long long int #define pb emplace_back #define mk make_pair #define pq priority_queue #define FOR(i, a, b) for (int i = (a); i < (b); ++i) #define rep(i, n) FOR(i, 0, n) #define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--) #define all(x) (x).begin(), (x).e...
// includes #include <bits/stdc++.h> // macros #define ll long long int #define pb emplace_back #define mk make_pair #define pq priority_queue #define FOR(i, a, b) for (int i = (a); i < (b); ++i) #define rep(i, n) FOR(i, 0, n) #define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--) #define all(x) (x).begin(), (x).e...
[["-", 0, 57, 15, 339, 51, 16, 12, 16, 12, 13], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 12, 13]]
1
722
#include <algorithm> #include <iostream> #include <map> #include <queue> #include <set> #include <vector> using namespace std; #define REP(i, n) for (int i = 0; i < (n); ++i) #define rep(i, a, b) for (int i = a; i < (b); ++i) template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; ...
#include <algorithm> #include <iostream> #include <map> #include <queue> #include <set> #include <vector> using namespace std; #define REP(i, n) for (int i = 0; i < (n); ++i) #define rep(i, a, b) for (int i = a; i < (b); ++i) template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; ...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 60], ["-", 8, 9, 0, 57, 15, 339, 51, 16, 12, 22], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 47], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13]]
1
399
#include <bits/stdc++.h> using namespace std; const int MAX = 105; const long long int INF = (1LL << 32); long long int D[MAX][MAX]; int N; void floyd() { for (int k = 0; k < N; k++) { for (int i = 0; i < N; i++) { if (D[i][k] == INF) continue; for (int j = 0; j < N; j++) { if (D[k]...
#include <bits/stdc++.h> using namespace std; const int MAX = 105; const long long int INF = (1LL << 32); long long int D[MAX][MAX]; int N; void floyd() { for (int k = 0; k < N; k++) { for (int i = 0; i < N; i++) { if (D[i][k] == INF) continue; for (int j = 0; j < N; j++) { if (D[k]...
[["+", 8, 9, 0, 57, 64, 9, 0, 93, 0, 94], ["+", 8, 9, 0, 57, 64, 9, 0, 93, 0, 35]]
1
402
#include <bits/stdc++.h> using namespace std; using LL = long long; const LL INF = 1'000'000'000'000'000'00; int V, E; vector<vector<LL>> dist; void WarashallFloyd() { for (int i = 0; i < V; i++) for (int j = 0; j < V; j++) for (int k = 0; k < V; k++) { if (dist[j][k] == INF || dist[i][k] == INF)...
#include <bits/stdc++.h> using namespace std; using LL = long long; const LL INF = 1'000'000'000'000'000'00; int V, E; vector<vector<LL>> dist; void WarashallFloyd() { for (int i = 0; i < V; i++) for (int j = 0; j < V; j++) for (int k = 0; k < V; k++) { if (dist[j][i] == INF || dist[i][k] == INF)...
[["-", 51, 16, 31, 16, 31, 69, 341, 342, 0, 22], ["+", 51, 16, 31, 16, 31, 69, 341, 342, 0, 22]]
1
377
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; typedef tuple<int, int> duo; //{{{ templates #define TMPINL_(...) template <__VA_ARGS__> inline #define TT_ TMPINL_(typename T) #define TTF_ TMPINL_(typename T, typename F) #define TTTS_ TMPINL_(typename T, typename... Ts) #de...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; typedef tuple<int, int> duo; //{{{ templates #define TMPINL_(...) template <__VA_ARGS__> inline #define TT_ TMPINL_(typename T) #define TTF_ TMPINL_(typename T, typename F) #define TTTS_ TMPINL_(typename T, typename... Ts) #de...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 60], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 20], ["-", 15, 339, 51, 16, 12, 23, 0, 16, 12, 13], ["+", 15, 339, 51, 16, 12, 23, 0, 16, 12, 13]]
1
1,076
#include <bits/stdc++.h> using namespace std; typedef long long int ll; typedef pair<int, int> pii; typedef vector<int> vi; typedef vector<pair<int, int>> vii; #define rrep(i, m, n) for (int(i) = (m); (i) < (n); (i)++) #define rep(i, n) for (int(i) = 0; (i) < (n); (i)++) #define rev(i, n) for (int(i) = (n)-1; (i) >= 0...
#include <bits/stdc++.h> using namespace std; typedef long long int ll; typedef pair<int, int> pii; typedef vector<int> vi; typedef vector<pair<int, int>> vii; #define rrep(i, m, n) for (int(i) = (m); (i) < (n); (i)++) #define rep(i, n) for (int(i) = 0; (i) < (n); (i)++) #define rev(i, n) for (int(i) = (n)-1; (i) >= 0...
[["+", 51, 4, 0, 2, 3, 4, 0, 16, 17, 72], ["+", 51, 4, 0, 2, 3, 4, 0, 16, 12, 22]]
1
586
#include <algorithm> #include <bitset> #include <cctype> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <deque> #include <fstream> #include <functional> #include <iomanip> #include <iostream> #include <list> #include <map> #include <numeric> #include <queue> #include ...
#include <algorithm> #include <bitset> #include <cctype> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <deque> #include <fstream> #include <functional> #include <iomanip> #include <iostream> #include <list> #include <map> #include <numeric> #include <queue> #include ...
[["-", 36, 36, 0, 30, 0, 43, 49, 50, 51, 13], ["+", 36, 36, 0, 30, 0, 43, 49, 50, 51, 13], ["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 60], ["-", 8, 9, 0, 57, 15, 339, 51, 16, 12, 22], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 47], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13]]
1
413
#include <algorithm> #include <iostream> using namespace std; #define INF 1 << 31 int main() { int v, e; cin >> v >> e; long long int edge[v][v]; for (int i = 0; i < v; i++) { for (int j = 0; j < v; j++) edge[i][j] = INF; } int s, t, d; for (int i = 0; i < e; i++) { cin >> s >> t >> d; e...
#include <algorithm> #include <iostream> using namespace std; #define INF ((1 << 31) - 1) int main() { int v, e; cin >> v >> e; long long int edge[v][v]; for (int i = 0; i < v; i++) { for (int j = 0; j < v; j++) edge[i][j] = INF; } int s, t, d; for (int i = 0; i < e; i++) { cin >> s >> t >> ...
[["-", 36, 36, 36, 36, 0, 30, 0, 58, 51, 59], ["+", 36, 36, 36, 36, 0, 30, 0, 58, 51, 59]]
1
357
#include <algorithm> #include <climits> #include <cstdio> #include <iostream> #define FOR(i, a, b) for (int(i) = (a); (i) < int(b); (i)++) using namespace std; const int MAX_V = 100; // ????????°????????§??? const int INF = INT_MAX; int v; // ????????° int g[MAX_V][MAX_V]; // ??£??\?????? int d[MAX_V][M...
#include <algorithm> #include <climits> #include <cstdio> #include <iostream> #define FOR(i, a, b) for (int(i) = (a); (i) < int(b); (i)++) using namespace std; const int MAX_V = 100; // ????????°????????§??? const int INF = INT_MAX; int v; // ????????° int g[MAX_V][MAX_V]; // ??£??\?????? int d[MAX_V][M...
[["-", 0, 57, 75, 76, 0, 1, 0, 16, 17, 151], ["-", 0, 57, 75, 76, 0, 1, 0, 16, 12, 22]]
1
384
#include <bits/stdc++.h> using namespace std; typedef long long ll; ll dp[101][101]; ll n, m; ll g[101][101]; int main() { for (ll i = 0; i < 101; i++) for (ll j = 0; j < 101; j++) if (i != j) dp[i][j] = 1e8; cin >> n >> m; for (ll i = 0; i < m; i++) { ll x, y, w; cin >> x >> y >> w;...
#include <bits/stdc++.h> using namespace std; typedef long long ll; ll dp[101][101]; ll n, m; ll g[101][101]; int main() { for (ll i = 0; i < 101; i++) for (ll j = 0; j < 101; j++) if (i != j) dp[i][j] = 1e15; cin >> n >> m; for (ll i = 0; i < m; i++) { ll x, y, w; cin >> x >> y >> w...
[["-", 8, 7, 8, 57, 64, 1, 0, 11, 12, 13], ["+", 8, 7, 8, 57, 64, 1, 0, 11, 12, 13], ["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 60], ["-", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 20], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13]]
1
389
#include <algorithm> #include <climits> #include <cmath> #include <cstdio> #include <cstring> #include <functional> #include <iomanip> #include <iostream> #include <list> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #include <string> #include <utility> #include <vector> #define FO...
#include <algorithm> #include <climits> #include <cmath> #include <cstdio> #include <cstring> #include <functional> #include <iomanip> #include <iostream> #include <list> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #include <string> #include <utility> #include <vector> #define FO...
[["+", 0, 57, 15, 339, 51, 16, 12, 16, 17, 152], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 12, 13]]
1
375
#include <climits> #include <cstdio> #include <iostream> #include <vector> int main() { int v, e; std::scanf("%d %d", &v, &e); // v = 4; e = 6; r = 0; std::vector<std::vector<int>> distance(v, std::vector<int>(v, INT_MAX)); std::vector<std::vector<int>> to(v); std::vector<std::vector<int>> from(v); for (...
#include <climits> #include <cstdio> #include <iostream> #include <vector> int main() { int v, e; std::scanf("%d %d", &v, &e); // v = 4; e = 6; r = 0; std::vector<std::vector<int>> distance(v, std::vector<int>(v, INT_MAX)); std::vector<std::vector<int>> to(v); std::vector<std::vector<int>> from(v); for (...
[["-", 0, 57, 15, 339, 51, 16, 31, 16, 17, 47], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 17, 60]]
1
569
#include <climits> #include <iostream> using namespace std; const int MAX = LLONG_MAX >> 1; int main() { int v = 0, e = 0; long long dist[100][100] = {0}; cin >> v >> e; for (int i = 0; i < v; i++) { for (int j = 0; j < v; j++) { dist[i][j] = MAX; } } for (int i = 0; i < v; i++) { dist[...
#include <climits> #include <iostream> using namespace std; const long long MAX = LLONG_MAX >> 1; int main() { int v = 0, e = 0; long long dist[100][100] = {0}; cin >> v >> e; for (int i = 0; i < v; i++) { for (int j = 0; j < v; j++) { dist[i][j] = MAX; } } for (int i = 0; i < v; i++) { ...
[["-", 36, 36, 36, 36, 0, 30, 0, 43, 39, 40], ["+", 36, 36, 0, 30, 0, 43, 39, 86, 0, 96]]
1
413
#include <algorithm> #include <cstring> #include <iostream> #include <map> #include <set> #include <sstream> #include <string> #include <vector> #define REP(i, k, n) for (int i = k; i < n; i++) #define rep(i, n) for (int i = 0; i < n; i++) #define INF 1LL << 50 #define pb push_back #define mp make_pair using namespac...
#include <algorithm> #include <cstring> #include <iostream> #include <map> #include <set> #include <sstream> #include <string> #include <vector> #define REP(i, k, n) for (int i = k; i < n; i++) #define rep(i, n) for (int i = 0; i < n; i++) #define INF 1LL << 50 #define pb push_back #define mp make_pair using namespac...
[["-", 51, 16, 31, 16, 31, 69, 341, 342, 0, 22], ["+", 51, 16, 31, 16, 31, 69, 341, 342, 0, 22], ["-", 12, 16, 31, 69, 28, 69, 341, 342, 0, 22], ["+", 12, 16, 31, 69, 28, 69, 341, 342, 0, 22]]
1
368
#include <iostream> using namespace std; int K[102][102], V, E; int main() { int k, i, j, s, t, d; cin >> V >> E; for (i = 0; i < V; i++) for (j = 0; j < E; j++) { if (i == j) K[i][j] = 0; else K[i][j] = 0x7FFFFFFF; } for (i = 0; i < E; i++) { cin >> s >> t >> d; ...
#include <iostream> using namespace std; int K[102][102], V, E; int main() { int k, i, j, s, t, d; cin >> V >> E; for (i = 0; i < V; i++) for (j = 0; j < V; j++) { if (i == j) K[i][j] = 0; else K[i][j] = 0x7FFFFFFF; } for (i = 0; i < E; i++) { cin >> s >> t >> d; ...
[["-", 8, 9, 0, 7, 8, 7, 15, 16, 12, 22], ["+", 8, 9, 0, 7, 8, 7, 15, 16, 12, 22]]
1
376
#include <algorithm> #include <iostream> using namespace std; static const int SIZE = 101; static const unsigned long long int INF = 1e18; unsigned long long int d[SIZE][SIZE] = {0}; void solve() { for (int i = 0; i < SIZE; ++i) { for (int j = 0; j < SIZE; ++j) { d[i][j] = INF; } d[i][i] = 0; } ...
#include <algorithm> #include <iostream> using namespace std; static const int SIZE = 101; static const long long int INF = 1e18; long long int d[SIZE][SIZE] = {0}; void solve() { for (int i = 0; i < SIZE; ++i) { for (int j = 0; j < SIZE; ++j) { d[i][j] = INF; } d[i][i] = 0; } int V, E; cin ...
[["-", 36, 36, 0, 30, 0, 43, 39, 86, 0, 87]]
1
399
#include <bits/stdc++.h> using namespace std; #define fi first #define se second #define pb push_back typedef long long LL; typedef long double LD; const LL INF = (1LL << 60); const int MAXN = 105; bool floyd_warshall(int n, LL adjMat[MAXN][MAXN], int parent[MAXN][MAXN]); int main() { ios_base::sync_with_stdio(...
#include <bits/stdc++.h> using namespace std; #define fi first #define se second #define pb push_back typedef long long LL; typedef long double LD; const LL INF = (1LL << 60); const int MAXN = 105; bool floyd_warshall(int n, LL adjMat[MAXN][MAXN], int parent[MAXN][MAXN]); int main() { ios_base::sync_with_stdio(...
[["-", 0, 14, 8, 9, 0, 7, 15, 16, 12, 22], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 12, 22], ["-", 0, 7, 8, 9, 0, 7, 15, 16, 12, 22], ["+", 0, 7, 8, 9, 0, 7, 15, 16, 12, 22]]
1
580
#include <algorithm> #include <iostream> #include <queue> #include <string> #include <utility> #include <vector> #define INF 1000000000000000 using namespace std; typedef long long int lli; typedef pair<int, int> P; struct edge { int from, to, cost; }; int V, E, r; edge e[9900]; lli d[100][100]; bool solve() { ...
#include <algorithm> #include <iostream> #include <queue> #include <string> #include <utility> #include <vector> #define INF 1000000000000000 using namespace std; typedef long long int lli; typedef pair<int, int> P; struct edge { int from, to, cost; }; int V, E, r; edge e[9900]; lli d[100][100]; bool solve() { ...
[["-", 0, 57, 15, 339, 51, 16, 31, 16, 17, 98], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 106], ["+", 0, 57, 15, 339, 51, 16, 12, 23, 0, 24], ["+", 0, 57, 15, 339, 51, 16, 12, 23, 0, 25]]
1
421
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef vector<vector<ll>> AdjMat; #define INF (ll)1e+18 int main() { int V, E; cin >> V >> E; AdjMat G(V, vector<ll>(V, INF)); for (int i = 0; i < E; i++) { ll s, t, d; cin >> s >> t >> d; G[s][t] = d; } for (int i = 0; i ...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef vector<vector<ll>> AdjMat; #define INF (ll)1e+18 int main() { int V, E; cin >> V >> E; AdjMat G(V, vector<ll>(V, INF)); for (int i = 0; i < E; i++) { ll s, t, d; cin >> s >> t >> d; G[s][t] = d; } for (int i = 0; i <...
[["+", 0, 57, 15, 339, 51, 16, 12, 16, 17, 85], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 12, 13]]
1
318
#include <algorithm> #include <climits> #include <iostream> #include <vector> using namespace std; static const int MAX = 100; static const long long INFTY = 1LL << 32; int n; long long d[MAX][MAX]; void floyd() { for (int k = 0; k < n; k++) { for (int i = 0; i < n; i++) { if (d[i][k] == INFTY) c...
#include <algorithm> #include <climits> #include <iostream> #include <vector> using namespace std; static const int MAX = 100; static const long long INFTY = 1LL << 32; int n; long long d[MAX][MAX]; void floyd() { for (int k = 0; k < n; k++) { for (int i = 0; i < n; i++) { if (d[i][k] == INFTY) c...
[["-", 0, 1, 0, 16, 31, 16, 31, 16, 12, 22], ["-", 8, 9, 0, 1, 0, 16, 31, 16, 17, 152], ["+", 8, 9, 0, 1, 0, 16, 31, 16, 17, 152], ["+", 8, 9, 0, 1, 0, 16, 31, 16, 12, 22]]
1
415
#include <algorithm> #include <cmath> #include <iomanip> #include <iostream> #include <queue> #include <vector> #define shosu(x) fixed << setprecision(x) using namespace std; typedef long long ll; typedef pair<int, int> P; typedef vector<int> vi; typedef vector<vi> vvi; typedef vector<P> vp; typedef vector<vp> vvp; typ...
#include <algorithm> #include <cmath> #include <iomanip> #include <iostream> #include <queue> #include <vector> #define shosu(x) fixed << setprecision(x) using namespace std; typedef long long ll; typedef pair<int, int> P; typedef vector<int> vi; typedef vector<vi> vvi; typedef vector<P> vp; typedef vector<vp> vvp; typ...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 19], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 20]]
1
600
#include <algorithm> #include <cmath> #include <cstring> #include <functional> #include <iostream> #include <list> #include <map> #include <queue> #include <stack> #include <vector> using namespace std; #define LOOP1(n) for (int i = 0; i < n; i++) #define LOOP2(n) for (int j = 0; j < n; j++) #define LOOP3(n) for (int k...
#include <algorithm> #include <cmath> #include <cstring> #include <functional> #include <iostream> #include <list> #include <map> #include <queue> #include <stack> #include <vector> using namespace std; #define LOOP1(n) for (int i = 0; i < n; i++) #define LOOP2(n) for (int j = 0; j < n; j++) #define LOOP3(n) for (int k...
[["-", 36, 36, 36, 36, 0, 30, 0, 43, 39, 40], ["+", 36, 36, 0, 30, 0, 43, 39, 86, 0, 96], ["+", 0, 14, 8, 9, 0, 43, 39, 86, 39, 40]]
1
355
#include <iostream> #define INF 100000000000000 #define MAXN 1000 + 10 using namespace std; long long dist[MAXN][MAXN]; int main() { int i, j, k, n, m, a, b; cin >> n >> m; for (i = 0; i < n; ++i) { for (j = 0; j < n; ++j) { if (i != j) { dist[i][j] = INF; } } } for (i = 0; i < m...
#include <iostream> #define INF 100000000000000 #define MAXN 1000 + 10 using namespace std; long long dist[MAXN][MAXN]; int main() { int i, j, k, n, m, a, b; cin >> n >> m; for (i = 0; i < n; ++i) { for (j = 0; j < n; ++j) { if (i != j) { dist[i][j] = INF; } } } for (i = 0; i < m...
[["-", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6], ["+", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6]]
1
346
#include <algorithm> #include <iostream> #include <vector> #define ll long long #define INF (100000000000) using namespace std; int main() { ios_base::sync_with_stdio(false); ll V, E; cin >> V >> E; vector<vector<ll>> dist(V, vector<ll>(V, INF)); for (ll i = 0; i < V; i++) dist[i][i] = 0; for (ll i = 0...
#include <algorithm> #include <iostream> #include <vector> #define ll long long #define INF (1000000000000) using namespace std; int main() { ios_base::sync_with_stdio(false); ll V, E; cin >> V >> E; vector<vector<ll>> dist(V, vector<ll>(V, INF)); for (ll i = 0; i < V; i++) dist[i][i] = 0; for (ll i = ...
[["-", 36, 36, 36, 36, 0, 30, 0, 58, 51, 59], ["+", 36, 36, 36, 36, 0, 30, 0, 58, 51, 59], ["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 60], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 20], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 17, 85], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 12, 13]]
1
337
#include <bits/stdc++.h> #define rep(i, a, n) for (int i = a; i < n; i++) #define repb(i, a, b) for (int i = a; i >= b; i--) #define all(a) a.begin(), a.end() #define o(a) cout << a << endl #define int long long using namespace std; typedef pair<int, int> P; const int INF = 1e9; int n, m; int d[110][110]; void init(...
#include <bits/stdc++.h> #define rep(i, a, n) for (int i = a; i < n; i++) #define repb(i, a, b) for (int i = a; i >= b; i--) #define all(a) a.begin(), a.end() #define o(a) cout << a << endl #define int long long using namespace std; typedef pair<int, int> P; const int INF = 1e13; int n, m; int d[110][110]; void init...
[["-", 36, 36, 0, 30, 0, 43, 49, 50, 51, 13], ["+", 36, 36, 0, 30, 0, 43, 49, 50, 51, 13], ["-", 0, 9, 0, 57, 15, 339, 51, 16, 17, 60], ["-", 0, 9, 0, 57, 15, 339, 51, 16, 12, 22], ["+", 0, 9, 0, 57, 15, 339, 51, 16, 17, 20], ["+", 0, 9, 0, 57, 15, 339, 51, 16, 12, 13]]
1
360
#include <bits/stdc++.h> #define rep(i, a, n) for (int i = a; i < n; i++) #define repb(i, a, b) for (int i = a; i >= b; i--) #define all(a) a.begin(), a.end() #define o(a) cout << a << endl #define int long long using namespace std; typedef pair<int, int> P; const int INF = 6e9; int V, E; int d[110][110]; void warsha...
#include <bits/stdc++.h> #define rep(i, a, n) for (int i = a; i < n; i++) #define repb(i, a, b) for (int i = a; i >= b; i--) #define all(a) a.begin(), a.end() #define o(a) cout << a << endl #define int long long using namespace std; typedef pair<int, int> P; const int INF = 6e9; int V, E; int d[110][110]; void warsha...
[["-", 0, 9, 0, 57, 15, 339, 51, 16, 17, 60], ["+", 0, 9, 0, 57, 15, 339, 51, 16, 17, 20]]
1
347
#include <bits/stdc++.h> #define int long long using namespace std; struct WarshallFloyd { int n; const int INF = 1e15; vector<vector<int>> d; WarshallFloyd(int _n) { n = _n; d.resize(n, vector<int>(n)); for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { d[i][j] = INF; ...
#include <bits/stdc++.h> #define int long long using namespace std; struct WarshallFloyd { int n; const int INF = 1e15; vector<vector<int>> d; WarshallFloyd(int _n) { n = _n; d.resize(n, vector<int>(n)); for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { d[i][j] = INF; ...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 60], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 47], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 17, 85], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 12, 13]]
1
412
#include <bits/stdc++.h> using namespace std; const long long inf = 1LL << 60; int N, M, a, b, c; long long dist[109][109]; int main() { scanf("%d%d", &N, &M); for (int i = 0; i < N; i++) { fill(dist[i], dist[i] + N, inf); dist[i][i] = 0; } for (int i = 0; i < M; i++) { scanf("%d%d%d", &a, &b, &c); ...
#include <bits/stdc++.h> using namespace std; const long long inf = 1LL << 60; int N, M, a, b, c; long long dist[109][109]; int main() { scanf("%d%d", &N, &M); for (int i = 0; i < N; i++) { fill(dist[i], dist[i] + N, inf); dist[i][i] = 0; } for (int i = 0; i < M; i++) { scanf("%d%d%d", &a, &b, &c); ...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 60], ["-", 8, 9, 0, 57, 15, 339, 51, 16, 12, 22], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 20], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 31, 13], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 17, 151], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 12, 13]]
1
346
#include <iostream> #include <queue> #include <stack> #include <vector> using namespace std; static const long long FAR = (1LL << 31); static const int N = 100; int n, m; bool visited[N]; int d[N][N]; void floyd() { for (int k = 0; k < n; ++k) { for (int l = 0; l < n; ++l) { if (d[l][k] == FAR) ...
#include <iostream> #include <queue> #include <stack> #include <vector> using namespace std; static const long long FAR = (1LL << 31); static const int N = 100; int n, m; bool visited[N]; long long d[N][N]; void floyd() { for (int k = 0; k < n; ++k) { for (int l = 0; l < n; ++l) { if (d[l][k] == FAR) ...
[["-", 36, 36, 36, 36, 0, 30, 0, 43, 39, 40], ["+", 36, 36, 0, 30, 0, 43, 39, 86, 0, 96]]
1
405
#include "bits/stdc++.h" #include <sys/timeb.h> using namespace std; #define repl(i, a, b) for (int i = (int)(a); i < (int)(b); i++) #define rep(i, n) repl(i, 0, n) #define replrev(i, a, b) for (int i = (int)(b)-1; i >= (int)(a); i--) #define reprev(i, n) replrev(i, 0, n) #define repi(itr, ds) for (auto itr = ds.begin...
#include "bits/stdc++.h" #include <sys/timeb.h> using namespace std; #define repl(i, a, b) for (int i = (int)(a); i < (int)(b); i++) #define rep(i, n) repl(i, 0, n) #define replrev(i, a, b) for (int i = (int)(b)-1; i >= (int)(a); i--) #define reprev(i, n) replrev(i, 0, n) #define repi(itr, ds) for (auto itr = ds.begin...
[["-", 0, 57, 15, 339, 51, 16, 31, 16, 12, 22], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 12, 22], ["-", 0, 57, 15, 339, 51, 16, 12, 16, 12, 22], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 12, 22]]
1
498
#include <bits/stdc++.h> #define r(i, n) for (int i = 0; i < n; i++) #define INF 1 << 32 using namespace std; int main() { int v, n; cin >> v >> n; long long a[v][v]; r(i, v) r(j, v) a[i][j] = i == j ? 0 : INF; r(i, n) { int x, y, w; cin >> x >> y >> w; a[x][y] = w; } r(k, v) r(i, v) r(j, v) i...
#include <bits/stdc++.h> #define r(i, n) for (int i = 0; i < n; i++) #define INF 2000000000 using namespace std; int main() { int v, n; cin >> v >> n; long long a[v][v]; r(i, v) r(j, v) a[i][j] = i == j ? 0 : INF; r(i, n) { int x, y, w; cin >> x >> y >> w; a[x][y] = w; } r(k, v) r(i, v) r(j, v...
[["-", 36, 36, 36, 36, 0, 30, 0, 58, 51, 59], ["+", 36, 36, 36, 36, 0, 30, 0, 58, 51, 59]]
1
275
#include <algorithm> #include <climits> #include <iostream> #include <vector> using namespace std; static const int MAX = 100; static const long long INFTY = (1LL << 32); int n; long long d[MAX][MAX]; void floyd() { for (int k = 0; k < n; k++) { for (int i = 0; i < n; i++) { if (d[i][k] == INFTY) ...
#include <algorithm> #include <climits> #include <iostream> #include <vector> using namespace std; static const int MAX = 100; static const long long INFTY = (1LL << 32); int n; long long d[MAX][MAX]; void floyd() { for (int k = 0; k < n; k++) { for (int i = 0; i < n; i++) { if (d[i][k] == INFTY) ...
[["-", 51, 16, 31, 69, 28, 69, 341, 342, 0, 22], ["+", 51, 16, 31, 69, 28, 69, 341, 342, 0, 22]]
1
406
#include <bits/stdc++.h> using namespace std; const int INF = 1 << 31; int V, E; int main() { cin >> V >> E; vector<vector<int>> D(V, vector<int>(V, INF)); for (int i = 0; i < V; i++) D[i][i] = 0; for (int i = 0; i < E; i++) { int s, t, d; cin >> s >> t >> d; D[s][t] = d; } for (int k =...
#include <bits/stdc++.h> using namespace std; const int INF = (1LL << 31) - 1; int V, E; int main() { cin >> V >> E; vector<vector<int>> D(V, vector<int>(V, INF)); for (int i = 0; i < V; i++) D[i][i] = 0; for (int i = 0; i < E; i++) { int s, t, d; cin >> s >> t >> d; D[s][t] = d; } for ...
[["-", 0, 30, 0, 43, 49, 50, 51, 16, 31, 13], ["+", 0, 43, 49, 50, 51, 16, 31, 23, 0, 24], ["+", 49, 50, 51, 16, 31, 23, 0, 16, 31, 13], ["+", 0, 43, 49, 50, 51, 16, 31, 23, 0, 25], ["+", 0, 30, 0, 43, 49, 50, 51, 16, 17, 33], ["+", 0, 30, 0, 43, 49, 50, 51, 16, 12, 13]]
1
349
#include <bits/stdc++.h> using namespace std; #define int long long signed main() { int v, e; cin >> v >> e; int g[v][v]; int INF = 1LL << 55LL; for (int i = 0; i < v; i++) for (int j = 0; j < v; j++) g[i][j] = (i != j) * INF; for (int i = 0; i < e; i++) { int s, t, d; cin >> s >> t >> d; ...
#include <bits/stdc++.h> using namespace std; #define int long long signed main() { int v, e; cin >> v >> e; int g[v][v]; int INF = 1LL << 55LL; for (int i = 0; i < v; i++) for (int j = 0; j < v; j++) g[i][j] = (i != j) * INF; for (int i = 0; i < e; i++) { int s, t, d; cin >> s >> t >> d; ...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 60], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 20], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 17, 85], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 12, 13]]
1
323
#include <algorithm> #include <array> #include <climits> #include <iostream> #include <vector> using namespace std; static const int MAX = 100; static const long long INFTY = (1LL << 32); int n; long long d[MAX][MAX]; int e, u, v, c; int R[100000]; void floyd() { for (int k = 0; k < n; k++) { for (int i = 0; i...
#include <algorithm> #include <array> #include <climits> #include <iostream> #include <vector> using namespace std; static const int MAX = 100; static const long long INFTY = (1LL << 32); int n; long long d[MAX][MAX]; int e, u, v, c; int R[100000]; void floyd() { for (int k = 0; k < n; k++) { for (int i = 0; i...
[["-", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6], ["+", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6]]
1
418
#include <bits/stdc++.h> #define INF 1e15 using namespace std; typedef struct ee { long long cost, to; } edge; int main() { int v, e; cin >> v >> e; vector<vector<ee>> E(v); long long dp[v + 1][v + 1] = {}; for (int i = 0; i < v; i++) { for (int j = 0; j < v; j++) { dp[i][j] = INF; if (i == ...
#include <bits/stdc++.h> #define INF 1e18 using namespace std; typedef struct ee { long long cost, to; } edge; int main() { int v, e; cin >> v >> e; vector<vector<ee>> E(v); long long dp[v + 1][v + 1] = {}; for (int i = 0; i < v; i++) { for (int j = 0; j < v; j++) { dp[i][j] = INF; if (i == ...
[["-", 36, 36, 36, 36, 0, 30, 0, 58, 51, 59], ["+", 36, 36, 36, 36, 0, 30, 0, 58, 51, 59], ["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 60], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 20], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 17, 33], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 12, 13]]
1
387