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
#include <bits/stdc++.h> using namespace std; /* RMQ and RUQ 区間の最小値を得る(RMQ) 区間の値を変更する(RUQ) */ class RMQ { public: typedef long long ll; ll INF = 1LL << 55; struct data { bool type; // 0 - empty , 1 - update ll value; }; ll n, n_; vector<ll> dat; vector<data> td; int toMax; // 0 -> Rang...
#include <bits/stdc++.h> using namespace std; /* RMQ and RUQ 区間の最小値を得る(RMQ) 区間の値を変更する(RUQ) */ class RMQ { public: typedef long long ll; ll INF = 1LL << 55; struct data { bool type; // 0 - empty , 1 - update ll value; }; ll n, n_; vector<ll> dat; vector<data> td; int toMax; // 0 -> Rang...
[["+", 8, 1, 0, 2, 3, 4, 0, 91, 17, 33], ["+", 0, 91, 28, 23, 0, 16, 31, 23, 0, 24], ["+", 0, 2, 3, 4, 0, 91, 28, 23, 0, 25]]
1
616
#include "algorithm" #include "bitset" #include "climits" #include "cmath" #include "cstdio" #include "functional" #include "iomanip" #include "iostream" #include "list" #include "map" #include "numeric" #include "queue" #include "random" #include "set" #include "stack" #include "string" #include "unordered_map" #inclu...
#include "algorithm" #include "bitset" #include "climits" #include "cmath" #include "cstdio" #include "functional" #include "iomanip" #include "iostream" #include "list" #include "map" #include "numeric" #include "queue" #include "random" #include "set" #include "stack" #include "string" #include "unordered_map" #inclu...
[["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13]]
1
1,923
#include <algorithm> #include <climits> #include <functional> #include <iostream> #include <vector> using namespace std; template <typename MonoidType, typename OperatorType> struct LazySegmentTree { using MMtoM = function<MonoidType(MonoidType, MonoidType)>; using OOtoO = function<OperatorType(OperatorType, Opera...
#include <algorithm> #include <climits> #include <functional> #include <iostream> #include <vector> using namespace std; template <typename MonoidType, typename OperatorType> struct LazySegmentTree { using MMtoM = function<MonoidType(MonoidType, MonoidType)>; using OOtoO = function<OperatorType(OperatorType, Opera...
[["-", 0, 218, 8, 9, 0, 37, 0, 16, 31, 22], ["-", 0, 218, 8, 9, 0, 37, 0, 16, 17, 72]]
1
1,713
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < int(n); i++) #define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--) #define reps(i, n) for (int i = 1; i <= int(n); i++) #define rreps(i, n) for (int i = int(n); i >= 1; i--) #define repi(i, a, b) for (int i = int(a); i < int(b); i++) #define each(x, y) ...
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < int(n); i++) #define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--) #define reps(i, n) for (int i = 1; i <= int(n); i++) #define rreps(i, n) for (int i = int(n); i >= 1; i--) #define repi(i, a, b) for (int i = int(a); i < int(b); i++) #define each(x, y) ...
[["-", 0, 30, 0, 122, 8, 123, 0, 124, 365, 13], ["+", 0, 30, 0, 122, 8, 123, 0, 124, 365, 13]]
1
1,099
#include "bits/stdc++.h" using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; const int INF = 1e9; const ll LINF = 1e18; template <class S, class T> ostream &operator<<(ostream &out, const pair<S, T> &o) { out << "(" << o.first << "," << o.second << ")"; return out; } tem...
#include "bits/stdc++.h" using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; const int INF = 1e9; const ll LINF = 1e18; template <class S, class T> ostream &operator<<(ostream &out, const pair<S, T> &o) { out << "(" << o.first << "," << o.second << ")"; return out; } tem...
[["+", 0, 1, 0, 2, 3, 4, 0, 16, 17, 72], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 12, 13]]
1
973
#include <bits/stdc++.h> using namespace std; #define int long long #define all(v) begin(v), end(v) #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define reps(i, s, n) for (int i = (int)(s); i < (int)(n); i++) #define min(...) min({__VA_ARGS__}) #define max(...) max({__VA_ARGS__}) template <class T1, class T2...
#include <bits/stdc++.h> using namespace std; #define int long long #define all(v) begin(v), end(v) #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define reps(i, s, n) for (int i = (int)(s); i < (int)(n); i++) #define min(...) min({__VA_ARGS__}) #define max(...) max({__VA_ARGS__}) template <class T1, class T2...
[["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13], ["+", 8, 9, 0, 57, 15, 339, 51, 91, 17, 92], ["-", 0, 57, 64, 9, 0, 1, 0, 11, 12, 13], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 12, 13]]
1
721
#include <algorithm> #include <iostream> #pragma warning(disable : 4996) using namespace std; long long seg[1 << 19], seg2[1 << 19], n, v, a, b, c, d, INF = (1LL << 31) - 1, size_ = 1; void push(int u) { if (seg[u] == INF) return; seg[u * 2] = seg[u]; ...
#include <algorithm> #include <iostream> #pragma warning(disable : 4996) using namespace std; long long seg[1 << 19], seg2[1 << 19], n, v, a, b, c, d, INF = (1LL << 31) - 1, size_ = 1; void push(int u) { if (seg[u] == INF) return; seg[u * 2] = seg[u]; ...
[["+", 0, 14, 8, 9, 0, 1, 0, 2, 63, 22], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 24], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 22], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 25], ["+", 0, 30, 0, 14, 8, 9, 0, 1, 0, 35]]
1
543
#include <bits/stdc++.h> #define ll long long #define INF 1000000005 #define MOD 1000000007 #define EPS 1e-10 #define rep(i, n) for (int i = 0; i < (int)n; ++i) #define each(a, b) for (auto(a) : (b)) #define all(v) (v).begin(), (v).end() #define fi first #define se second #define pb push_back #define show(x) cout << #x...
#include <bits/stdc++.h> #define ll long long #define INF 1000000005 #define MOD 1000000007 #define EPS 1e-10 #define rep(i, n) for (int i = 0; i < (int)n; ++i) #define each(a, b) for (auto(a) : (b)) #define all(v) (v).begin(), (v).end() #define fi first #define se second #define pb push_back #define show(x) cout << #x...
[["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 44], ["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
1
642
#include <bits/stdc++.h> #define ll long long #define INF 1000000005 #define MOD 1000000007 #define EPS 1e-10 #define rep(i, n) for (int i = 0; i < (int)n; ++i) #define each(a, b) for (auto(a) : (b)) #define all(v) (v).begin(), (v).end() #define fi first #define se second #define pb push_back #define show(x) cout << #x...
#include <bits/stdc++.h> #define ll long long #define INF 1000000005 #define MOD 1000000007 #define EPS 1e-10 #define rep(i, n) for (int i = 0; i < (int)n; ++i) #define each(a, b) for (auto(a) : (b)) #define all(v) (v).begin(), (v).end() #define fi first #define se second #define pb push_back #define show(x) cout << #x...
[["-", 0, 14, 8, 9, 0, 57, 64, 37, 0, 22], ["+", 0, 14, 8, 9, 0, 57, 64, 37, 0, 22]]
1
768
#include <bits/stdc++.h> using namespace std; using ll = long long; int id = INT_MAX; int id2 = -1; int merge(int l, int r) { return min(l, r); } int merge2(int l, int r) { return r == id2 ? l : r; } unsigned xor128() { static unsigned x = 123456789, y = 362436069, z = 521288629, w = 88675123; unsigned t = x ^ (x...
#include <bits/stdc++.h> using namespace std; using ll = long long; int id = INT_MAX; int id2 = -1; int merge(int l, int r) { return min(l, r); } int merge2(int l, int r) { return r == id2 ? l : r; } unsigned xor128() { static unsigned x = 123456789, y = 362436069, z = 521288629, w = 88675123; unsigned t = x ^ (x...
[["-", 0, 1, 0, 11, 12, 2, 3, 4, 0, 13], ["+", 0, 1, 0, 11, 12, 2, 3, 4, 0, 22]]
1
1,572
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; typedef pair<ll, ll> P; #define fi first #define se second #define repl(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++) #define rep(i, n) repl(i, 0, n) #define each(itr, v) for (auto itr : v) #define pb push_back #defi...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; typedef pair<ll, ll> P; #define fi first #define se second #define repl(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++) #define rep(i, n) repl(i, 0, n) #define each(itr, v) for (auto itr : v) #define pb push_back #defi...
[["-", 36, 36, 0, 30, 0, 43, 49, 50, 51, 22], ["+", 36, 36, 0, 30, 0, 43, 49, 50, 51, 22]]
1
650
#include <algorithm> #include <cmath> #include <cstdio> #include <cstring> #include <deque> #include <fstream> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <vector> using namespace std; #define REP(i, n) for (int i = 0; i < n; ++i) #define FOR(i, a, b) ...
#include <algorithm> #include <cmath> #include <cstdio> #include <cstring> #include <deque> #include <fstream> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <vector> using namespace std; #define REP(i, n) for (int i = 0; i < n; ++i) #define FOR(i, a, b) ...
[["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 22]]
1
681
#include <bits/stdc++.h> using namespace std; #define fst(t) std::get<0>(t) #define snd(t) std::get<1>(t) #define thd(t) std::get<2>(t) #define unless(p) if (!(p)) #define until(p) while (!(p)) using ll = long long; using P = std::tuple<int, int>; using ui = unsigned int; const int dx[8] = {-1, 1, 0, 0, -1, -1, 1, ...
#include <bits/stdc++.h> using namespace std; #define fst(t) std::get<0>(t) #define snd(t) std::get<1>(t) #define thd(t) std::get<2>(t) #define unless(p) if (!(p)) #define until(p) while (!(p)) using ll = long long; using P = std::tuple<int, int>; using ui = unsigned int; const int dx[8] = {-1, 1, 0, 0, -1, -1, 1, ...
[["+", 0, 57, 64, 9, 0, 1, 0, 2, 63, 22], ["+", 64, 9, 0, 1, 0, 2, 3, 4, 0, 24], ["+", 64, 9, 0, 1, 0, 2, 3, 4, 0, 22], ["+", 64, 9, 0, 1, 0, 2, 3, 4, 0, 25], ["+", 8, 9, 0, 57, 64, 9, 0, 1, 0, 35]]
1
715
import copy INF = 10**10 v, e = map(int, input().split()) M = [[INF]*v for i in range(v)] for i in range(v): M[i][i] = 0 for i in range(e): s, t, d = map(int, input().split()) M[s][t] = d # k:グラフの範囲 ans = copy.deepcopy(M) for k in range(v): for i in range(v): if M[i][k] == INF: con...
import copy INF = 10**10 v, e = map(int, input().split()) M = [[INF]*v for i in range(v)] for i in range(v): M[i][i] = 0 for i in range(e): s, t, d = map(int, input().split()) M[s][t] = d # k:グラフの範囲 ans = copy.deepcopy(M) for k in range(v): for i in range(v): if ans[i][k] == INF: c...
[["-", 0, 57, 15, 666, 0, 206, 51, 206, 51, 22], ["+", 0, 57, 15, 666, 0, 206, 51, 206, 51, 22]]
5
247
import sys def warshall(n, matrix): for i in range(n): matrix[i][i] = 0 for i in range(n): for j in range(n): for k in range(n): matrix[j][k] = min(matrix[j][k], matrix[j][i]+matrix[i][k]) return matrix V,E = list(map(int, input().split())) path = [[sys.maxsize] * V for _ in range(V)] for ...
import sys def warshall(n, matrix): for i in range(n): matrix[i][i] = 0 for i in range(n): for j in range(n): for k in range(n): matrix[j][k] = min(matrix[j][k], matrix[j][i]+matrix[i][k]) return matrix V,E = list(map(int, input().split())) path = [[sys.maxsize] * V for _ in range(V)] for ...
[["-", 0, 7, 8, 196, 0, 57, 15, 666, 667, 60], ["-", 8, 196, 0, 57, 15, 666, 0, 319, 500, 22], ["-", 8, 196, 0, 57, 15, 666, 0, 319, 0, 131], ["-", 8, 196, 0, 57, 15, 666, 0, 319, 319, 22], ["+", 0, 7, 8, 196, 0, 57, 15, 666, 667, 47], ["+", 8, 196, 0, 57, 15, 666, 0, 657, 31, 612], ["+", 8, 196, 0, 57, 15, 666, 0, 657...
5
276
from collections import defaultdict vertice,edge = map(int,input().split(" ")) cost = [[0 if m == n else float("inf") for n in range(vertice)] for m in range(vertice)] link = defaultdict(dict) weight = defaultdict(dict) for e in range(edge): i,j,w = map(int,input().split("")) link[i] = link.get(i,set()) | {j}...
from collections import defaultdict vertice,edge = map(int,input().split(" ")) cost = [[0 if m == n else float("inf") for n in range(vertice)] for m in range(vertice)] link = defaultdict(dict) weight = defaultdict(dict) for e in range(edge): i,j,w = map(int,input().split(" ")) link[i] = link.get(i,set()) | {j...
[["+", 3, 4, 0, 652, 3, 4, 0, 557, 0, 6]]
5
268
from collections import defaultdict vertices, edges = (int(n) for n in input().split(" ")) connect = defaultdict(list) cost_dp = [[float("inf") if n != m else 0 for n in range(vertices)] for m in range(vertices)] for e in range(edges): v1, v2, weight = (int(n) for n in input().split(" ")) connect[v1].append([v2...
from collections import defaultdict vertices, edges = (int(n) for n in input().split(" ")) connect = defaultdict(list) cost_dp = [[float("inf") if n != m else 0 for n in range(vertices)] for m in range(vertices)] for e in range(edges): v1, v2, weight = (int(n) for n in input().split(" ")) connect[v1].append([v2...
[["-", 0, 57, 75, 76, 8, 196, 0, 93, 0, 94]]
5
273
# -*- coding: utf-8 -*- def inpl(): return tuple(map(int, input().split())) INF = float("inf") V, E = inpl() adj = [[] for _ in range(V)] D = [[INF]*V for _ in range(V)] for _ in range(E): s, t, d = inpl() D[s][t] = d for v in range(V): D[v][v] = 0 def WarshallFloyd(G): V = len(G) for k in...
# -*- coding: utf-8 -*- def inpl(): return tuple(map(int, input().split())) INF = float("inf") V, E = inpl() adj = [[] for _ in range(V)] D = [[INF]*V for _ in range(V)] for _ in range(E): s, t, d = inpl() D[s][t] = d for v in range(V): D[v][v] = 0 def WarshallFloyd(G): V = len(G) for k in...
[["-", 0, 1, 0, 652, 3, 4, 0, 557, 0, 6], ["+", 0, 1, 0, 652, 3, 4, 0, 557, 0, 6]]
5
253
#include <bits/stdc++.h> using namespace std; #define int long long typedef pair<int, int> pint; typedef vector<int> vint; #define rep(i, n) for (int i = 0; i < (n); i++) #define pb push_back const int INF = 1001001001001001001ll; struct edge { int to, cost; edge(int to, int cost) : to(to), cost(cost) {} }; int...
#include <bits/stdc++.h> using namespace std; #define int long long typedef pair<int, int> pint; typedef vector<int> vint; #define rep(i, n) for (int i = 0; i < (n); i++) #define pb push_back const int INF = 1001001001001001001ll; struct edge { int to, cost; edge(int to, int cost) : to(to), cost(cost) {} }; int...
[["-", 0, 2, 3, 4, 0, 2, 3, 4, 0, 13], ["+", 0, 2, 3, 4, 0, 2, 3, 4, 0, 22], ["-", 0, 1, 0, 11, 31, 69, 341, 342, 0, 13], ["+", 0, 1, 0, 11, 31, 69, 341, 342, 0, 22]]
1
370
#include <algorithm> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <deque> #include <functional> #include <iostream> #include <map> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <utility> #include <vector> using names...
#include <algorithm> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <deque> #include <functional> #include <iostream> #include <map> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <utility> #include <vector> using names...
[["-", 0, 14, 49, 53, 54, 55, 0, 56, 39, 78], ["+", 0, 14, 49, 53, 54, 55, 0, 56, 39, 78], ["+", 0, 30, 0, 14, 8, 9, 0, 43, 0, 35], ["+", 0, 14, 8, 9, 0, 1, 0, 2, 63, 22], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 24], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 25]]
1
427
#include <iostream> #include <vector> #define MIN(a, b) ((a < b) ? a : b) #define INF 1000000001 #define N 100000 using namespace std; struct edge { int source; int target; int weight; }; vector<edge> edges; int distances[N]; int prev_distances[N] = {0}; int main() { int V, E, r; cin >> V >> E >> r; ...
#include <iostream> #include <vector> #define MIN(a, b) ((a < b) ? a : b) #define INF 1000000001 #define N 100000 using namespace std; struct edge { int source; int target; int weight; }; vector<edge> edges; int distances[N]; int prev_distances[N] = {0}; int main() { int V, E, r; cin >> V >> E >> r; ...
[["-", 15, 339, 51, 16, 31, 69, 341, 342, 0, 22], ["+", 15, 339, 51, 16, 31, 69, 341, 342, 0, 22], ["-", 15, 339, 51, 16, 12, 69, 341, 342, 0, 22], ["+", 15, 339, 51, 16, 12, 69, 341, 342, 0, 22]]
1
353
#include <algorithm> #include <cstdio> #include <queue> #include <vector> using namespace std; const int INF = 1000000000; struct edge { int to, cost; }; typedef pair<int, int> P; vector<edge> G[100000]; priority_queue<P, vector<P>, greater<P>> q; int V, E, r; int d[100000]; int main() { scanf("%d %d %d", &V,...
#include <algorithm> #include <cstdio> #include <queue> #include <vector> using namespace std; const int INF = 1000000000; struct edge { int to, cost; }; typedef pair<int, int> P; vector<edge> G[100000]; priority_queue<P, vector<P>, greater<P>> q; int V, E, r; int d[100000]; int main() { scanf("%d %d %d", &V,...
[["-", 15, 339, 51, 16, 12, 16, 31, 118, 28, 22], ["-", 15, 339, 51, 16, 12, 16, 31, 118, 17, 131], ["-", 15, 339, 51, 16, 12, 16, 31, 118, 119, 120], ["+", 15, 339, 51, 16, 12, 16, 31, 69, 28, 22], ["+", 51, 16, 12, 16, 31, 69, 341, 342, 0, 70], ["+", 51, 16, 12, 16, 31, 69, 341, 342, 0, 22], ["+", 51, 16, 12, 16, 31,...
1
389
// Created by Vignesh Manoharan #include <algorithm> #include <cassert> #include <cmath> #include <cstdio> #include <cstring> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <vector> using namespace std; typedef long long ll; typedef vector<int> vi; typedef pair<int, int...
// Created by Vignesh Manoharan #include <algorithm> #include <cassert> #include <cmath> #include <cstdio> #include <cstring> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <vector> using namespace std; typedef long long ll; typedef vector<int> vi; typedef pair<int, int...
[["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 22], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 22]]
1
659
#include <algorithm> #include <functional> #include <iostream> #include <queue> #include <vector> using namespace std; #define WHITE 0 #define GRAY 1 #define BLACK 2 #define MAX_N 150000 #define INF 1355135500 priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> Q; int d[MAX_N], col[MAX_N...
#include <algorithm> #include <functional> #include <iostream> #include <queue> #include <vector> using namespace std; #define WHITE 0 #define GRAY 1 #define BLACK 2 #define MAX_N 150000 #define INF 1355135500 priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> Q; int d[MAX_N], col[MAX_N...
[["+", 0, 1, 0, 16, 31, 16, 12, 5, 0, 62]]
1
424
#include <algorithm> #include <iostream> #include <map> #include <math.h> #include <queue> #include <stack> #include <vector> using namespace std; #define int long long inline int in() { int32_t x; scanf("%d", &x); return x; } inline string getStr() { char ch[200000]; scanf("%s", ch); return ch; } inline ch...
#include <algorithm> #include <iostream> #include <map> #include <math.h> #include <queue> #include <stack> #include <vector> using namespace std; #define int long long inline int in() { int32_t x; scanf("%d", &x); return x; } inline string getStr() { char ch[200000]; scanf("%s", ch); return ch; } inline ch...
[["-", 0, 30, 0, 43, 49, 50, 51, 16, 31, 13], ["+", 0, 30, 0, 43, 49, 50, 51, 16, 31, 13], ["-", 0, 57, 15, 339, 51, 16, 12, 16, 17, 60], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 17, 19]]
1
564
#include <bits/stdc++.h> using namespace std; #define fi first #define se second const int MAXN = 100000; typedef pair<int, int> ii; typedef vector<ii> vii; vii adjList[MAXN]; int dist[MAXN]; bitset<MAXN> inq; queue<int> q; int main() { int N, E, S; cin >> N >> E >> S; for (int i = 0; i < N; i++) { i...
#include <bits/stdc++.h> using namespace std; #define fi first #define se second const int MAXN = 100000; typedef pair<int, int> ii; typedef vector<ii> vii; vii adjList[MAXN]; int dist[MAXN]; bitset<MAXN> inq; queue<int> q; int main() { int N, E, S; cin >> N >> E >> S; for (int i = 0; i < E; i++) { i...
[["-", 0, 14, 8, 9, 0, 7, 15, 16, 12, 22], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 12, 22]]
1
338
// GRL_1_A #include <iostream> #include <math.h> #include <queue> #include <vector> #define N 10000000000 using namespace std; struct edge { int adj; int dis; }; int main() { int V, E, r, s, t, d, x; vector<vector<edge>> A; vector<int> distance; queue<int> ver; edge e; cin >> V >> E >> r; A.resize...
// GRL_1_A #include <iostream> #include <math.h> #include <queue> #include <vector> #define N 1000000000 using namespace std; struct edge { int adj; int dis; }; int main() { int V, E, r, s, t, d, x; vector<vector<edge>> A; vector<int> distance; queue<int> ver; edge e; cin >> V >> E >> r; A.resize(...
[["-", 36, 36, 36, 36, 0, 30, 0, 58, 51, 59], ["+", 36, 36, 36, 36, 0, 30, 0, 58, 51, 59]]
1
339
#include <iostream> #include <vector> const int MAX_V = 100000; const int MAX_E = 500000; int r; int INF = -1; //??????fromk???????????????to???????????????cost?????? struct edge { int from, to, cost; }; edge es[MAX_E]; long long d[MAX_V]; //???????????¢ int V, E; // V???????????°???E???????????° // s??...
#include <iostream> #include <vector> const int MAX_V = 100000; const int MAX_E = 500000; int r; long long INF = 10e15; //??????fromk???????????????to???????????????cost?????? struct edge { int from, to, cost; }; edge es[MAX_E]; long long d[MAX_V]; //???????????¢ int V, E; // V???????????°???E???????????...
[["-", 36, 36, 36, 36, 0, 30, 0, 43, 39, 40], ["+", 36, 36, 0, 30, 0, 43, 39, 86, 0, 96], ["-", 36, 36, 0, 30, 0, 43, 49, 50, 51, 13], ["+", 36, 36, 0, 30, 0, 43, 49, 50, 51, 13]]
1
320
#include <iostream> #include <queue> #include <vector> using namespace std; #define INF 10000000001 class E { public: int rel, cost; E(int rel, int cost) { this->rel = rel; this->cost = cost; } }; vector<E> G[100000]; int main() { int v = 0; // num of vertices int e = 0; // num of edges int r = 0...
#include <iostream> #include <queue> #include <vector> using namespace std; #define INF 1000000001 class E { public: int rel, cost; E(int rel, int cost) { this->rel = rel; this->cost = cost; } }; vector<E> G[100000]; int main() { int v = 0; // num of vertices int e = 0; // num of edges int r = 0; /...
[["-", 36, 36, 36, 36, 0, 30, 0, 58, 51, 59], ["+", 36, 36, 36, 36, 0, 30, 0, 58, 51, 59]]
1
381
#include "bits/stdc++.h" using namespace std; #include <chrono> //????????? #pragma region MACRO #define putans(x) \ std::cerr << "[ answer ]: "; \ cout << (x) << endl #define dputans(x) ...
#include "bits/stdc++.h" using namespace std; #include <chrono> //????????? #pragma region MACRO #define putans(x) \ std::cerr << "[ answer ]: "; \ cout << (x) << endl #define dputans(x) ...
[["-", 36, 36, 0, 30, 0, 43, 49, 50, 51, 13], ["+", 36, 36, 0, 30, 0, 43, 49, 50, 51, 13], ["-", 0, 14, 49, 53, 54, 55, 0, 56, 39, 78], ["+", 0, 14, 49, 53, 54, 55, 0, 56, 39, 78]]
1
781
#include <algorithm> #include <functional> #include <iostream> #include <queue> #include <vector> using namespace std; int n, m, s; vector<int> et[100000]; vector<int> ec[100000]; int minDist[100000]; int INF = 1145141919; void dijkstra() { for (int i = 0; i < n; i++) minDist[i] = INF; typedef pair<int, int> ...
#include <algorithm> #include <functional> #include <iostream> #include <queue> #include <vector> using namespace std; int n, m, s; vector<int> et[100000]; vector<int> ec[100000]; int minDist[100000]; int INF = 1145141919; void dijkstra() { for (int i = 0; i < n; i++) minDist[i] = INF; typedef pair<int, int> ...
[["-", 0, 2, 3, 4, 0, 2, 3, 4, 0, 13], ["+", 0, 2, 3, 4, 0, 2, 3, 4, 0, 22]]
1
336
#include <bits/stdc++.h> using namespace std; #define INF 1e9 typedef struct { int cost; int to; } edge; int main() { int V, E, r; vector<edge> v[100000]; cin >> V >> E >> r; for (int i = 0; i < E; i++) { int s; edge t; cin >> s >> t.to >> t.cost; v[s].push_back(t); } int d[100000]; f...
#include <bits/stdc++.h> using namespace std; #define INF 1e9 typedef struct { int cost; int to; } edge; int main() { int V, E, r; vector<edge> v[100000]; cin >> V >> E >> r; for (int i = 0; i < E; i++) { int s; edge t; cin >> s >> t.to >> t.cost; v[s].push_back(t); } int d[100000]; f...
[["-", 0, 1, 0, 11, 31, 69, 341, 342, 0, 13], ["+", 0, 1, 0, 11, 31, 69, 341, 342, 0, 22]]
1
334
#include <algorithm> #include <cmath> #include <cstring> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #include <string> #include <vector> const int MOD = 1e9 + 7; const int iINF = 100000000; const long long int llINF = 1 << 30; #define rep(i, n) for (int i = 0;...
#include <algorithm> #include <cmath> #include <cstring> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #include <string> #include <vector> const int MOD = 1e9 + 7; const int iINF = 100000000; const long long int llINF = 1 << 30; #define rep(i, n) for (int i = 0;...
[["-", 0, 14, 8, 9, 0, 1, 0, 11, 12, 22], ["+", 0, 14, 8, 9, 0, 1, 0, 11, 12, 22], ["-", 0, 57, 15, 339, 51, 16, 31, 16, 12, 22], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 12, 22]]
1
317
#include <bits/stdc++.h> using namespace std; template <typename T> struct RadixHeap { using uint = unsigned; vector<pair<uint, T>> v[33]; uint size, last; RadixHeap() : size(0), last(0) {} bool empty() const { return size == 0; } inline int getbit(int a) { return a ? 32 - __builtin_clz(a) : 0; } v...
#include <bits/stdc++.h> using namespace std; template <typename T> struct RadixHeap { using uint = unsigned; vector<pair<uint, T>> v[33]; uint size, last; RadixHeap() : size(0), last(0) {} bool empty() const { return size == 0; } inline int getbit(int a) { return a ? 32 - __builtin_clz(a) : 0; } v...
[["-", 63, 343, 345, 344, 3, 347, 0, 77, 39, 40], ["+", 345, 344, 3, 347, 0, 77, 39, 86, 0, 87]]
1
737
#include <bits/stdc++.h> using namespace std; #define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++) #define RFOR(i, a, b) for (int i = (int)(b)-1; i >= (int)(a); i--) #define REP(i, n) FOR(i, 0, n) #define RREP(i, n) RFOR(i, 0, n) #define LL long long #define INF INT_MAX / 3 const double EPS = 1e-14; const d...
#include <bits/stdc++.h> using namespace std; #define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++) #define RFOR(i, a, b) for (int i = (int)(b)-1; i >= (int)(a); i--) #define REP(i, n) FOR(i, 0, n) #define RREP(i, n) RFOR(i, 0, n) #define LL long long #define INF INT_MAX / 3 const double EPS = 1e-14; const d...
[["-", 0, 30, 0, 14, 8, 9, 0, 338, 39, 40], ["+", 0, 14, 8, 9, 0, 338, 39, 86, 0, 96], ["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
1
687
#include <algorithm> #include <cmath> #include <iostream> #include <numeric> #include <queue> #include <utility> #include <vector> using ll = long long; template <class T> using vec = std::vector<T>; template <class T> constexpr T nil = static_cast<T>(-1); template <class T> constexpr T inf = std::numeric_limits<T>...
#include <algorithm> #include <cmath> #include <iostream> #include <numeric> #include <queue> #include <utility> #include <vector> using ll = long long; template <class T> using vec = std::vector<T>; template <class T> constexpr T nil = static_cast<T>(-1); template <class T> constexpr T inf = std::numeric_limits<T>...
[["+", 51, 218, 8, 9, 0, 338, 8, 9, 0, 45], ["+", 51, 218, 8, 9, 0, 338, 8, 9, 0, 46], ["-", 0, 14, 8, 9, 0, 7, 15, 16, 12, 22], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 12, 22]]
1
461
#include <algorithm> #include <cmath> #include <iostream> #include <map> #include <queue> #include <stack> #include <string> #include <vector> using namespace std; typedef long long ll; typedef vector<int> vint; typedef vector<ll> vll; typedef pair<int, int> pint; typedef pair<ll, ll> pll; #define range(i, a, b) for (i...
#include <algorithm> #include <cmath> #include <iostream> #include <map> #include <queue> #include <stack> #include <string> #include <vector> using namespace std; typedef long long ll; typedef vector<int> vint; typedef vector<ll> vll; typedef pair<int, int> pint; typedef pair<ll, ll> pll; #define range(i, a, b) for (i...
[["+", 0, 57, 64, 9, 0, 1, 0, 16, 17, 151], ["+", 0, 57, 64, 9, 0, 1, 0, 16, 12, 22]]
1
372
#include <stdio.h> int R = 1, C = 1, H[2000010], N[2000010]; //????????¢??°????????????MAX??? int hyouka(int a, int b) { if (C < b) return 1; if (C < a || b == 0) return 0; return N[H[a]] < N[H[b]] ? 1 : 0; } //?????\??¢??° void hin(int a) { int i = C++; for (N[H[0] = R] = a; hyouka(0, i / 2); i /= 2)...
#include <stdio.h> int R = 1, C = 1, H[2000010], N[2000010]; //????????¢??°????????????MAX??? int hyouka(int a, int b) { if (C < b) return 1; if (C < a || b == 0) return 0; return N[H[a]] < N[H[b]] ? 1 : 0; } //?????\??¢??° void hin(int a) { int i = C++; for (N[H[0] = R] = a; hyouka(0, i / 2); i /= 2)...
[["+", 0, 14, 8, 9, 0, 43, 49, 50, 0, 32], ["+", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13], ["-", 0, 1, 0, 11, 31, 69, 71, 16, 31, 22], ["+", 0, 1, 0, 11, 31, 69, 71, 16, 31, 22]]
0
630
#include <algorithm> #include <cctype> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <deque> #include <iostream> #include <limits> #include <list> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <string...
#include <algorithm> #include <cctype> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <deque> #include <iostream> #include <limits> #include <list> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <string...
[["+", 0, 14, 49, 53, 54, 55, 0, 56, 39, 40], ["+", 0, 14, 49, 53, 54, 55, 0, 56, 49, 22], ["+", 0, 30, 0, 14, 49, 53, 54, 55, 0, 21], ["-", 0, 14, 49, 53, 54, 55, 0, 56, 39, 78], ["+", 0, 14, 49, 53, 54, 55, 0, 56, 39, 78], ["+", 0, 16, 31, 16, 12, 2, 3, 4, 0, 21], ["+", 0, 16, 31, 16, 12, 2, 3, 4, 0, 22]]
1
479
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_3_A #include <climits> #include <iostream> #include <queue> #include <vector> using namespace std; int main(int arg, char **argv) { int V, E; cin >> V >> E; vector<vector<pair<int, int>>> A(E); for (int i = 0; i < E; i++) { int s, t, w; cin...
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_3_A #include <climits> #include <iostream> #include <queue> #include <vector> using namespace std; int main(int arg, char **argv) { int V, E; cin >> V >> E; vector<vector<pair<int, int>>> A(V); for (int i = 0; i < E; i++) { int s, t, w; c...
[["-", 0, 43, 49, 53, 54, 55, 0, 56, 39, 78], ["+", 0, 43, 49, 53, 54, 55, 0, 56, 39, 78]]
1
250
#include <algorithm> #include <iostream> #include <vector> using namespace std; #define MAX 10000 #define INFTY (1 << 29) class DisjointSet { public: vector<int> rank, p; DisjointSet() {} DisjointSet(int size) { rank.resize(size, 0); p.resize(size, 0); for (int i = 0; i < size; i++) makeSet(i)...
#include <algorithm> #include <iostream> #include <vector> using namespace std; #define MAX 10000 #define INFTY (1 << 29) class DisjointSet { public: vector<int> rank, p; DisjointSet() {} DisjointSet(int size) { rank.resize(size, 0); p.resize(size, 0); for (int i = 0; i < size; i++) makeSet(i)...
[["-", 64, 9, 0, 1, 0, 2, 63, 118, 119, 120], ["+", 64, 9, 0, 1, 0, 2, 63, 118, 119, 120]]
1
535
#include <algorithm> #include <array> #include <cmath> #include <complex> #include <deque> #include <functional> #include <iomanip> #include <iostream> #include <iterator> #include <map> #include <memory> #include <numeric> #include <queue> #include <set> #include <stack> #include <string> #include <tuple> #include <un...
#include <algorithm> #include <array> #include <cmath> #include <complex> #include <deque> #include <functional> #include <iomanip> #include <iostream> #include <iterator> #include <map> #include <memory> #include <numeric> #include <queue> #include <set> #include <stack> #include <string> #include <tuple> #include <un...
[["-", 0, 52, 8, 9, 0, 1, 0, 11, 17, 32], ["+", 0, 52, 8, 9, 0, 1, 0, 11, 17, 107], ["-", 0, 2, 3, 4, 0, 16, 31, 118, 28, 22], ["-", 0, 2, 3, 4, 0, 16, 31, 118, 17, 131], ["-", 0, 2, 3, 4, 0, 16, 31, 118, 119, 120], ["-", 3, 4, 0, 2, 3, 4, 0, 16, 17, 72]]
1
462
// be name khoda // Pedram Sadeghian // :) #include <bits/stdc++.h> using namespace std; const int maxN = 1e5; int n, m, k1, k2, dad[maxN], high[maxN], ans; pair<int, pair<int, int>> P[maxN]; int root(int a) { if (dad[a] == a) return a; dad[a] = root(dad[a]); return dad[a]; } void merrge(int a, int b) { if...
// be name khoda // Pedram Sadeghian // :) #include <bits/stdc++.h> using namespace std; const int maxN = 1e5; int n, m, k1, k2, dad[maxN], high[maxN], ans; pair<int, pair<int, int>> P[maxN]; int root(int a) { if (dad[a] == a) return a; dad[a] = root(dad[a]); return dad[a]; } void merrge(int a, int b) { if...
[["-", 0, 14, 8, 9, 0, 7, 15, 16, 12, 22], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 12, 22]]
1
387
// BINARY_BOY!! // THINK TWICE CODE ONCE { TRUE } // ##### ### ## # ### ##### # # ##### #### # # // # # # # # # # # # # # # # # # # # # // ##### # # # # ##### ##### # ##### # # # // # # # # ## # # # # # # # # # # // ##### ### # #...
// BINARY_BOY!! // THINK TWICE CODE ONCE { TRUE } // ##### ### ## # ### ##### # # ##### #### # # // # # # # # # # # # # # # # # # # # # // ##### # # # # ##### ##### # ##### # # # // # # # # ## # # # # # # # # # # // ##### ### # #...
[["+", 0, 14, 8, 9, 0, 37, 0, 2, 63, 22], ["+", 8, 9, 0, 37, 0, 2, 3, 4, 0, 24], ["+", 8, 9, 0, 37, 0, 2, 3, 4, 0, 25]]
1
376
#include <algorithm> #include <math.h> #include <queue> #include <stdio.h> #include <string> #include <utility> template <class T> class Node { public: Node() : parent(0), child(0){}; Node *parent; Node *child; T para; }; template <class T> class UnionFind { public: void Connect(Node<T> *a, Node<T> *b) { Vert...
#include <algorithm> #include <math.h> #include <queue> #include <stdio.h> #include <string> #include <utility> template <class T> class Node { public: Node() : parent(0), child(0){}; Node *parent; Node *child; T para; }; template <class T> class UnionFind { public: void Connect(Node<T> *a, Node<T> *b) { Vert...
[["-", 0, 66, 28, 69, 341, 342, 0, 16, 17, 33], ["-", 0, 66, 28, 69, 341, 342, 0, 16, 12, 13], ["-", 49, 50, 51, 350, 49, 367, 368, 16, 12, 13], ["+", 49, 50, 51, 350, 49, 367, 368, 16, 12, 13]]
1
513
#include <bits/stdc++.h> using namespace std; struct EDGE { int from, to, cost; }; bool operator<(const EDGE &a, const EDGE &b) { return a.cost < b.cost; } vector<EDGE> g; int par[10000]; int find(int x) { if (par[x] == x) return x; return par[x] = find(par[x]); } bool _union(int x, int y) { x = find(x);...
#include <bits/stdc++.h> using namespace std; struct EDGE { int from, to, cost; }; bool operator<(const EDGE &a, const EDGE &b) { return a.cost < b.cost; } vector<EDGE> g; int par[10000]; int find(int x) { if (par[x] == x) return x; return par[x] = find(par[x]); } bool _union(int x, int y) { x = find(x);...
[["-", 0, 14, 8, 9, 0, 7, 15, 16, 12, 22], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 12, 22]]
1
304
#include <algorithm> #include <iostream> #include <vector> using namespace std; // Union-Find Tree class DisjointSet { private: struct Node { int parent; int rank; }; public: DisjointSet(size_t n) : _nodes(n) { int i = 0; for (auto &node : _nodes) { node.parent = i++; node.rank = 0;...
#include <algorithm> #include <iostream> #include <vector> using namespace std; // Union-Find Tree class DisjointSet { private: struct Node { int parent; int rank; }; public: DisjointSet(size_t n) : _nodes(n) { int i = 0; for (auto &node : _nodes) { node.parent = i++; node.rank = 0;...
[["-", 0, 218, 8, 9, 0, 37, 0, 16, 17, 47], ["+", 0, 218, 8, 9, 0, 37, 0, 16, 17, 18], ["-", 49, 50, 51, 2, 3, 4, 0, 16, 17, 72], ["-", 49, 50, 51, 2, 3, 4, 0, 16, 12, 13]]
1
469
#include <functional> #include <iostream> #include <queue> #include <vector> using namespace std; constexpr int INF = 1e9; struct edge { int from, to, cost; bool operator>(const edge &other) const { return cost > other.cost; } }; using edges = vector<edge>; //辺を集めた using graph = vector<edges>; // i番目のvectorには頂点i...
#include <functional> #include <iostream> #include <queue> #include <vector> using namespace std; constexpr int INF = 1e9; struct edge { int from, to, cost; bool operator>(const edge &other) const { return cost > other.cost; } }; using edges = vector<edge>; //辺を集めた using graph = vector<edges>; // i番目のvectorには頂点i...
[["-", 0, 2, 3, 4, 0, 191, 51, 83, 0, 22], ["-", 0, 2, 3, 4, 0, 191, 51, 83, 0, 21], ["+", 0, 2, 3, 4, 0, 191, 51, 83, 0, 21], ["+", 0, 2, 3, 4, 0, 191, 51, 83, 0, 22]]
1
388
#include <algorithm> #include <iostream> #include <vector> using namespace std; class union_find_tree { private: vector<int> par, rank_; public: union_find_tree(int n) : par(n), rank_(n) { for (int i = 0; i < n; i++) { par[i] = i; rank_[i] = 0; } } int root(int x) { if (par[x] == x) { ...
#include <algorithm> #include <iostream> #include <vector> using namespace std; class union_find_tree { private: vector<int> par, rank_; public: union_find_tree(int n) : par(n), rank_(n) { for (int i = 0; i < n; i++) { par[i] = i; rank_[i] = 0; } } int root(int x) { if (par[x] == x) { ...
[["+", 0, 57, 75, 76, 0, 9, 0, 37, 0, 38]]
1
479
#include <functional> #include <iostream> #include <queue> #include <vector> using namespace std; constexpr int INF = 1e9; struct edge { int from, to, cost; bool operator>(const edge &other) const { return cost > other.cost; } }; using edges = vector<edge>; //辺を集めた using graph = vector<edges>; // i番目のvectorには頂点i...
#include <functional> #include <iostream> #include <queue> #include <vector> using namespace std; constexpr int INF = 1e9; struct edge { int from, to, cost; bool operator>(const edge &other) const { return cost > other.cost; } }; using edges = vector<edge>; using graph = vector<edges>; void add_edge(graph &g, i...
[["-", 0, 2, 3, 4, 0, 191, 51, 83, 0, 22], ["-", 0, 2, 3, 4, 0, 191, 51, 83, 0, 21], ["+", 0, 2, 3, 4, 0, 191, 51, 83, 0, 21], ["+", 0, 2, 3, 4, 0, 191, 51, 83, 0, 22]]
1
388
#include <algorithm> #include <iostream> #include <vector> using namespace std; class union_find_tree { private: vector<int> par, rank_; public: union_find_tree(int n) : par(n), rank_(n) { for (int i = 0; i < n; i++) { par[i] = i; rank_[i] = 0; } } int root(int x) { if (par[x] == x) { ...
#include <algorithm> #include <iostream> #include <vector> using namespace std; class union_find_tree { private: vector<int> par, rank_; public: union_find_tree(int n) : par(n), rank_(n) { for (int i = 0; i < n; i++) { par[i] = i; rank_[i] = 0; } } int root(int x) { if (par[x] == x) { ...
[["-", 51, 91, 28, 2, 3, 4, 0, 118, 119, 120], ["+", 51, 91, 28, 2, 3, 4, 0, 118, 119, 120]]
1
439
#include <algorithm> #include <cassert> #include <cmath> #include <iostream> #include <map> #include <numeric> #include <queue> #include <random> #include <set> #include <stack> #include <string> #include <utility> #include <vector> using namespace std; #define MK make_pair #define F first #define S second #define ege ...
#include <algorithm> #include <cassert> #include <cmath> #include <iostream> #include <map> #include <numeric> #include <queue> #include <random> #include <set> #include <stack> #include <string> #include <utility> #include <vector> using namespace std; #define MK make_pair #define F first #define S second #define ege ...
[["-", 0, 52, 8, 9, 0, 1, 0, 11, 17, 107], ["+", 0, 52, 8, 9, 0, 1, 0, 11, 17, 110]]
1
278
import heapq nv, ne = map(int, input().split()) edges = [set() for _ in range(nv)] while ne: s, t, w = map(int, input().split()) edges[s].add((w, t)) edges[t].add((w, s)) ne -= 1 cost = 0 queue = list(edges[0]) heapq.heapify(queue) visited = [False] * nv visited[0] = True while True: edge_cost, ...
import heapq nv, ne = map(int, input().split()) edges = [set() for _ in range(nv)] while ne: s, t, w = map(int, input().split()) edges[s].add((w, t)) edges[t].add((w, s)) ne -= 1 cost = 0 queue = list(edges[0]) heapq.heapify(queue) visited = [False] * nv visited[0] = True while queue: edge_cost,...
[["-", 36, 36, 36, 36, 0, 656, 0, 52, 15, 146], ["+", 36, 36, 36, 36, 0, 656, 0, 52, 15, 22]]
5
179
import sys class UnionFind(): def __init__(self, n): self.n = n self.p = [i for i in range(n + 5)] self.rank = [0 for i in range(n + 5)] def find_set(self, x): if self.p[x] != x: self.p[x] = self.find_set(self.p[x]) return self.p[x] def unite(self, x, ...
import sys class UnionFind(): def __init__(self, n): self.n = n self.p = [i for i in range(n + 5)] self.rank = [0 for i in range(n + 5)] def find_set(self, x): if self.p[x] != x: self.p[x] = self.find_set(self.p[x]) return self.p[x] def unite(self, x, ...
[["-", 64, 196, 0, 1, 0, 662, 31, 206, 206, 22], ["+", 64, 196, 0, 1, 0, 662, 31, 206, 206, 22], ["-", 8, 196, 0, 1, 0, 662, 31, 206, 206, 22], ["+", 8, 196, 0, 1, 0, 662, 31, 206, 206, 22]]
5
312
#include <bits/stdc++.h> using namespace std; using Int = long long; // BEGIN CUT HERE template <typename T, typename E> struct SkewHeap { typedef function<T(T, E)> F; typedef function<E(E, E)> G; SkewHeap *l, *r; T val; F &f; G &g; E add, e; SkewHeap(T val, F &f, G &g, E e) : val(val), f(f), g(g), add...
#include <bits/stdc++.h> using namespace std; using Int = long long; // BEGIN CUT HERE template <typename T, typename E> struct SkewHeap { typedef function<T(T, E)> F; typedef function<E(E, E)> G; SkewHeap *l, *r; T val; F &f; G &g; E add, e; SkewHeap(T val, F &f, G &g, E e) : val(val), f(f), g(g), add...
[["-", 64, 9, 0, 1, 0, 2, 3, 4, 0, 22], ["-", 64, 9, 0, 1, 0, 2, 3, 4, 0, 21], ["+", 64, 9, 0, 1, 0, 2, 3, 4, 0, 21], ["+", 64, 9, 0, 1, 0, 2, 3, 4, 0, 22]]
1
1,227
from heapq import heappush, heappop v,e,r = map(int,input().split()) edges=[[] for i in range(v)] d = [float('INF')]*v for i in range(e): s,t,c = map(int,input().split()) edges.append([t,c]) que = [] heappush(que,(0,r)) d[r] = 0 while que: c, u = heappop(que) for v, s in edges[u]: if d[v] > s + c: ...
from heapq import heappush, heappop v,e,r = map(int,input().split()) edges=[[] for i in range(v)] d = [float('INF')]*v for i in range(e): s,t,c = map(int,input().split()) edges[s].append([t,c]) que = [] heappush(que,(0,r)) d[r] = 0 while que: c, u = heappop(que) for v, s in edges[u]: if d[v] > s + c: ...
[["+", 0, 1, 0, 652, 63, 319, 500, 206, 0, 70], ["+", 0, 1, 0, 652, 63, 319, 500, 206, 206, 22], ["+", 0, 1, 0, 652, 63, 319, 500, 206, 0, 73]]
5
184
# AOJ GRL_1_A # http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_1_A from heapq import heappush, heappop INF = 100000000 def solve(r, t, v, dic): dp = [] q = [] dp = [INF] * v dp[r] = 0 heappush(q, (0, r)) while q: cost, vtx = heappop(q) if dp[vtx] < cost: ...
# AOJ GRL_1_A # http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_1_A from heapq import heappush, heappop INF = 10000000000 def solve(r, v, dic): dp = [] q = [] dp = [INF] * v dp[r] = 0 heappush(q, (0, r)) while q: cost, vtx = heappop(q) if dp[vtx] < cost: ...
[["-", 36, 36, 0, 656, 0, 1, 0, 662, 12, 612], ["+", 36, 36, 0, 656, 0, 1, 0, 662, 12, 612], ["-", 36, 36, 0, 656, 0, 14, 54, 54, 0, 21], ["-", 36, 36, 0, 656, 0, 14, 54, 54, 0, 22], ["-", 0, 1, 0, 662, 12, 652, 3, 4, 0, 21], ["-", 0, 1, 0, 662, 12, 652, 3, 4, 0, 22]]
5
261
from heapq import heappush, heappop V, E, r = list(map(int, input().split())) g = [[] for i in range(V)] for i in range(E): s, t, d = list(map(int, input().split())) g[s].append((t, d)) INF = 10**10 dist = [INF]*V que = [(0,r)] dist[r] = 0 while que: c, v = heappop(que) if dist[v] < c: continue...
from heapq import heappush, heappop V, E, r = list(map(int, input().split())) g = [[] for i in range(V)] for i in range(E): s, t, d = list(map(int, input().split())) g[s].append((t, d)) INF = 10**10 dist = [INF]*V que = [(0,r)] dist[r] = 0 while que: c, v = heappop(que) if dist[v] < c: continue...
[["-", 0, 1, 0, 652, 3, 4, 0, 660, 0, 22], ["-", 0, 1, 0, 652, 3, 4, 0, 660, 0, 21], ["+", 0, 1, 0, 652, 3, 4, 0, 660, 0, 21], ["+", 0, 1, 0, 652, 3, 4, 0, 660, 0, 22]]
5
202
from collections import defaultdict from collections import deque from sys import stdin def sp(G,R,V): d = {} INF = float('inf') for i in range(V): d[i] = INF d[R] = 0 q = deque([(R)]) while q: u = q.popleft() for v in G[u]: if d[v[0]] > d[u] + v[1]: ...
from collections import defaultdict from collections import deque from sys import stdin def sp(G,R,V): d = {} INF = float('inf') for i in range(V): d[i] = INF d[R] = 0 q = deque([(R)]) while q: u = q.popleft() for v in G[u]: if d[v[0]] > d[u] + v[1]: ...
[["-", 36, 36, 0, 656, 0, 1, 0, 652, 63, 22], ["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 24], ["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 22], ["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 25]]
5
262
from collections import defaultdict import heapq vertice,edge,source = map(int,input().split(" ")) link = defaultdict(dict) weight = defaultdict(dict) answer = [-1] * vertice for e in range(edge): i,j,w = map(int,input().split(" ")) link[i] = link.get(i,set()) | {j} weight[i].update({j:w}) goal = v queue ...
from collections import defaultdict import heapq vertice,edge,source = map(int,input().split(" ")) link = defaultdict(dict) weight = defaultdict(dict) answer = [-1] * vertice for e in range(edge): i,j,w = map(int,input().split(" ")) link[i] = link.get(i,set()) | {j} weight[i].update({j:w}) queue = [] heapq...
[["-", 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, 22]]
5
220
import heapq def main(): nvertices, nedges, s = map(int, input().split()) adj = [[] for i in range(nvertices)] for i in range(nedges): u, v, w = map(int, input().split()) adj[u].append((v, w)) INF = float('inf') costs = [INF] * nvertices costs[0] = 0 que = [(0, s)] for...
import heapq def main(): nvertices, nedges, s = map(int, input().split()) adj = [[] for i in range(nvertices)] for i in range(nedges): u, v, w = map(int, input().split()) adj[u].append((v, w)) INF = float('inf') costs = [INF] * nvertices costs[s] = 0 que = [(0, s)] for...
[["-", 8, 196, 0, 1, 0, 662, 31, 206, 206, 612], ["+", 8, 196, 0, 1, 0, 662, 31, 206, 206, 22]]
5
233
V,E,r = map(int, input().split()) edges = [] for _ in range(E): tmp = [int(x) for x in input().split()] edges.append(tmp) d = [float('inf') for _ in range(V)] d[r] = 0 for _ in range(V-1): count = 0 for x in edges: s,t,d = x if d[t] > d[s] + d: count += 1 d[t] =...
#Bellman-FordだとTLEになる(はず) V,E,r = map(int, input().split()) edges = [] for _ in range(E): tmp = [int(x) for x in input().split()] edges.append(tmp) d = [float('inf') for _ in range(V)] d[r] = 0 for _ in range(V-1): count = 0 for x in edges: s,t,w = x if d[t] > d[s] + w: co...
[["-", 8, 196, 0, 1, 0, 662, 31, 684, 0, 22], ["+", 8, 196, 0, 1, 0, 662, 31, 684, 0, 22], ["-", 8, 196, 0, 57, 15, 666, 0, 657, 12, 22], ["+", 8, 196, 0, 57, 15, 666, 0, 657, 12, 22], ["-", 64, 196, 0, 1, 0, 662, 12, 657, 12, 22], ["+", 64, 196, 0, 1, 0, 662, 12, 657, 12, 22]]
5
162
#include <algorithm> #include <cstring> #include <iostream> #include <queue> #include <string> #include <vector> using namespace std; const int inf = 1e9 + 5; const int maxn = 100000; typedef vector<int> vi; typedef long long ll; #define fi first #define se second typedef pair<int, int> P; int d[maxn + 5]; bool visited...
#include <algorithm> #include <cstring> #include <iostream> #include <queue> #include <string> #include <vector> using namespace std; const int inf = 1e9 + 5; const int maxn = 100000; typedef vector<int> vi; typedef long long ll; #define fi first #define se second typedef pair<int, int> P; int d[maxn + 5]; bool visited...
[["-", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6], ["+", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6]]
1
429
#include <bits/stdc++.h> #define GET_MACRO(_1, _2, _3, _4, _5, _6, _7, _8, NAME, ...) NAME #define pr(...) \ cerr << GET_MACRO(__VA_ARGS__, pr8, pr7, pr6, pr5, pr4, pr3, pr2, \ pr1)(__VA_ARGS__) ...
#include <bits/stdc++.h> #define GET_MACRO(_1, _2, _3, _4, _5, _6, _7, _8, NAME, ...) NAME #define pr(...) \ cerr << GET_MACRO(__VA_ARGS__, pr8, pr7, pr6, pr5, pr4, pr3, pr2, \ pr1)(__VA_ARGS__) ...
[["-", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6], ["+", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6]]
1
1,088
#include <cstdio> #include <queue> #include <vector> using namespace std; typedef long long ll; typedef pair<ll, ll> P; typedef pair<ll, P> Q; ll v, e, r, s[2000], t[2000], d[2000], dp[1001], INF = 1e9; bool search() { for (ll i = 0; i < v; i++) dp[i] = INF; dp[r] = 0; for (ll i = 0; i < v; i++) { bool ...
#include <cstdio> #include <queue> #include <vector> using namespace std; typedef long long ll; typedef pair<ll, ll> P; typedef pair<ll, P> Q; ll v, e, r, s[2000], t[2000], d[2000], dp[1001], INF = 1e9; bool search() { for (ll i = 0; i < v; i++) dp[i] = INF; dp[r] = 0; for (ll i = 0; i < v; i++) { bool ...
[["-", 0, 57, 15, 339, 51, 16, 31, 69, 28, 22], ["+", 0, 57, 15, 339, 51, 16, 31, 69, 28, 22]]
1
346
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define int long long #define rep(i, n) for (int i = 0; i < n; i++) #define MOD 1000000007 #define INF 1000000000000000 #define fi first #define se second #define all(v) v.begin(), v.end() int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0}; #define pb push...
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define int long long #define rep(i, n) for (int i = 0; i < n; i++) #define MOD 1000000007 #define INF 1000000000000000 #define fi first #define se second #define all(v) v.begin(), v.end() int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0}; #define pb push...
[["+", 0, 14, 8, 9, 0, 1, 0, 2, 63, 22], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 24], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 22], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 25], ["+", 0, 30, 0, 14, 8, 9, 0, 1, 0, 35]]
1
337
#include <algorithm> #include <cmath> #include <cstdio> #include <cstring> #include <queue> #include <vector> using namespace std; #define rep(i, n) for (int i = 0; i < (n); i++) #define reg(i, a, b) for (int i = (a); i <= (b); i++) typedef long long int lli; typedef pair<int, int> mp; #define fir first #define sec sec...
#include <algorithm> #include <cmath> #include <cstdio> #include <cstring> #include <queue> #include <vector> using namespace std; #define rep(i, n) for (int i = 0; i < (n); i++) #define reg(i, a, b) for (int i = (a); i <= (b); i++) typedef long long int lli; typedef pair<int, int> mp; #define fir first #define sec sec...
[["+", 0, 1, 0, 2, 3, 4, 0, 16, 17, 72], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 12, 13], ["+", 0, 1, 0, 2, 3, 4, 0, 25, 0, 35], ["-", 0, 57, 15, 339, 51, 16, 12, 16, 17, 33], ["-", 0, 57, 15, 339, 51, 16, 12, 16, 12, 13]]
1
422
#include <cstdlib> #include <iostream> using namespace std; #define INF 1e9 #define MAX_E 500000 #define MAX_V 100000 struct edge { int u, v, cost; }; edge es[MAX_E]; int dis[MAX_V]; int V, E, r; void bellman_ford(int s) { for (int i = 0; i < V; i++) dis[i] = INF; dis[s] = 0; int count = 0; while (true...
#include <cstdlib> #include <iostream> using namespace std; #define INF 1e9 #define MAX_E 500000 #define MAX_V 100000 struct edge { int u, v, cost; }; edge es[MAX_E]; int dis[MAX_V]; int V, E, r; void bellman_ford(int s) { for (int i = 0; i < V; i++) dis[i] = INF; dis[s] = 0; int count = 0; while (true...
[["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 98], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 31, 22], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 17, 47], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 12, 13]]
1
331
#include <bits/stdc++.h> using namespace std; #define FOR(i, k, n) for (int i = (k); i < (n); i++) #define REP(i, n) FOR(i, 0, n) #define ALL(a) a.begin(), a.end() #define MS(m, v) memset(m, v, sizeof(m)) #define D10 fixed << setprecision(10) typedef vector<int> vi; typedef vector<string> vs; typedef pair<int, int> pii...
#include <bits/stdc++.h> using namespace std; #define FOR(i, k, n) for (int i = (k); i < (n); i++) #define REP(i, n) FOR(i, 0, n) #define ALL(a) a.begin(), a.end() #define MS(m, v) memset(m, v, sizeof(m)) #define D10 fixed << setprecision(10) typedef vector<int> vi; typedef vector<string> vs; typedef pair<int, int> pii...
[["+", 0, 14, 8, 9, 0, 57, 75, 76, 0, 95]]
1
557
// #include <bits/stdc++.h> using namespace std; using ll = long long; #define rep(i, j) for (int i = 0; i < (int)(j); i++) constexpr int INF = 1 << 28; struct Edge { int to; ll cost; Edge(int to, ll cost) : to(to), cost(cost) {} }; using EdgeList = vector<vector<Edge>>; using Vatex = int; constexpr ll INFL = 1LL...
// #include <bits/stdc++.h> using namespace std; using ll = long long; #define rep(i, j) for (int i = 0; i < (int)(j); i++) constexpr int INF = 1 << 28; struct Edge { int to; ll cost; Edge(int to, ll cost) : to(to), cost(cost) {} }; using EdgeList = vector<vector<Edge>>; using Vatex = int; constexpr ll INFL = 1LL...
[["-", 0, 57, 15, 339, 51, 16, 31, 16, 17, 79], ["-", 0, 57, 15, 339, 51, 16, 31, 16, 12, 22], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 17, 18], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 12, 22]]
1
355
#include <algorithm> #include <iostream> #include <queue> #include <vector> using namespace std; typedef pair<long long int, int> P; struct vertex { vector<P> E; // cost,to }; #define INF 5000000001 vertex V[100000]; long long int minimum[100000]; int main() { int NV, NE, r; cin >> NV >> NE >> r; fill(minimum,...
#include <algorithm> #include <iostream> #include <queue> #include <vector> using namespace std; typedef pair<long long int, int> P; struct vertex { vector<P> E; // cost,to }; #define INF 5000000001 vertex V[100000]; long long int minimum[100000]; int main() { int NV, NE, r; cin >> NV >> NE >> r; fill(minimum,...
[["-", 15, 339, 51, 16, 31, 69, 341, 342, 0, 22], ["+", 15, 339, 51, 16, 31, 69, 341, 342, 0, 22], ["-", 0, 338, 12, 118, 28, 69, 341, 342, 0, 22], ["+", 0, 338, 12, 118, 28, 69, 341, 342, 0, 22], ["-", 51, 16, 31, 16, 31, 69, 341, 342, 0, 22], ["+", 51, 16, 31, 16, 31, 69, 341, 342, 0, 22], ["-", 0, 11, 12, 16, 31, 69...
1
313
#include <algorithm> #include <cstdio> #include <vector> using namespace std; #define INF 10000000 #define MAX_V 1000 int V, E; struct edge { int from, to, cost; }; vector<edge> edges; int d[MAX_V]; int main() { int f, t, c; int s; scanf("%d %d %d", &V, &E, &s); for (int i = 0; i < E; i++) { scanf("%d %...
#include <algorithm> #include <cstdio> #include <vector> using namespace std; #define INF 10000000 #define MAX_V 1000 int V, E; struct edge { int from, to, cost; }; vector<edge> edges; int d[MAX_V]; int main() { int f, t, c; int s; scanf("%d %d %d", &V, &E, &s); for (int i = 0; i < E; i++) { scanf("%d %...
[["-", 64, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 64, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 64, 1, 0, 2, 3, 4, 0, 5, 0, 44], ["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 44]]
1
313
#include <iostream> #include <math.h> using namespace std; //= AOJ GRL_1_A const int V_constraint = 1000, E_constraint = 2000, D_constraint = 10000; int V, E, R, S[E_constraint + 10], T[E_constraint + 10], D[E_constraint + 10], C[V_constraint + 10]; const int inf = V_constraint * D_constraint + 100; // int paren...
#include <iostream> #include <math.h> using namespace std; //= AOJ GRL_1_A const int V_constraint = 1000, E_constraint = 2000, D_constraint = 10000; int V, E, R, S[E_constraint + 10], T[E_constraint + 10], D[E_constraint + 10], C[V_constraint + 10]; const int inf = V_constraint * D_constraint + 100; // int paren...
[["-", 8, 9, 0, 7, 15, 16, 12, 16, 31, 22], ["-", 8, 9, 0, 7, 15, 16, 12, 16, 17, 33], ["-", 8, 9, 0, 7, 15, 16, 12, 16, 12, 13], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 12, 22], ["-", 0, 9, 0, 7, 15, 16, 12, 16, 17, 33], ["-", 0, 9, 0, 7, 15, 16, 12, 16, 12, 13]]
1
422
#include <bits/stdc++.h> #define P pair<int, int> #define rep(i, n) for (int i = 0; i < n; i++) #define INF 1 << 28 #define mk make_pair using namespace std; int main() { int n, m, t; cin >> n >> m >> t; vector<pair<int, int>> a[n]; rep(i, m) { int q, w, e; cin >> q >> w >> e; a[q].push_back(mk(w, e...
#include <bits/stdc++.h> #define P pair<int, int> #define rep(i, n) for (int i = 0; i < n; i++) #define INF 1 << 28 #define mk make_pair using namespace std; int main() { int n, m, t; cin >> n >> m >> t; vector<pair<int, int>> a[n]; rep(i, m) { int q, w, e; cin >> q >> w >> e; a[q].push_back(mk(w, e...
[["-", 64, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["+", 64, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["-", 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 <cmath> #include <deque> #include <iomanip> #include <iostream> #include <limits> #include <map> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <vector> using namespace std; typedef long long ll; #define REP(i, n) for (int(i) = 0; (i) < (int...
#include <algorithm> #include <cmath> #include <deque> #include <iomanip> #include <iostream> #include <limits> #include <map> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <vector> using namespace std; typedef long long ll; #define REP(i, n) for (int(i) = 0; (i) < (int...
[["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 22]]
1
603
#include <bits/stdc++.h> using namespace std; template <typename T> struct edge { int src, to; T cost; edge(int to, T cost) : src(-1), to(to), cost(cost) {} edge(int src, int to, T cost) : src(src), to(to), cost(cost) {} edge &operator=(const int &x) { to = x; return *this; } operator int() ...
#include <bits/stdc++.h> using namespace std; template <typename T> struct edge { int src, to; T cost; edge(int to, T cost) : src(-1), to(to), cost(cost) {} edge(int src, int to, T cost) : src(src), to(to), cost(cost) {} edge &operator=(const int &x) { to = x; return *this; } operator int() ...
[["+", 8, 9, 0, 43, 49, 53, 54, 55, 0, 24], ["+", 0, 43, 49, 53, 54, 55, 0, 56, 39, 78], ["+", 8, 9, 0, 43, 49, 53, 54, 55, 0, 25]]
1
565
#include <algorithm> #include <assert.h> #include <cmath> #include <cstdio> #include <cstring> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <utility> #include <vector> #define loop(i, a, b) for (int i = a; i < b; i++...
#include <algorithm> #include <assert.h> #include <cmath> #include <cstdio> #include <cstring> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <utility> #include <vector> #define loop(i, a, b) for (int i = a; i < b; i++...
[["-", 0, 57, 15, 339, 51, 16, 31, 16, 12, 22], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 12, 22]]
1
562
#include <algorithm> #include <bitset> #include <cmath> #include <complex> #include <cstdio> #include <fstream> #include <functional> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <time.h> #include <tuple> #include <u...
#include <algorithm> #include <bitset> #include <cmath> #include <complex> #include <cstdio> #include <fstream> #include <functional> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <time.h> #include <tuple> #include <u...
[["-", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6], ["+", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6]]
1
682
#include <iostream> #include <queue> #include <vector> using namespace std; typedef pair<long long, long long> P; int v, e, r; long long int INF = 1e10; struct edge { int to; long long cost; edge(int _to, long long _cost) : to(_to), cost(_cost) {} }; vector<edge> G[1010]; bool f[1010]; long long d[1010]; bool bel...
#include <iostream> #include <queue> #include <vector> using namespace std; typedef pair<long long, long long> P; int v, e, r; long long int INF = 1e10; struct edge { int to; long long cost; edge(int _to, long long _cost) : to(_to), cost(_cost) {} }; vector<edge> G[1010]; bool f[1010]; long long d[1010]; bool bel...
[["+", 0, 7, 8, 9, 0, 7, 8, 9, 0, 46], ["-", 0, 7, 8, 9, 0, 7, 8, 9, 0, 46]]
1
420
#include <algorithm> #include <iostream> #include <vector> using namespace std; constexpr int MAX_N = 100000; vector<int> pre_order( MAX_N, -1); // pre_order[i]:=??±???????????¢?´¢??§???????????????i????????£?????¨??????timer vector<int> post_order( MAX_N, -1); // post_order[i]:=??±???????????¢?´¢??§?...
#include <algorithm> #include <iostream> #include <vector> using namespace std; constexpr int MAX_N = 100000; vector<int> pre_order( MAX_N, -1); // pre_order[i]:=??±???????????¢?´¢??§???????????????i????????£?????¨??????timer vector<int> post_order( MAX_N, -1); // post_order[i]:=??±???????????¢?´¢??§?...
[["-", 0, 57, 15, 339, 51, 16, 31, 69, 28, 22], ["+", 0, 57, 15, 339, 51, 16, 31, 69, 28, 22]]
1
500
#include <algorithm> #include <climits> #include <iostream> #include <vector> using namespace std; const int V_MAX = 100000; vector<int> G[V_MAX]; vector<bool> check(V_MAX, false); vector<int> pre(V_MAX); vector<int> low(V_MAX, INT_MAX); vector<bool> articulation(V_MAX, false); int order; void dfs(int s, int p) { ...
#include <algorithm> #include <climits> #include <iostream> #include <vector> using namespace std; const int V_MAX = 100000; vector<int> G[V_MAX]; vector<bool> check(V_MAX, false); vector<int> pre(V_MAX, INT_MAX); vector<int> low(V_MAX, INT_MAX); vector<bool> articulation(V_MAX, false); int order; void dfs(int s, in...
[["+", 0, 30, 0, 43, 49, 53, 54, 55, 0, 21], ["+", 0, 43, 49, 53, 54, 55, 0, 56, 39, 78]]
1
422
#include <bits/stdc++.h> using namespace std; const int M = 1e5 + 10; int n, m, H[M]; vector<int> g[M]; bool cv[M], mark[M]; int dfs(int v, int par, int h) { int up = h, cnt = 0; mark[v] = true; H[v] = h; if (g[v].size() == 1 && v != 1) return h; for (auto u : g[v]) if (!mark[u]) { cnt++; ...
#include <bits/stdc++.h> using namespace std; const int M = 1e5 + 10; int n, m, H[M]; vector<int> g[M]; bool cv[M], mark[M]; int dfs(int v, int par, int h) { int up = h, cnt = 0; mark[v] = true; H[v] = h; if (g[v].size() == 1 && v != 1) return h; for (auto u : g[v]) if (!mark[u]) { cnt++; ...
[["-", 64, 9, 0, 57, 15, 339, 51, 16, 17, 47], ["+", 64, 9, 0, 57, 15, 339, 51, 16, 17, 20]]
1
315
#include <algorithm> #include <cstdio> #include <vector> using namespace std; vector<int> G[1000000]; vector<pair<int, int>> bridge; vector<int> articulation; int ord[1000000], low[1000000]; bool vis[1000000]; void dfs(int v, int p, int &k) { vis[v] = true; ord[v] = k++; low[v] = ord[v]; bool isArticulatio...
#include <algorithm> #include <cstdio> #include <vector> using namespace std; vector<int> G[1000000]; vector<pair<int, int>> bridge; vector<int> articulation; int ord[1000000], low[1000000]; bool vis[1000000]; void dfs(int v, int p, int &k) { vis[v] = true; ord[v] = k++; low[v] = ord[v]; bool isArticulatio...
[["-", 8, 1, 0, 2, 3, 4, 0, 16, 17, 72], ["-", 8, 1, 0, 2, 3, 4, 0, 16, 12, 13]]
1
512
#include <stdio.h> #include <stdlib.h> struct node { int id; struct node *next; }; struct pair { int x; int y; }; struct node **list; struct pair *art; int *seq, counter, sp; void Insert(int, int); int Biconnected(int, int); void qsort1(int, int); int main(void) { int i, j, v, e, s, t; scanf("%d %d", &v, ...
#include <stdio.h> #include <stdlib.h> struct node { int id; struct node *next; }; struct pair { int x; int y; }; struct node **list; struct pair *art; int *seq, counter, sp; void Insert(int, int); int Biconnected(int, int); void qsort1(int, int); int main(void) { int i, j, v, e, s, t; scanf("%d %d", &v, ...
[["-", 0, 57, 15, 23, 0, 16, 31, 16, 17, 20], ["+", 0, 57, 15, 23, 0, 16, 31, 16, 17, 47], ["-", 0, 57, 15, 23, 0, 16, 31, 16, 17, 19], ["+", 0, 57, 15, 23, 0, 16, 31, 16, 17, 18]]
0
790
#include <algorithm> #include <iostream> #include <vector> using namespace std; struct Edge { int from, to; Edge(int f, int t) : from(f), to(t) {} }; using Edges = vector<Edge>; using Graph = vector<Edges>; class LowLink { public: LowLink(int n) : mGraph(n), mOrd(n), mLow(n), mUsed(n, false) {} void add_edge...
#include <algorithm> #include <iostream> #include <vector> using namespace std; struct Edge { int from, to; Edge(int f, int t) : from(f), to(t) {} }; using Edges = vector<Edge>; using Graph = vector<Edges>; class LowLink { public: LowLink(int n) : mGraph(n), mOrd(n), mLow(n), mUsed(n, false) {} void add_edge...
[["+", 64, 1, 0, 2, 3, 4, 0, 2, 63, 22], ["+", 0, 2, 3, 4, 0, 2, 3, 4, 0, 24], ["+", 0, 2, 3, 4, 0, 2, 3, 4, 0, 25]]
1
568
#include <algorithm> #include <iostream> #include <vector> using namespace std; int N, M, A[200009], B[200009], pre[200009], low[200009], cnts; vector<pair<int, int>> X[200009]; vector<int> G; void dfs(int pos, int par) { cnts++; pre[pos] = cnts; low[pos] = cnts; for (int i = 0; i < X[pos].size(); i++) { ...
#include <algorithm> #include <iostream> #include <vector> using namespace std; int N, M, A[200009], B[200009], pre[200009], low[200009], cnts; vector<pair<int, int>> X[200009]; vector<int> G; void dfs(int pos, int par) { cnts++; pre[pos] = cnts; low[pos] = cnts; for (int i = 0; i < X[pos].size(); i++) { ...
[["-", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["+", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13]]
1
484
#include <bits/stdc++.h> using namespace std; #define int long long // <-----!!!!!!!!!!!!!!!!!!! #define rep(i, n) for (int i = 0; i < (n); i++) #define rep2(i, a, b) for (int i = (a); i < (b); i++) #define rrep(i, n) for (int i = (n)-1; i >= 0; i--) #define rrep2(i, a, b) for (int i = (b)-1; i >= (a); i--) #define al...
#include <bits/stdc++.h> using namespace std; #define int long long // <-----!!!!!!!!!!!!!!!!!!! #define rep(i, n) for (int i = 0; i < (n); i++) #define rep2(i, a, b) for (int i = (a); i < (b); i++) #define rrep(i, n) for (int i = (n)-1; i >= 0; i--) #define rrep2(i, a, b) for (int i = (b)-1; i >= (a); i--) #define al...
[["-", 36, 36, 36, 36, 0, 30, 0, 112, 51, 59], ["+", 36, 36, 36, 36, 0, 30, 0, 112, 51, 59]]
1
967
def solve(): N, M = map(int, input().split()) edges = [[] for _ in [0]*N] r_edges = [[] for _ in [0]*N] for _ in [0]*M: a, b = map(int, input().split()) edges[a].append(b) r_edges[b].append(a) c = get_strongly_connected_components(edges, r_edges) print(c) group = [0]...
def solve(): N, M = map(int, input().split()) edges = [[] for _ in [0]*N] r_edges = [[] for _ in [0]*N] for _ in [0]*M: a, b = map(int, input().split()) edges[a].append(b) r_edges[b].append(a) c = get_strongly_connected_components(edges, r_edges) group = [0]*N ...
[["-", 0, 14, 8, 196, 0, 1, 0, 652, 63, 22], ["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 24], ["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 22], ["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 25]]
5
396
def solve(): N, M = map(int, input().split()) edges = [[] for _ in [0]*N] r_edges = [[] for _ in [0]*N] for _ in [0]*M: a, b = map(int, input().split()) edges[a].append(b) r_edges[b].append(a) c = kosaraju(edges, r_edges) group = [0]*N for i in range(len(c)): ...
def solve(): N, M = map(int, input().split()) edges = [[] for _ in [0]*N] r_edges = [[] for _ in [0]*N] for _ in [0]*M: a, b = map(int, input().split()) edges[a].append(b) r_edges[b].append(a) c = kosaraju(edges, r_edges) group = [0]*N for i in range(len(c)): ...
[["-", 12, 668, 0, 678, 0, 666, 0, 206, 51, 22], ["+", 12, 668, 0, 678, 0, 666, 0, 206, 51, 22]]
5
406
from collections import defaultdict sys.setrecursionlimit(100000) def counter(): cnt = 0 while True: yield cnt cnt += 1 def dfs(here, visited, track, count, connect): visited |= {here} for c in connect[here]: if c not in visited: dfs(c, visited, track, count, connec...
from collections import defaultdict import sys sys.setrecursionlimit(100000) def counter(): cnt = 0 while True: yield cnt cnt += 1 def dfs(here, visited, track, count, connect): visited |= {here} for c in connect[here]: if c not in visited: dfs(c, visited, track, co...
[["+", 36, 36, 36, 36, 0, 656, 0, 596, 0, 487], ["+", 36, 36, 0, 656, 0, 596, 141, 673, 0, 22]]
5
395
#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...
[["-", 0, 14, 49, 53, 54, 55, 0, 56, 39, 78], ["+", 0, 14, 49, 53, 54, 55, 0, 56, 39, 78]]
1
546
#include <bits/stdc++.h> using namespace std; #define rep(i, x, y) for (int i = (x); i < (y); ++i) #define debug(x) #x << "=" << (x) #ifdef DEBUG #define _GLIBCXX_DEBUG #define show(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl #else #define show(x) #endif typedef long long int ll; typedef pair<...
#include <bits/stdc++.h> using namespace std; #define rep(i, x, y) for (int i = (x); i < (y); ++i) #define debug(x) #x << "=" << (x) #ifdef DEBUG #define _GLIBCXX_DEBUG #define show(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl #else #define show(x) #endif typedef long long int ll; typedef pair<...
[["+", 31, 16, 12, 2, 3, 4, 0, 91, 17, 111]]
1
506
#include <algorithm> #include <cctype> #include <cfloat> #include <climits> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <deque> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <st...
#include <algorithm> #include <cctype> #include <cfloat> #include <climits> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <deque> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <st...
[["-", 8, 9, 0, 7, 10, 43, 49, 50, 49, 22], ["+", 8, 9, 0, 7, 10, 43, 49, 50, 49, 22], ["-", 0, 52, 8, 9, 0, 7, 15, 16, 31, 22], ["+", 0, 52, 8, 9, 0, 7, 15, 16, 31, 22], ["-", 0, 52, 8, 9, 0, 7, 26, 27, 28, 22], ["+", 0, 52, 8, 9, 0, 7, 26, 27, 28, 22], ["-", 0, 43, 49, 50, 51, 69, 341, 342, 0, 22], ["+", 0, 43, 49, 5...
1
273
#include <functional> #include <iostream> #include <vector> using namespace std; bool cycle_detection(vector<vector<int>> &G) { vector<bool> vis(G.size()); function<bool(int, int, bool)> rec = [&](int pos, int start, bool flag) { if (pos == start && flag) return true; if (flag) vis[pos] = true; ...
#include <functional> #include <iostream> #include <vector> using namespace std; bool cycle_detection(vector<vector<int>> &G) { vector<bool> vis(G.size()); function<bool(int, int, bool)> rec = [&](int pos, int start, bool flag) { if (pos == start && flag) return true; if (flag) vis[pos] = true; ...
[["-", 0, 57, 15, 339, 51, 2, 3, 4, 0, 13], ["-", 0, 57, 15, 339, 51, 2, 3, 4, 0, 21], ["+", 0, 57, 15, 339, 51, 2, 3, 4, 0, 21], ["+", 0, 57, 15, 339, 51, 2, 3, 4, 0, 147]]
1
261
#include <algorithm> #include <cstdio> #include <stack> #include <utility> #include <vector> using namespace std; using Weight = long long; static const Weight INF = 1LL << 57; struct Edge { size_t src, dst; Weight weight; Edge() {} Edge(size_t src, size_t dst, Weight weight = 1) : src(src), dst(dst), ...
#include <algorithm> #include <cstdio> #include <stack> #include <utility> #include <vector> using namespace std; using Weight = long long; static const Weight INF = 1LL << 57; struct Edge { size_t src, dst; Weight weight; Edge() {} Edge(size_t src, size_t dst, Weight weight = 1) : src(src), dst(dst), ...
[["-", 0, 57, 15, 339, 51, 16, 31, 118, 119, 120], ["+", 0, 57, 15, 339, 51, 16, 31, 118, 119, 120], ["-", 51, 91, 28, 69, 341, 342, 0, 118, 119, 120], ["+", 51, 91, 28, 69, 341, 342, 0, 118, 119, 120], ["-", 64, 1, 0, 2, 3, 4, 0, 118, 119, 120], ["+", 64, 1, 0, 2, 3, 4, 0, 118, 119, 120]]
1
487
#include <bits/stdc++.h> #define range(i, a, b) for (int i = (a); i < (b); i++) #define rep(i, b) for (int i = 0; i < (b); i++) #define all(a) (a).begin(), (a).end() #define show(x) cerr << #x << " = " << (x) << endl; #define debug(x) \ cerr << #x << " = "...
#include <bits/stdc++.h> #define range(i, a, b) for (int i = (a); i < (b); i++) #define rep(i, b) for (int i = 0; i < (b); i++) #define all(a) (a).begin(), (a).end() #define show(x) cerr << #x << " = " << (x) << endl; #define debug(x) \ cerr << #x << " = "...
[["-", 0, 14, 8, 9, 0, 57, 64, 37, 0, 146], ["+", 0, 14, 8, 9, 0, 57, 64, 37, 0, 147], ["-", 8, 9, 0, 57, 75, 76, 0, 37, 0, 147], ["+", 8, 9, 0, 57, 75, 76, 0, 37, 0, 146]]
1
391
#include <algorithm> #include <cmath> #include <cstdio> #include <cstring> #include <iomanip> #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) #de...
#include <algorithm> #include <cmath> #include <cstdio> #include <cstring> #include <iomanip> #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) #de...
[["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 22], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 22]]
1
523
#include <bits/stdc++.h> using namespace std; int V, E; vector<bool> visited; vector<int> depth, lowlink, pars; void dfs(vector<vector<int>> &G, int p, int u, int d) { visited[u] = true; pars[u] = p; depth[u] = lowlink[u] = d; for (auto v : G[u]) if (v != p) { if (!visited[v]) { dfs(G, u, v...
#include <bits/stdc++.h> using namespace std; int V, E; vector<bool> visited; vector<int> depth, lowlink, pars; void dfs(vector<vector<int>> &G, int p, int u, int d) { visited[u] = true; pars[u] = p; depth[u] = lowlink[u] = d; for (auto v : G[u]) if (v != p) { if (!visited[v]) { dfs(G, u, v...
[["+", 8, 9, 0, 338, 8, 1, 0, 16, 17, 151], ["+", 8, 9, 0, 338, 8, 1, 0, 16, 12, 22]]
1
404
#include <bits/stdc++.h> using namespace std; typedef pair<int, int> P; struct Bridge { int n; vector<vector<int>> G; vector<int> low, used, depth; set<pair<int, int>> ans; Bridge() {} Bridge(int sz) : n(sz), low(sz), used(sz), depth(sz), G(sz) {} void add(int a, int b) { G[a].push_back(b); G[b].p...
#include <bits/stdc++.h> using namespace std; typedef pair<int, int> P; struct Bridge { int n; vector<vector<int>> G; vector<int> low, used, depth; set<pair<int, int>> ans; Bridge() {} Bridge(int sz) : n(sz), low(sz), used(sz), depth(sz), G(sz) {} void add(int a, int b) { G[a].push_back(b); G[b].p...
[["+", 0, 16, 31, 16, 31, 16, 12, 103, 0, 104], ["+", 0, 16, 31, 16, 31, 16, 12, 103, 0, 125], ["+", 8, 9, 0, 1, 0, 16, 31, 16, 17, 151]]
1
473
#include <bits/stdc++.h> using namespace std; #ifdef _DEBUG #define _GLIBCXX_DEBUG #include "dump.hpp" #else #define dump(...) #endif //#define int long long // typedef __int128_t Int; #define DBG 1 #define rep(i, a, b) for (int i = (a); i < (b); i++) #define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--) #define lo...
#include <bits/stdc++.h> using namespace std; #ifdef _DEBUG #define _GLIBCXX_DEBUG #include "dump.hpp" #else #define dump(...) #endif //#define int long long // typedef __int128_t Int; #define DBG 1 #define rep(i, a, b) for (int i = (a); i < (b); i++) #define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--) #define lo...
[["+", 0, 14, 8, 9, 0, 338, 49, 352, 0, 67]]
1
660