problem_id
stringlengths
6
6
language
stringclasses
2 values
original_status
stringclasses
3 values
original_src
stringlengths
19
243k
changed_src
stringlengths
19
243k
change
stringclasses
3 values
i1
int64
0
8.44k
i2
int64
0
8.44k
j1
int64
0
8.44k
j2
int64
0
8.44k
error
stringclasses
270 values
stderr
stringlengths
0
226k
p03166
C++
Time Limit Exceeded
#include <bits/stdc++.h> #define ll long long int #define Fast \ ios_base::sync_with_stdio(0); \ cin.tie(0); using namespace std; int dp[1000005]; int dfs(vector<int> adj[], bool vis[], int i) { if (...
#include <bits/stdc++.h> #define ll long long int #define Fast \ ios_base::sync_with_stdio(0); \ cin.tie(0); using namespace std; int dp[1000005]; int dfs(vector<int> adj[], bool vis[], int i) { if (...
insert
21
21
21
22
TLE
p03166
C++
Runtime Error
/* created by Sanyam Singhal /*/ #include <bits/stdc++.h> using namespace std; #define pb push_back #define mp make_pair #define ll long long int #define mod 1000000007 #define w(t) \ int t; ...
/* created by Sanyam Singhal /*/ #include <bits/stdc++.h> using namespace std; #define pb push_back #define mp make_pair #define ll long long int #define mod 1000000007 #define w(t) \ int t; ...
replace
81
82
81
82
-6
terminate called after throwing an instance of 'std::bad_alloc' what(): std::bad_alloc
p03166
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; /*------- Constants---- */ #define LL long long #define Ulong unsigned long long #define REP(i, n) for (long long i = 0; i < n; i++) #define mp make_pair #define pb push_back #define all(x) (x).begin(), (x).end() #define PI acos(-1.0) #define EPS 1e-14 #define F first #def...
#include <bits/stdc++.h> using namespace std; /*------- Constants---- */ #define LL long long #define Ulong unsigned long long #define REP(i, n) for (long long i = 0; i < n; i++) #define mp make_pair #define pb push_back #define all(x) (x).begin(), (x).end() #define PI acos(-1.0) #define EPS 1e-14 #define F first #def...
replace
64
65
64
65
0
p03166
C++
Runtime Error
#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; } template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } const long long INF = 1LL << 60...
#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; } template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } const long long INF = 1LL << 60...
replace
38
39
38
39
0
p03166
C++
Time Limit Exceeded
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; using namespace std; #define TRACE(x) x #define WATCH(x) TRACE(cout << #x " = " << x << endl) #define PRINT(x) TRACE(printf(x)) #define WATCHR(a, b) ...
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; using namespace std; #define TRACE(x) x #define WATCH(x) TRACE(cout << #x " = " << x << endl) #define PRINT(x) TRACE(printf(x)) #define WATCHR(a, b) ...
replace
74
75
74
76
TLE
p03166
C++
Runtime Error
// KALAM #include <bits/stdc++.h> using namespace std; const int N = 3000 + 77; int n, m, d[N], A; vector<int> a[N]; bool M[N]; void dfs(int v) { M[v] = 1; d[v] = 1; for (int u : a[v]) { if (!M[u]) dfs(u); d[v] = max(d[v], d[u] + 1); } A = max(A, d[v]); } int main() { ios::sync_with_stdio(0)...
// KALAM #include <bits/stdc++.h> using namespace std; const int N = 100000 + 77; int n, m, d[N], A; vector<int> a[N]; bool M[N]; void dfs(int v) { M[v] = 1; d[v] = 1; for (int u : a[v]) { if (!M[u]) dfs(u); d[v] = max(d[v], d[u] + 1); } A = max(A, d[v]); } int main() { ios::sync_with_stdio(...
replace
5
6
5
6
0
p03166
C++
Time Limit Exceeded
// If there is no outward edge then ,length of longest path=0 #include <bits/stdc++.h> #define ll long long using namespace std; map<ll, list<ll>> graph; ll dp[100003]; ll solve(ll y) { if (dp[y] != -1) return dp[y]; if (graph[y].size() == 0) { return 0; } ll ans = 0; for (auto it : graph[y]) { an...
// If there is no outward edge then ,length of longest path=0 #include <bits/stdc++.h> #define ll long long using namespace std; map<ll, list<ll>> graph; ll dp[100003]; ll solve(ll y) { if (dp[y] != -1) return dp[y]; if (graph[y].size() == 0) { return 0; } ll ans = 0; for (auto it : graph[y]) { an...
replace
16
17
16
17
TLE
p03166
C++
Runtime Error
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); ++i) using namespace std; using ll = long long; using P = pair<int, int>; int main() { int n, m; cin >> n >> m; vector<vector<int>> child; vector<int> parent; rep(i, n) parent[i] = 0; int x, y; rep(i, m) { cin >> x >> y; x--; ...
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); ++i) using namespace std; using ll = long long; using P = pair<int, int>; int main() { int n, m; cin >> n >> m; vector<vector<int>> child(n); vector<int> parent(n); rep(i, n) parent[i] = 0; int x, y; rep(i, m) { cin >> x >> y; x-...
replace
9
11
9
11
-11
p03166
C++
Time Limit Exceeded
#include <algorithm> #include <cstring> #include <iostream> #include <map> #include <math.h> #include <queue> #include <set> #include <stack> #include <vector> #define pb push_back #define ll long long #define ff first #define ss second using namespace std; int n, m; vector<int> v[100001]; vector<int> sink; vector<int...
#include <algorithm> #include <cstring> #include <iostream> #include <map> #include <math.h> #include <queue> #include <set> #include <stack> #include <vector> #define pb push_back #define ll long long #define ff first #define ss second using namespace std; int n, m; vector<int> v[100001]; vector<int> sink; vector<int...
replace
48
49
48
49
TLE
p03166
C++
Time Limit Exceeded
#include <bits/stdc++.h> #define _overload3(_1, _2, _3, name, ...) name #define _rep(i, n) repi(i, 0, n) #define repi(i, a, b) for (int i = (a); i < (b); ++i) #define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__) #define ll long long #define lld long double #define ALL(x) x.begin(), x.end() #define chmax(...
#include <bits/stdc++.h> #define _overload3(_1, _2, _3, name, ...) name #define _rep(i, n) repi(i, 0, n) #define repi(i, a, b) for (int i = (a); i < (b); ++i) #define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__) #define ll long long #define lld long double #define ALL(x) x.begin(), x.end() #define chmax(...
insert
24
24
24
26
TLE
p03166
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; vector<int> dp; vector<vector<int>> e; int f(int x) { int r = 0; if (e[x].size()) for (auto p : e[x]) r = max(r, f(p) + 1); else r = 0; dp[x] = r; return r; } int main() { int n, m; scanf("%d %d", &n, &m); dp = vector<int>(n, -1); e = vect...
#include <bits/stdc++.h> using namespace std; vector<int> dp; vector<vector<int>> e; int f(int x) { if (dp[x] != -1) return dp[x]; int r = 0; if (e[x].size()) for (auto p : e[x]) r = max(r, f(p) + 1); else r = 0; dp[x] = r; return r; } int main() { int n, m; scanf("%d %d", &n, &m); ...
insert
7
7
7
9
TLE
p03166
C++
Time Limit Exceeded
#include <bits/stdc++.h> #define ll long long #define pb push_back #define pii pair<int, int> #define vi vector<int> #define vii vector<pii> #define mi map<int, int> #define mii map<pii, int> #define all(a) (a).begin(), (a).end() #define x first #define y second #define sz(x) (int)x.size() #define endl '\n' #define he...
#include <bits/stdc++.h> #define ll long long #define pb push_back #define pii pair<int, int> #define vi vector<int> #define vii vector<pii> #define mi map<int, int> #define mii map<pii, int> #define all(a) (a).begin(), (a).end() #define x first #define y second #define sz(x) (int)x.size() #define endl '\n' #define he...
insert
20
20
20
21
TLE
p03166
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; typedef long long int ll; typedef pair<int, int> PII; typedef pair<ll, ll> PLL; #define pb push_back // #all(x) (x).begin(),(x).end() // int const N = 1; int const MOD = 1e9 + 7; ll bigmod(ll a, ll b) { if (b == 0) return 1 % MOD; ll x = bigmod(a, b / 2); x = (x...
#include <bits/stdc++.h> using namespace std; typedef long long int ll; typedef pair<int, int> PII; typedef pair<ll, ll> PLL; #define pb push_back // #all(x) (x).begin(),(x).end() // int const N = 1; int const MOD = 1e9 + 7; ll bigmod(ll a, ll b) { if (b == 0) return 1 % MOD; ll x = bigmod(a, b / 2); x = (x...
replace
21
22
21
22
0
p03166
C++
Time Limit Exceeded
// Vaidik Patel(India) // DA-IICT #include <bits/stdc++.h> using namespace std; //******************************************** #include <ext/pb_ds/assoc_container.hpp> // include the associative containers or group of templates such as set, multimap, map etc. #include <ext/pb_ds/tree_policy.hpp> // include the tree_ord...
// Vaidik Patel(India) // DA-IICT #include <bits/stdc++.h> using namespace std; //******************************************** #include <ext/pb_ds/assoc_container.hpp> // include the associative containers or group of templates such as set, multimap, map etc. #include <ext/pb_ds/tree_policy.hpp> // include the tree_ord...
replace
104
106
104
107
TLE
p03166
C++
Runtime Error
///...................................*****................................................./// /// Mujahidul Islam ( mujahidulislam2923@gmail.com ) /// /// Department of Ict /// Comilla University , Bangladesh. /// ///...................................*****..............................
///...................................*****................................................./// /// Mujahidul Islam ( mujahidulislam2923@gmail.com ) /// /// Department of Ict /// Comilla University , Bangladesh. /// ///...................................*****..............................
replace
75
76
75
76
0
p03166
C++
Runtime Error
// Take care of mod becoming -ve #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; #define fro(i, s, e) for (auto i = s; i <= e; ++i) #define int long long #define ld long double #define fr(i, n) for (auto i = 0; i < n; i++) #define ff fi...
// Take care of mod becoming -ve #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; #define fro(i, s, e) for (auto i = s; i <= e; ++i) #define int long long #define ld long double #define fr(i, n) for (auto i = 0; i < n; i++) #define ff fi...
replace
121
122
121
122
0
Time : 42.689ms
p03166
C++
Time Limit Exceeded
#include <bits/stdc++.h> // #define int long long #define deb(x) cout << #x << " = " << x << "\n"; #define maxn 100005 using namespace std; int dp[maxn]; vector<int> g[maxn]; bitset<maxn> vis; int dfs(int s) { vis[s] = 1; for (int ch : g[s]) { dfs(ch); dp[s] = max(dp[s], 1 + dp[ch]); } return dp[s]; } ...
#include <bits/stdc++.h> // #define int long long #define deb(x) cout << #x << " = " << x << "\n"; #define maxn 100005 using namespace std; int dp[maxn]; vector<int> g[maxn]; bitset<maxn> vis; int dfs(int s) { vis[s] = 1; for (int ch : g[s]) { if (!vis[ch]) dfs(ch); dp[s] = max(dp[s], 1 + dp[ch]); }...
replace
11
12
11
13
TLE
p03166
C++
Runtime Error
#include <algorithm> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <iomanip> #include <iostream> #include <list> #include <map> #include <queue> #include <set> #include <sstream> #include <stack> #include <stdio.h> #include <string> #include <utility> #include <vector> using namespac...
#include <algorithm> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <iomanip> #include <iostream> #include <list> #include <map> #include <queue> #include <set> #include <sstream> #include <stack> #include <stdio.h> #include <string> #include <utility> #include <vector> using namespac...
replace
51
52
51
52
0
p03166
C++
Time Limit Exceeded
#include <algorithm> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <iomanip> #include <iostream> #include <list> #include <map> #include <queue> #include <set> #include <sstream> #include <stack> #include <stdio.h> #include <string> #include <utility> #include <vector> using namespac...
#include <algorithm> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <iomanip> #include <iostream> #include <list> #include <map> #include <queue> #include <set> #include <sstream> #include <stack> #include <stdio.h> #include <string> #include <utility> #include <vector> using namespac...
replace
45
46
45
46
TLE
p03166
C++
Runtime Error
#include <algorithm> #include <array> #include <bitset> #include <cassert> #include <cctype> #include <cfenv> #include <chrono> #include <climits> #include <cmath> #include <complex> #include <cstdint> #include <cstdio> #include <cstring> #include <deque> #include <fstream> #include <functional> #include <iomanip> #inc...
#include <algorithm> #include <array> #include <bitset> #include <cassert> #include <cctype> #include <cfenv> #include <chrono> #include <climits> #include <cmath> #include <complex> #include <cstdint> #include <cstdio> #include <cstring> #include <deque> #include <fstream> #include <functional> #include <iomanip> #inc...
replace
61
62
61
62
0
p03166
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; struct Fast { Fast() { std::cin.tie(0); ios::sync_with_stdio(false); } } fast; /* define */ #define FOR(I, X, Y) for (long long(I) = (X); (I) < (Y); (I)++) #define REP(I, X, Y) for (long long(I) = (Y)-1; (I) >= (X); (I)--) #define ALL(X) (X).begin(), (X).end() ...
#include <bits/stdc++.h> using namespace std; struct Fast { Fast() { std::cin.tie(0); ios::sync_with_stdio(false); } } fast; /* define */ #define FOR(I, X, Y) for (long long(I) = (X); (I) < (Y); (I)++) #define REP(I, X, Y) for (long long(I) = (Y)-1; (I) >= (X); (I)--) #define ALL(X) (X).begin(), (X).end() ...
replace
84
85
84
85
TLE
p03166
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; class Edge { public: long long cost; int from, to; Edge(long long c, int f, int t) { cost = c; from = f; to = t; } }; typedef vector<Edge> Edges; typedef vector<Edges> Graph; void readGraph(Graph &g, int E, bool D, bool C) { // E:NumofEdg...
#include <bits/stdc++.h> using namespace std; class Edge { public: long long cost; int from, to; Edge(long long c, int f, int t) { cost = c; from = f; to = t; } }; typedef vector<Edge> Edges; typedef vector<Edges> Graph; void readGraph(Graph &g, int E, bool D, bool C) { // E:NumofEdg...
replace
40
41
40
41
TLE
p03166
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define FOR(var, begin, end) for (int var = (begin); var < (end); var++) #define RFOR(var, begin, end) for (int var = (begin)-1; var >= (end); var--) #define REP(var, length) FOR(var, 0, length) #define RREP(var, length) RFOR(var, length, 0) #define SO...
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define FOR(var, begin, end) for (int var = (begin); var < (end); var++) #define RFOR(var, begin, end) for (int var = (begin)-1; var >= (end); var--) #define REP(var, length) FOR(var, 0, length) #define RREP(var, length) RFOR(var, length, 0) #define SO...
insert
23
23
23
24
TLE
p03166
C++
Runtime Error
#include <iostream> #include <vector> using namespace std; const long long INF = 1LL << 60; int N, M; // input vector<vector<int>> G; // graph // メモ化再帰 // int dp[100100]; int dp[30]; int rec(int v) { if (dp[v] != -1) return dp[v]; // if it's updated, use the value int res = 0; for (auto nv ...
#include <iostream> #include <vector> using namespace std; const long long INF = 1LL << 60; int N, M; // input vector<vector<int>> G; // graph // メモ化再帰 int dp[100100]; int rec(int v) { if (dp[v] != -1) return dp[v]; // if it's updated, use the value int res = 0; for (auto nv : G[v]) { r...
replace
11
13
11
12
0
p03166
C++
Runtime Error
#include <algorithm> #include <bitset> #include <cassert> #include <cctype> #include <chrono> #include <cmath> #include <cstdio> #include <cstring> #include <ctime> #include <deque> #include <functional> #include <iostream> #include <map> #include <queue> #include <random> #include <set> #include <sstream> #include <st...
#include <algorithm> #include <bitset> #include <cassert> #include <cctype> #include <chrono> #include <cmath> #include <cstdio> #include <cstring> #include <ctime> #include <deque> #include <functional> #include <iostream> #include <map> #include <queue> #include <random> #include <set> #include <sstream> #include <st...
replace
45
46
45
46
-6
terminate called after throwing an instance of 'std::length_error' what(): cannot create std::vector larger than max_size()
p03166
C++
Runtime Error
#include <bits/stdc++.h> #define ll long long int #define ii int #define jmp cout << "\n" #define vl vector<ll> #define pb push_back #define fast \ ios_base::sync_with_stdio(false); \ cin.tie(NULL); ...
#include <bits/stdc++.h> #define ll long long int #define ii int #define jmp cout << "\n" #define vl vector<ll> #define pb push_back #define fast \ ios_base::sync_with_stdio(false); \ cin.tie(NULL); ...
replace
55
59
55
59
-11
p03166
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; #define ll long long #define ff first #define ss second #define pb push_back #define pf push_front #define mp make_pair #define pu push #define pp pop_back #define in insert #define MOD 1000000007 #define endl "\n" #define sz(a) (int)((a).size()) #define all(x) (x).begin()...
#include <bits/stdc++.h> using namespace std; #define ll long long #define ff first #define ss second #define pb push_back #define pf push_front #define mp make_pair #define pu push #define pp pop_back #define in insert #define MOD 1000000007 #define endl "\n" #define sz(a) (int)((a).size()) #define all(x) (x).begin()...
replace
67
68
67
68
0
p03166
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; vector<int> dp(100001, -2); int path(vector<vector<int>> v, int n) { if (n == 0) { return -1; } if (dp[n] != -2) return dp[n]; vector<int> t; for (int i = 0; i < v[n].size(); i++) { if (dp[v[n][i]] == -2) dp[v[n][i]] = path(v, v[n][i]); t.pus...
#include <bits/stdc++.h> using namespace std; vector<int> dp(100001, -2); int path(vector<vector<int>> &v, int n) { if (n == 0) { return -1; } if (dp[n] != -2) return dp[n]; vector<int> t; for (int i = 0; i < v[n].size(); i++) { if (dp[v[n][i]] == -2) dp[v[n][i]] = path(v, v[n][i]); t.pu...
replace
3
4
3
4
TLE
p03166
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; #define watch(x) cout << (#x) << " is " << (x) << endl #define fr(i, n) for (int i = 0; i < n; i++) #define rep(i, st, en) for (int i = st; i <= en; i++) #define repn(i, st, en) for (int i = st; i >= en; i--) #define sq(a) (a * a) typedef long long ll; typedef pair<int, in...
#include <bits/stdc++.h> using namespace std; #define watch(x) cout << (#x) << " is " << (x) << endl #define fr(i, n) for (int i = 0; i < n; i++) #define rep(i, st, en) for (int i = st; i <= en; i++) #define repn(i, st, en) for (int i = st; i >= en; i--) #define sq(a) (a * a) typedef long long ll; typedef pair<int, in...
replace
21
22
21
23
TLE
p03166
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; bool vist[1000001]; int dp[1000001]; void dfs(int s, vector<vector<int>> g) { vist[s] = true; for (auto v : g[s]) { if (!vist[v]) dfs(v, g); dp[s] = max(dp[s], 1 + dp[v]); } return; } int main() { // your code goes here int n, m, x, y; cin >> n ...
#include <bits/stdc++.h> using namespace std; bool vist[1000001]; int dp[1000001]; void dfs(int s, vector<vector<int>> &g) { vist[s] = true; for (auto v : g[s]) { if (!vist[v]) dfs(v, g); dp[s] = max(dp[s], 1 + dp[v]); } return; } int main() { // your code goes here int n, m, x, y; cin >> n...
replace
5
6
5
6
TLE
p03166
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; #define maxn 5005 #define N 100000 #define inf (int)2e9 #define ll long long #define ii pair<int, int> #define FOR(i, a, b) for (int i = a; i <= b; i++) #define REP(i, a, b) for (int i = a; i >= b; i--) int n, m, run = 1; vector<int> g[maxn]; int cl[maxn], f1[maxn]; void...
#include <bits/stdc++.h> using namespace std; #define maxn 100005 #define N 100000 #define inf (int)2e9 #define ll long long #define ii pair<int, int> #define FOR(i, a, b) for (int i = a; i <= b; i++) #define REP(i, a, b) for (int i = a; i >= b; i--) int n, m, run = 1; vector<int> g[maxn]; int cl[maxn], f1[maxn]; vo...
replace
3
4
3
4
0
p03166
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; vector<int> in_degree; vector<int> vis; vector<int> dist; void dfs(vector<vector<int>> edge, int start) { vis[start] = 1; for (auto b : edge[start]) { in_degree[b]--; dist[b] = max(dist[b], dist[start] + 1); if (in_degree[b] == 0) dfs(edge, b); } }...
#include <bits/stdc++.h> using namespace std; vector<int> in_degree; vector<int> vis; vector<int> dist; void dfs(vector<vector<int>> &edge, int start) { vis[start] = 1; for (auto b : edge[start]) { in_degree[b]--; dist[b] = max(dist[b], dist[start] + 1); if (in_degree[b] == 0) dfs(edge, b); } ...
replace
6
7
6
7
TLE
p03166
C++
Time Limit Exceeded
#include <algorithm> #include <iostream> #include <limits.h> #include <map> #include <stdio.h> #include <string.h> #include <string> #include <vector> #ifndef ULLONG typedef unsigned long long ULLONG; #endif #ifndef LLONG typedef long long LLONG; #endif template <class _Ty> static _Ty tp_abs(const _Ty &a) { return ...
#include <algorithm> #include <iostream> #include <limits.h> #include <map> #include <stdio.h> #include <string.h> #include <string> #include <vector> #ifndef ULLONG typedef unsigned long long ULLONG; #endif #ifndef LLONG typedef long long LLONG; #endif template <class _Ty> static _Ty tp_abs(const _Ty &a) { return ...
replace
64
65
64
65
TLE
p03166
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; ////////////////////////////////////////////////*kedar1514*////////////////////////////////////////////////(Template ///Start)***** #define endl "\n" #define ll long long #define fo(i, n) for (i = 0; i < n; i++) #define Fo(i, n) for (i = 1; i <= n; i++) #define si(x) scanf(...
#include <bits/stdc++.h> using namespace std; ////////////////////////////////////////////////*kedar1514*////////////////////////////////////////////////(Template ///Start)***** #define endl "\n" #define ll long long #define fo(i, n) for (i = 0; i < n; i++) #define Fo(i, n) for (i = 1; i <= n; i++) #define si(x) scanf(...
delete
103
107
103
103
-11
p03166
C++
Runtime Error
#include <bits/stdc++.h> #define _overload3(_1, _2, _3, name, ...) name #define _rep(i, n) repi(i, 0, n) #define repi(i, a, b) for (ll i = ll(a); i < ll(b); ++i) #define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__) #define all(x) (x).begin(), (x).end() #define PRINT(V) cout << V << "\n" #define SORT(V) s...
#include <bits/stdc++.h> #define _overload3(_1, _2, _3, name, ...) name #define _rep(i, n) repi(i, 0, n) #define repi(i, a, b) for (ll i = ll(a); i < ll(b); ++i) #define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__) #define all(x) (x).begin(), (x).end() #define PRINT(V) cout << V << "\n" #define SORT(V) s...
replace
28
29
28
29
0
p03166
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; const int nax = 1e5 + 5; // this should be const for the below values to be initialised vector<int> edges[nax]; int indegree[nax]; int dist[nax]; bool vis[nax]; void dfs(int i) { vis[i] = true; for (int j : edges[i]) { dist[j] = max(dist[j], dist[i] + 1); d...
#include <bits/stdc++.h> using namespace std; const int nax = 1e5 + 5; // this should be const for the below values to be initialised vector<int> edges[nax]; int indegree[nax]; int dist[nax]; bool vis[nax]; void dfs(int i) { vis[i] = true; for (int j : edges[i]) { dist[j] = max(dist[j], dist[i] + 1); i...
replace
13
14
13
16
TLE
p03166
C++
Memory Limit Exceeded
#include <bits/stdc++.h> using namespace std; #pragma GCC optimize("-O3") const int maxn = 10e7; vector<bool> visited(maxn, false); vector<vector<int>> edges(maxn); vector<long long int> dp(maxn); void dfs(int u) { visited[u] = 1; for (int v : edges[u]) { if (!visited[v]) dfs(v); dp[u] = max(dp[u],...
#include <bits/stdc++.h> using namespace std; #pragma GCC optimize("-O3") const int maxn = 1 + 10e5; vector<bool> visited(maxn, false); vector<vector<int>> edges(maxn); vector<long long int> dp(maxn); void dfs(int u) { visited[u] = 1; for (int v : edges[u]) { if (!visited[v]) dfs(v); dp[u] = max(dp...
replace
3
4
3
4
MLE
p03166
C++
Time Limit Exceeded
#include <algorithm> #include <bitset> #include <cmath> #include <cstdlib> #include <ctime> #include <deque> #include <fstream> #include <functional> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #include <string> #include <vector> using namespace std; using ll ...
#include <algorithm> #include <bitset> #include <cmath> #include <cstdlib> #include <ctime> #include <deque> #include <fstream> #include <functional> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #include <string> #include <vector> using namespace std; using ll ...
replace
107
108
107
110
TLE
p03166
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; #define DEBUG 0 #define nl '\n' #if DEBUG #define trace(var) \ { cerr << "Line " << __LINE__ << ": " << #var << "=" << var << nl; } #else #define trace(var) ...
#include <bits/stdc++.h> using namespace std; #define DEBUG 0 #define nl '\n' #if DEBUG #define trace(var) \ { cerr << "Line " << __LINE__ << ": " << #var << "=" << var << nl; } #else #define trace(var) ...
replace
33
34
33
35
TLE
p03166
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; void pre() {} long long int n, m, a, b; vector<long long int> fov[100001]; long long int dp[100001]{0}; bool flag[100001]{0}; long long int dfs(long long int i) { if (flag[i]) { return dp[i]; } if (fov[i].size() == 0) { dp[i] = -1; return dp[i]; } dp[i...
#include <bits/stdc++.h> using namespace std; void pre() {} long long int n, m, a, b; vector<long long int> fov[100001]; long long int dp[100001]{0}; bool flag[100001]{0}; long long int dfs(long long int i) { if (flag[i]) { return dp[i]; } if (fov[i].size() == 0) { dp[i] = -1; return dp[i]; } flag...
insert
15
15
15
16
TLE
p03166
C++
Runtime Error
#include <algorithm> #include <iostream> #include <string> #include <vector> using namespace std; typedef long long ll; ll N, M; vector<vector<ll>> to; vector<ll> dp; // 初期値はマイナス1に設定 ll rec(ll i) { if (dp[i] != -1) { return dp[i]; } ll res = 0; // まだrec(i)がもとまっていなかったら、今から求める for (auto a : to[i]) { ...
#include <algorithm> #include <iostream> #include <string> #include <vector> using namespace std; typedef long long ll; ll N, M; vector<vector<ll>> to; vector<ll> dp; // 初期値はマイナス1に設定 ll rec(ll i) { if (dp[i] != -1) { return dp[i]; } ll res = 0; // まだrec(i)がもとまっていなかったら、今から求める for (auto a : to[i]) { ...
replace
25
26
25
26
-11
p03166
C++
Runtime Error
// srinivas #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> // #include <boost/multiprecision/cpp_int.hpp> // using namespace boost::multiprecision; using namespace __gnu_pbds; using namespace std; #define all(c) (c).begin(), (c).end() #define endl "\n" #define ff...
// srinivas #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> // #include <boost/multiprecision/cpp_int.hpp> // using namespace boost::multiprecision; using namespace __gnu_pbds; using namespace std; #define all(c) (c).begin(), (c).end() #define endl "\n" #define ff...
delete
55
59
55
55
-11
p03166
C++
Runtime Error
#include <bits/stdc++.h> #define ll long long int using namespace std; int dp[1000]; void dfs(vector<int> adj[], int vis[], int node) { if (vis[node]) return; vis[node] = 1; for (int i = 0; i < adj[node].size(); i++) { int x = adj[node][i]; if (!vis[x]) dfs(adj, vis, x); dp[node] = max(dp[n...
#include <bits/stdc++.h> #define ll long long int using namespace std; int dp[1000000]; void dfs(vector<int> adj[], int vis[], int node) { if (vis[node]) return; vis[node] = 1; for (int i = 0; i < adj[node].size(); i++) { int x = adj[node][i]; if (!vis[x]) dfs(adj, vis, x); dp[node] = max(d...
replace
3
4
3
4
0
p03166
C++
Time Limit Exceeded
#define ll long long int #include <bits/stdc++.h> // #include <fstream> using namespace std; #define ff first #define ss second #define mp make_pair #define pb push_back #define pf push_front #define vi vector<ll> #define pii pair<ll, ll> #define qi queue<ll> #define mem(a, b) memset(a, b, sizeof(a)) #define print(a) ...
#define ll long long int #include <bits/stdc++.h> // #include <fstream> using namespace std; #define ff first #define ss second #define mp make_pair #define pb push_back #define pf push_front #define vi vector<ll> #define pii pair<ll, ll> #define qi queue<ll> #define mem(a, b) memset(a, b, sizeof(a)) #define print(a) ...
replace
103
105
103
106
TLE
p03166
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; typedef unsigned long long ull; typedef long long ll; typedef long double ld; #define fastio() \ ios_base::sync_with_stdio(0); \ cin.tie(0); ...
#include <bits/stdc++.h> using namespace std; typedef unsigned long long ull; typedef long long ll; typedef long double ld; #define fastio() \ ios_base::sync_with_stdio(0); \ cin.tie(0); ...
replace
47
48
47
49
TLE
p03166
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; vector<vector<int>> to(100000); vector<int> done; vector<int> memo; int dp(int i) { if (done.at(i)) { return memo.at(i); } else { int res = 0; for (int b : to.at(i)) { res = max(res, dp(b) + 1); } return res; } } /*i=0 3 1 2 2 0 3 ...
#include <bits/stdc++.h> using namespace std; vector<vector<int>> to(100000); vector<int> done; vector<int> memo; int dp(int i) { if (done.at(i)) { return memo.at(i); } else { int res = 0; for (int b : to.at(i)) { res = max(res, dp(b) + 1); } // 当たり前やんか、一回触ったらそれをdoneに書き込まないと done.at(i)...
insert
13
13
13
16
TLE
p03166
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; unordered_map<int, list<int>> l; int dp[10001]; int lp(int src) { if (dp[src] != -1) return dp[src]; bool leaf = 1; int ans = INT_MIN; for (auto it : l[src]) { leaf = 0; ans = max(ans, lp(it)); } if (leaf == true) return dp[src] = 0; return d...
#include <bits/stdc++.h> using namespace std; unordered_map<int, list<int>> l; int dp[100001]; int lp(int src) { if (dp[src] != -1) return dp[src]; bool leaf = 1; int ans = INT_MIN; for (auto it : l[src]) { leaf = 0; ans = max(ans, lp(it)); } if (leaf == true) return dp[src] = 0; return ...
replace
4
5
4
5
0
p03166
C++
Runtime Error
#include <bits/stdc++.h> #define vi vector<int> #define vb vector<bool> #define lli long long int #define vvi vector<vector<int>> #define loop(n) for (int i = 0; i < n; i++) using namespace std; auto SpeedUp = []() { #ifndef ONLINE_JUDGE freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif ...
#include <bits/stdc++.h> #define vi vector<int> #define vb vector<bool> #define lli long long int #define vvi vector<vector<int>> #define loop(n) for (int i = 0; i < n; i++) using namespace std; auto SpeedUp = []() { #ifndef ONLINE_JUDGE freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif ...
replace
25
26
25
26
0
p03166
C++
Time Limit Exceeded
#include <bits/stdc++.h> using i64 = long long; bool used[101010]; int dp[101010]; std::deque<int> g[101010]; int dfs(int v) { if (used[v]) return dp[v]; int ret = 0; for (auto c : g[v]) { ret = std::max(ret, dfs(c) + 1); } return dp[v] = ret; } int main() { int n, m; std::cin >> n >> m; fo...
#include <bits/stdc++.h> using i64 = long long; bool used[101010]; int dp[101010]; std::deque<int> g[101010]; int dfs(int v) { if (used[v]) return dp[v]; used[v] = true; int ret = 0; for (auto c : g[v]) { ret = std::max(ret, dfs(c) + 1); } return dp[v] = ret; } int main() { int n, m; std::...
insert
10
10
10
12
TLE
p03166
C++
Runtime Error
#include <bits/stdc++.h> #define ll long long int #define pb push_back const int M = 1e9 + 7; using namespace std; int N = 1000000 + 1; void dfs(vector<int> *g, int st, bool *visited, vector<int> *ts) { visited[st] = true; for (int i = 0; i < g[st].size(); i++) { if (visited[g[st][i]] == false) { dfs(g, g...
#include <bits/stdc++.h> #define ll long long int #define pb push_back const int M = 1e9 + 7; using namespace std; int N = 1000000 + 1; void dfs(vector<int> *g, int st, bool *visited, vector<int> *ts) { visited[st] = true; for (int i = 0; i < g[st].size(); i++) { if (visited[g[st][i]] == false) { dfs(g, g...
replace
38
39
38
39
-6
terminate called after throwing an instance of 'std::out_of_range' what(): vector::_M_range_check: __n (which is 4) >= this->size() (which is 4)
p03166
C++
Time Limit Exceeded
/* quid-pro-quo: LOGIC for AC written by: codercell07 LANG: C++ 11 Problem: random */ #include <bits/stdc++.h> #define fastio \ ios::sync_with_stdio(false); \ cin.tie(NULL) #define testcas...
/* quid-pro-quo: LOGIC for AC written by: codercell07 LANG: C++ 11 Problem: random */ #include <bits/stdc++.h> #define fastio \ ios::sync_with_stdio(false); \ cin.tie(NULL) #define testcas...
insert
61
61
61
63
TLE
p03166
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; const int MOD = 1e9 + 7; const int MAXN = 101010; typedef struct def { int a, b, c; def() {} def(int a2, int b2, int c2) { a = a2; b = b2; c = c2; } bool operator<(def comp) const { if (a != comp.a) return a < comp.a; else return...
#include <bits/stdc++.h> using namespace std; const int MOD = 1e9 + 7; const int MAXN = 101010; typedef struct def { int a, b, c; def() {} def(int a2, int b2, int c2) { a = a2; b = b2; c = c2; } bool operator<(def comp) const { if (a != comp.a) return a < comp.a; else return...
replace
45
46
45
46
TLE
p03166
C++
Runtime Error
#include <bits/stdc++.h> #define LOCAL using namespace std; template <typename A, typename B> ostream &operator<<(ostream &out, const pair<A, B> &a) { out << "(" << a.first << "," << a.second << ")"; return out; } template <typename T, size_t N> ostream &operator<<(ostream &out, const array<T, N> &a) { out << "["...
#include <bits/stdc++.h> #define LOCAL using namespace std; template <typename A, typename B> ostream &operator<<(ostream &out, const pair<A, B> &a) { out << "(" << a.first << "," << a.second << ")"; return out; } template <typename T, size_t N> ostream &operator<<(ostream &out, const array<T, N> &a) { out << "["...
replace
74
76
74
76
0
p03166
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; #define make_it_fast \ ios_base::sync_with_stdio(false); \ cin.tie(NULL); \ cout.tie(NULL) #define mp m...
#include <bits/stdc++.h> using namespace std; #define make_it_fast \ ios_base::sync_with_stdio(false); \ cin.tie(NULL); \ cout.tie(NULL) #define mp m...
insert
86
86
86
90
TLE
p03166
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; #define int long long int dp[3001]; class Graph { int v; list<int> *l; public: Graph(int v) { this->v = v; l = new list<int>[v]; } void addedge(int x, int y) { l[x].push_back(y); } void printgraph() { for (int i = 0; i < v; i++) { cout << i <...
#include <bits/stdc++.h> using namespace std; #define int long long int dp[100001]; class Graph { int v; list<int> *l; public: Graph(int v) { this->v = v; l = new list<int>[v]; } void addedge(int x, int y) { l[x].push_back(y); } void printgraph() { for (int i = 0; i < v; i++) { cout << i...
replace
3
4
3
4
0
p03166
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; #define pb push_back #define m_p make_pair #define rep(i, a, b) for (int i = a; i < b; i++) #define repr(i, a, b) for (int i = a, i >= b; i--) #define sz(x) (int)x.size() #define F first #define S second #define debug(x) ...
#include <bits/stdc++.h> using namespace std; #define pb push_back #define m_p make_pair #define rep(i, a, b) for (int i = a; i < b; i++) #define repr(i, a, b) for (int i = a, i >= b; i--) #define sz(x) (int)x.size() #define F first #define S second #define debug(x) ...
insert
41
41
41
42
TLE
p03166
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; const int maxn = 100001; vector<int> G[maxn], tsort; bool vis[maxn]; int dp[maxn]; void dfs(int u) { vis[u] = 1; for (int v : G[u]) dfs(v); tsort.push_back(u); } int main() { ios_base::sync_with_stdio(0); cin.tie(0); int V, E; cin >> V >> E; while...
#include <bits/stdc++.h> using namespace std; const int maxn = 100001; vector<int> G[maxn], tsort; bool vis[maxn]; int dp[maxn]; void dfs(int u) { vis[u] = 1; for (int v : G[u]) if (!vis[v]) dfs(v); tsort.push_back(u); } int main() { ios_base::sync_with_stdio(0); cin.tie(0); int V, E; cin...
replace
14
15
14
16
TLE
p03166
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; const int MAXN = 1e2 + 5; const int MAXNN = 1e5 + 7; const int INF = 1e9 + 7; #define ll long long #define pb push_back #define endl '\n' #define fast_io \ ios_base::sync_with_stdio(false); ...
#include <bits/stdc++.h> using namespace std; const int MAXN = 1e5 + 5; const int MAXNN = 1e5 + 7; const int INF = 1e9 + 7; #define ll long long #define pb push_back #define endl '\n' #define fast_io \ ios_base::sync_with_stdio(false); ...
replace
3
4
3
4
0
p03166
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; #define endl "\n" #define fast \ ios_base::sync_with_stdio(false); \ cin.tie(0); \ cout.tie(0)...
#include <bits/stdc++.h> using namespace std; #define endl "\n" #define fast \ ios_base::sync_with_stdio(false); \ cin.tie(0); \ cout.tie(0)...
replace
18
20
18
20
0
p03166
C++
Time Limit Exceeded
#include <bits/stdc++.h> #define pb push_back #define mp make_pair #define f first #define s second #define ll long long #define endl "\n" using namespace std; #include <ext/pb_ds/assoc_container.hpp> using namespace __gnu_pbds; template <typename T> using ordered_set = tree<T, null_type, std::less<T>, rb_tree_tag, ...
#include <bits/stdc++.h> #define pb push_back #define mp make_pair #define f first #define s second #define ll long long #define endl "\n" using namespace std; #include <ext/pb_ds/assoc_container.hpp> using namespace __gnu_pbds; template <typename T> using ordered_set = tree<T, null_type, std::less<T>, rb_tree_tag, ...
replace
22
23
22
24
TLE
p03166
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; using ll = long long; constexpr int INF = 1e9; template <class T> inline void chmax(T &a, T b) { if (a < b) a = b; } template <class T> inline void chmin(T &a, T b) { if (a > b) a = b; } int dp[100010]; int deg[100010]; vector<vector<int>> G; int main() { ci...
#include <bits/stdc++.h> using namespace std; using ll = long long; constexpr int INF = 1e9; template <class T> inline void chmax(T &a, T b) { if (a < b) a = b; } template <class T> inline void chmin(T &a, T b) { if (a > b) a = b; } int dp[100010]; int deg[100010]; vector<vector<int>> G; int main() { ci...
replace
40
41
40
42
TLE
p03166
C++
Time Limit Exceeded
#pragma GCC optimize("O3") #include <bits/stdc++.h> using namespace std; typedef long long ll; // mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); int memo[100010]; vector<int> v[100010]; int sol(int pos) { if (memo[pos]) return memo[pos]; int ma = 0; for (int i : v[pos]) ma = max(ma, ...
#pragma GCC optimize("O3") #include <bits/stdc++.h> using namespace std; typedef long long ll; // mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); int memo[100010]; vector<int> v[100010]; int sol(int pos) { if (memo[pos]) return memo[pos]; int ma = 0; for (int i : v[pos]) ma = max(ma, ...
replace
13
14
13
14
TLE
p03166
C++
Time Limit Exceeded
#include <bits/stdc++.h> #define F first #define S second #define PB push_back using namespace std; typedef long long ll; ll n, m; vector<int> graph[100005]; int memo[100005]; int findpath(int node) { int maxlen = 0; for (auto x : graph[node]) { if (memo[x] != -1) maxlen = max(maxlen, 1 + memo[x]); ...
#include <bits/stdc++.h> #define F first #define S second #define PB push_back using namespace std; typedef long long ll; ll n, m; vector<int> graph[100005]; int memo[100005]; int findpath(int node) { int maxlen = 0; for (auto x : graph[node]) { if (memo[x] != -1) maxlen = max(maxlen, 1 + memo[x]); ...
replace
22
23
22
23
TLE
p03166
C++
Runtime Error
#include <iostream> #include <vector> using namespace std; // 入力 int N, M; int dp[100100]; // メモ化再帰 vector<vector<int>> G; // グラフ int rec(int v) { if (dp[v] != 0) return dp[v]; // 既に更新済み int res = 0; for (auto nv : G[v]) { res = max(res, rec(nv) + 1); } return dp[v] = res; // メモしながらリターン } i...
#include <iostream> #include <vector> using namespace std; // 入力 int N, M; int dp[100100]; // メモ化再帰 vector<vector<int>> G; // グラフ int rec(int v) { if (dp[v] != 0) return dp[v]; // 既に更新済み int res = 0; for (auto nv : G[v]) { res = max(res, rec(nv) + 1); } return dp[v] = res; // メモしながらリターン } i...
replace
23
24
23
24
0
p03166
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; int main() { int n, m; cin >> n >> m; vector<vector<int>> g(n); vector<int> deg(n, 0); for (int i = 0; i < m; i++) { int x, y; cin >> x >> y; x--, y--; g[x].push_back(y); deg[y]++; } vector<int> dp(n, 0); queue<int> q; for (int i = 0; ...
#include <bits/stdc++.h> using namespace std; int main() { int n, m; cin >> n >> m; vector<vector<int>> g(n); vector<int> deg(n, 0); for (int i = 0; i < m; i++) { int x, y; cin >> x >> y; x--, y--; g[x].push_back(y); deg[y]++; } vector<int> dp(n, 0); queue<int> q; for (int i = 0; ...
replace
26
27
26
29
TLE
p03166
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; #define int long long int dp[100001]; int solve(vector<vector<int>> v, int i) { if (dp[i] != -1) return dp[i]; int ans = 0; for (int j = 0; j < v[i].size(); j++) { ans = max(ans, solve(v, v[i][j]) + 1); } dp[i] = ans; return ans; } int32_t main() { ...
#include <bits/stdc++.h> using namespace std; #define int long long int dp[100001]; int solve(vector<vector<int>> &v, int i) { if (dp[i] != -1) return dp[i]; int ans = 0; for (int j = 0; j < v[i].size(); j++) { ans = max(ans, solve(v, v[i][j]) + 1); } dp[i] = ans; return ans; } int32_t main() {...
replace
7
8
7
8
TLE
p03166
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; int n, m, a, b; int bio[100010]; vector<int> v[100010]; int dfs(int x) { for (int i = 0; i < v[x].size(); i++) { bio[x] = max(bio[x], dfs(v[x][i]) + 1); } return bio[x]; } int main() { cin >> n >> m; for (int i = 0; i < m; i++) { cin >> a >> b; v[...
#include <bits/stdc++.h> using namespace std; int n, m, a, b; int bio[100010]; vector<int> v[100010]; int dfs(int x) { for (int i = 0; i < v[x].size(); i++) { if (bio[v[x][i]] == 0) bio[x] = max(bio[x], dfs(v[x][i]) + 1); else { bio[x] = max(bio[x], bio[v[x][i]] + 1); } } return bio[x];...
replace
9
10
9
14
TLE
p03166
C++
Time Limit Exceeded
/*@author Vipen Loka*/ #include <bits/stdc++.h> #define endl '\n' #define ff first #define ss second #define ll long long int #define vi vector<int> #define vll vector<ll> #define vvi vector<vi> #define pii pair<int, int> #define pll pair<long long, long long> #define mod 1000000007 #define inf 1000000000000000001; #de...
/*@author Vipen Loka*/ #include <bits/stdc++.h> #define endl '\n' #define ff first #define ss second #define ll long long int #define vi vector<int> #define vll vector<ll> #define vvi vector<vi> #define pii pair<int, int> #define pll pair<long long, long long> #define mod 1000000007 #define inf 1000000000000000001; #de...
replace
38
40
38
41
TLE
p03166
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; vector<int> adj[10007]; int used[100007], dp[100007], mx; void dfs(int v) { if (used[v]) return; used[v] = 1; for (auto u : adj[v]) { dfs(u); dp[v] = max(dp[v], dp[u] + 1); } } int main() { int n, m; cin >> n >> m; for (int i = 0; i < m; i++) ...
#include <bits/stdc++.h> using namespace std; vector<int> adj[100007]; int used[100007], dp[100007], mx; void dfs(int v) { if (used[v]) return; used[v] = 1; for (auto u : adj[v]) { dfs(u); dp[v] = max(dp[v], dp[u] + 1); } } int main() { int n, m; cin >> n >> m; for (int i = 0; i < m; i++)...
replace
4
5
4
5
0
p03166
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; vector<int> g[100000]; int visited[100000]; int dp[100000]; void dfs(int node) { dp[node] = 0; visited[node] = 1; for (auto child : g[node]) { if (!visited[child]) { dfs(child); } dp[node] = max(dp[node], 1 + dp[child]); } } int main() { int n, m...
#include <bits/stdc++.h> using namespace std; vector<int> g[100001]; int visited[100001]; int dp[100001]; void dfs(int node) { dp[node] = 0; visited[node] = 1; for (auto child : g[node]) { if (!visited[child]) { dfs(child); } dp[node] = max(dp[node], 1 + dp[child]); } } int main() { int n, m...
replace
2
5
2
5
0
p03166
C++
Runtime Error
#include <bits/stdc++.h> #define int long long int #define S second #define F first using namespace std; const int N = 120, M = 1e5 + 100; int dp[N], n, m, cnt[N], k[N]; pair<int, int> p[N]; vector<int> v[N], ans; queue<int> q; int32_t main() { cin >> n >> m; for (int i = 0; i < m; i++) { int aa, bb; cin...
#include <bits/stdc++.h> #define int long long int #define S second #define F first using namespace std; const int N = 2e6 + 100, M = 1e5 + 100; int dp[N], n, m, cnt[N], k[N]; pair<int, int> p[N]; vector<int> v[N], ans; queue<int> q; int32_t main() { cin >> n >> m; for (int i = 0; i < m; i++) { int aa, bb; ...
replace
7
8
7
8
0
p03166
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; vector<int> g[100005]; int dp[100005], vis[100005], mx; void dfs(int node) { vis[node] = 1; for (int a : g[node]) dfs(a), dp[node] = max(dp[a] + 1, dp[node]); mx = max(mx, dp[node]); } int main() { ios::sync_with_stdio(false); cin.tie(NULL); int n, m; ci...
#include <bits/stdc++.h> using namespace std; vector<int> g[100005]; int dp[100005], vis[100005], mx; void dfs(int node) { vis[node] = 1; for (int a : g[node]) { if (!vis[a]) dfs(a); dp[node] = max(dp[a] + 1, dp[node]); } mx = max(mx, dp[node]); } int main() { ios::sync_with_stdio(false); ci...
replace
7
9
7
12
TLE
p03166
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; using ll = long long; ll solve() { ll N, M, x, y; cin >> N >> M; vector<vector<ll>> G(N); vector<int> c_in(N); for (int i = 0; i < M; i++) { cin >> x >> y; x--, y--; G[x].push_back(y); c_in[y]++; } vector<int> h(N, -1); function<int(int, in...
#include <bits/stdc++.h> using namespace std; using ll = long long; ll solve() { ll N, M, x, y; cin >> N >> M; vector<vector<ll>> G(N); vector<int> c_in(N); for (int i = 0; i < M; i++) { cin >> x >> y; x--, y--; G[x].push_back(y); c_in[y]++; } vector<int> h(N, -1); function<int(int, in...
insert
28
28
28
29
TLE
p03166
C++
Time Limit Exceeded
#include <bits/stdc++.h> #define ll long long int using namespace std; const int maxValue = 1e5 + 5; int dfs(int i, vector<int> g[], int *maxNodes, int dist) { if (g[i].size() == 0) { maxNodes[i] = 1; } for (int j : g[i]) { maxNodes[i] = max(maxNodes[i], dfs(j, g, maxNodes, dist) + 1); } return maxNo...
#include <bits/stdc++.h> #define ll long long int using namespace std; const int maxValue = 1e5 + 5; int dfs(int i, vector<int> g[], int *maxNodes, int dist) { if (g[i].size() == 0) { maxNodes[i] = 1; } if (maxNodes[i] != 0) return maxNodes[i]; for (int j : g[i]) { maxNodes[i] = max(maxNodes[i], df...
insert
9
9
9
11
TLE
p03166
C++
Runtime Error
#include <bits/stdc++.h> #pragma GCC optimize("Ofast") #pragma GCC optimize("unroll-loops") #pragma GCC target("sse2") /* |||||||||||||||||||||||||||||||||||||||||||||||| | ||| | |||| |||| | | | | | | | | | | | | | | | | | | | | | | | | ...
#include <bits/stdc++.h> #pragma GCC optimize("Ofast") #pragma GCC optimize("unroll-loops") #pragma GCC target("sse2") /* |||||||||||||||||||||||||||||||||||||||||||||||| | ||| | |||| |||| | | | | | | | | | | | | | | | | | | | | | | | | ...
replace
91
93
91
93
-11
p03166
C++
Time Limit Exceeded
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < n; i++) #define mrep(i, j, n) for (int i = j; i < n; i++) #define reps(i, n) for (int i = 1; i <= n; i++) #define rrep(i, n) for (int i = n - 1; i >= 0; i--) #define mreps(i, j, n) for (int i = j; i <= n; i++) #define rreps(i, n) for (int i = n; i >= 1; i--...
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < n; i++) #define mrep(i, j, n) for (int i = j; i < n; i++) #define reps(i, n) for (int i = 1; i <= n; i++) #define rrep(i, n) for (int i = n - 1; i >= 0; i--) #define mreps(i, j, n) for (int i = j; i <= n; i++) #define rreps(i, n) for (int i = n; i >= 1; i--...
insert
59
59
59
61
TLE
p03166
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; using ll = long long; constexpr int N_MAX = 100000; int n, m; vector<int> graph[N_MAX]; vector<int> lp(N_MAX, -1); int dfs(int node) { int max_child_lp = -1; for (int child : graph[node]) { if (lp[child] != -1) { max_child_lp = max(max_child_lp, lp[child]...
#include <bits/stdc++.h> using namespace std; using ll = long long; constexpr int N_MAX = 100000; int n, m; vector<int> graph[N_MAX]; vector<int> lp(N_MAX, -1); int dfs(int node) { int max_child_lp = -1; for (int child : graph[node]) { if (lp[child] != -1) { max_child_lp = max(max_child_lp, lp[child]...
replace
22
23
22
23
TLE
p03166
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; vector<int> dp; int longestPath(vector<vector<int>> &G, int v) { if (dp[v] == -1) { int r = 0; for (int i = 0; i < G[v].size(); i++) { r = max(r, 1 + longestPath(G, G[v][i])); } dp[v] = r; } return dp[v]; } int main() { int N, M; cin >> N...
#include <bits/stdc++.h> using namespace std; vector<int> dp; int longestPath(vector<vector<int>> &G, int v) { if (dp[v] == -1) { int r = 0; for (int i = 0; i < G[v].size(); i++) { r = max(r, 1 + longestPath(G, G[v][i])); } dp[v] = r; } return dp[v]; } int main() { int N, M; cin >> N...
replace
24
25
24
25
0
p03166
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; int js, a[100010], to[100010]; int n, m, c, b, ans, sum, dp[100010]; vector<int> v[100010]; vector<int> vv[10010]; inline void topsort() { queue<int> q; for (int i = 1; i <= n; ++i) { if (!to[i]) q.push(i); } while (!q.empty()) { int x = q.front(); ...
#include <bits/stdc++.h> using namespace std; int js, a[100010], to[100010]; int n, m, c, b, ans, sum, dp[100010]; vector<int> v[100010]; vector<int> vv[100010]; inline void topsort() { queue<int> q; for (int i = 1; i <= n; ++i) { if (!to[i]) q.push(i); } while (!q.empty()) { int x = q.front(); ...
replace
5
6
5
6
0
p03166
C++
Runtime Error
#pragma GCC optimize( \ "Ofast") // Comment optimisations for interactive problems (use endl) #pragma GCC target("avx,avx2,fma") #pragma GCC optimization("unroll-loops") #include <bits/stdc++.h> using namespace std; #define fastio ...
#include <bits/stdc++.h> using namespace std; #define fastio \ ios::sync_with_stdio(0); \ cin.tie(0); \ cout.tie(0); ...
replace
0
4
0
1
0
p03166
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (n); ++i) #define repr(i, n) for (int i = (n - 1); i >= 0; --i) template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; } template <class T> bool chmin(T &a, const T &b) { if (b < a)...
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (n); ++i) #define repr(i, n) for (int i = (n - 1); i >= 0; --i) template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; } template <class T> bool chmin(T &a, const T &b) { if (b < a)...
replace
34
35
34
38
TLE
p03166
C++
Time Limit Exceeded
#include <algorithm> #include <iostream> #include <vector> using namespace std; typedef long long ll; vector<int> v[100005]; vector<int> dp; ll dfs(int u) { ll d = 0; if (dp[u] != -1) { return dp[u]; } for (int w : v[u]) { d = max(d, dfs(w) + 1); } return d; } int main(int argc, char *argv[])...
#include <algorithm> #include <iostream> #include <vector> using namespace std; typedef long long ll; vector<int> v[100005]; vector<int> dp; ll dfs(int u) { ll d = 0; if (dp[u] != -1) { return dp[u]; } for (int w : v[u]) { d = max(d, dfs(w) + 1); } return dp[u] = d; } int main(int argc, char ...
replace
21
22
21
22
TLE
p03166
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; int n, m; vector<vector<int>> from; vector<vector<int>> to; vector<int> start, finish; vector<int> d; int dist(int u) { if (d[u] != -1) return d[u]; int md = -1; for (int i = 0; i < from[u].size(); i++) { int v = from[u][i]; md = max(md, dist(v) + 1); ...
#include <bits/stdc++.h> using namespace std; int n, m; vector<vector<int>> from; vector<vector<int>> to; vector<int> start, finish; vector<int> d; int dist(int u) { if (d[u] != -1) return d[u]; int md = -1; for (int i = 0; i < from[u].size(); i++) { int v = from[u][i]; md = max(md, dist(v) + 1); ...
insert
19
19
19
20
TLE
p03166
Python
Runtime Error
def main(): n, m = map(int, input().split()) graph = [[] for _ in range(n)] for _ in range(m): x, y = map(lambda x: int(x) - 1, input().split()) graph[x].append(y) dp = [-1 for _ in range(n)] # dp[i] := iから距離が最も長い頂点への距離 def solve(v): if dp[v] != -1: return dp...
from sys import setrecursionlimit setrecursionlimit(10**7) def main(): n, m = map(int, input().split()) graph = [[] for _ in range(n)] for _ in range(m): x, y = map(lambda x: int(x) - 1, input().split()) graph[x].append(y) dp = [-1 for _ in range(n)] # dp[i] := iから距離が最も長い頂点への距離 ...
insert
0
0
0
5
0
p03166
Python
Runtime Error
N, M = map(int, input().split()) G = [[] for i in range(N)] for i in range(M): x, y = map(int, input().split()) x, y = x - 1, y - 1 G[x].append(y) def topological_sort(g): topological_list = [] visited = set() def dfs(n): for e in g[n]: if e not in visited: ...
import sys sys.setrecursionlimit(10**9) N, M = map(int, input().split()) G = [[] for i in range(N)] for i in range(M): x, y = map(int, input().split()) x, y = x - 1, y - 1 G[x].append(y) def topological_sort(g): topological_list = [] visited = set() def dfs(n): for e in g[n]: ...
insert
0
0
0
4
0
p03166
Python
Runtime Error
import sys from functools import lru_cache sys.setrecursionlimit(100000) @lru_cache(maxsize=None) def dfs(v): lv = links[v] return max(map(dfs, lv)) + 1 if lv else 0 n, m = map(int, input().split()) sss = set(range(n)) links = [set() for _ in range(n)] for line in sys.stdin.readlines(): x, y = map(int,...
import sys from functools import lru_cache sys.setrecursionlimit(1000000) @lru_cache(maxsize=None) def dfs(v): lv = links[v] return max(map(dfs, lv)) + 1 if lv else 0 n, m = map(int, input().split()) sss = set(range(n)) links = [set() for _ in range(n)] for line in sys.stdin.readlines(): x, y = map(int...
replace
3
4
3
4
0
p03166
Python
Runtime Error
def get_kyori(i): if kos[i] == []: kyori[i] = 0 return 0 if kyori[i] > -1: return kyori[i] re = 0 for ko in kos[i]: new = get_kyori(ko) + 1 if re < new: re = new kyori[i] = re return re n, m = map(int, input().split()) kos = [[] for _ in rang...
import sys input = sys.stdin.readline sys.setrecursionlimit(10**6) def get_kyori(i): if kos[i] == []: kyori[i] = 0 return 0 if kyori[i] > -1: return kyori[i] re = 0 for ko in kos[i]: new = get_kyori(ko) + 1 if re < new: re = new kyori[i] = re ...
insert
0
0
0
6
0
p03166
Python
Runtime Error
N, M = map(int, input().split()) graph = [dict() for _ in range(N)] for i in range(M): x, y = map(int, input().split()) graph[y - 1][x - 1] = 1 dp = [0 for _ in range(N)] def dfs(u): if dp[u] != 0: return dp[u] max_dis = 0 for f in graph[u].keys(): if max_dis < dfs(f) + 1: ...
import sys sys.setrecursionlimit(10**8) N, M = map(int, input().split()) graph = [dict() for _ in range(N)] for i in range(M): x, y = map(int, input().split()) graph[y - 1][x - 1] = 1 dp = [0 for _ in range(N)] def dfs(u): if dp[u] != 0: return dp[u] max_dis = 0 for f in graph[u].keys(...
insert
0
0
0
4
0
p03166
Python
Runtime Error
def dfs(v): if d[v] != -1: return d[v] res = -1 for u in e[v]: res = max(res, dfs(u)) res += 1 d[v] = res return res n, m = map(int, input().split()) e = tuple(set() for _ in range(n)) for _ in range(m): x, y = map(int, input().split()) x -= 1 y -= 1 e[x].add(y)...
import sys sys.setrecursionlimit(10**7) def dfs(v): if d[v] != -1: return d[v] res = -1 for u in e[v]: res = max(res, dfs(u)) res += 1 d[v] = res return res n, m = map(int, input().split()) e = tuple(set() for _ in range(n)) for _ in range(m): x, y = map(int, input().spl...
insert
0
0
0
5
0
p03166
Python
Runtime Error
import sys def input(): return sys.stdin.readline().strip() def dfs(v): if dp[v] >= 0: return dp[v] res = 0 for nv in g[v]: res = max(res, dfs(nv) + 1) dp[v] = res return res n, m = map(int, input().split()) g = {i: set() for i in range(1, n + 1)} for _ in range(m): x, ...
import sys sys.setrecursionlimit(10**7) def input(): return sys.stdin.readline().strip() def dfs(v): if dp[v] >= 0: return dp[v] res = 0 for nv in g[v]: res = max(res, dfs(nv) + 1) dp[v] = res return res n, m = map(int, input().split()) g = {i: set() for i in range(1, n + ...
insert
1
1
1
3
0
p03166
C++
Runtime Error
/*********************** * Author: xuziyuan * ***********************/ #include <bits/stdc++.h> #define rt0 return 0 #define rep(i, n) for (int i = 0; i < n; i++) #define repn(i, n) for (int i = 1; i <= n; i++) #define replet(c) for (char c = 'a'; c <= 'z'; c++) #define LL long long #define pii pair<int, int> #...
/*********************** * Author: xuziyuan * ***********************/ #include <bits/stdc++.h> #define rt0 return 0 #define rep(i, n) for (int i = 0; i < n; i++) #define repn(i, n) for (int i = 1; i <= n; i++) #define replet(c) for (char c = 'a'; c <= 'z'; c++) #define LL long long #define pii pair<int, int> #...
replace
24
25
24
25
0
p03166
C++
Time Limit Exceeded
#include <algorithm> #include <iostream> #include <queue> #include <vector> using namespace std; using ll = long long; int f(vector<int> &dp, vector<vector<int>> graph, int vertex) { if (dp[vertex] != -1) return dp[vertex]; if (graph[vertex].size() == 0) { dp[vertex] = 0; return 0; } for (int i = 0...
#include <algorithm> #include <iostream> #include <queue> #include <vector> using namespace std; using ll = long long; int f(vector<int> &dp, vector<vector<int>> &graph, int vertex) { if (dp[vertex] != -1) return dp[vertex]; if (graph[vertex].size() == 0) { dp[vertex] = 0; return 0; } for (int i = ...
replace
7
8
7
8
TLE
p03166
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<int64_t, int64_t> pll; typedef vector<int64_t> vl; int dx[] = {1, -1, 0, 0, 1, -1, 1, -1}; int dy[] = {0, 0, 1, -1, 1, -1, -1, 1}; const long double PI = acos(-1); #define INF (2147483647) #define mod (100000000...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<int64_t, int64_t> pll; typedef vector<int64_t> vl; int dx[] = {1, -1, 0, 0, 1, -1, 1, -1}; int dy[] = {0, 0, 1, -1, 1, -1, -1, 1}; const long double PI = acos(-1); #define INF (2147483647) #define mod (100000000...
insert
35
35
35
36
TLE
p03166
C++
Time Limit Exceeded
#include <bits/stdc++.h> #include <iostream> using namespace std; using ll = long long; int n, m; vector<vector<int>> adj; vector<int> in_dig, s_path; queue<int> Q; void bfs() { while (!Q.empty()) { auto node = Q.front(); Q.pop(); for (auto child : adj[node]) { s_path[child] = max(s_path[child], ...
#include <bits/stdc++.h> #include <iostream> using namespace std; using ll = long long; int n, m; vector<vector<int>> adj; vector<int> in_dig, s_path; queue<int> Q; void bfs() { while (!Q.empty()) { auto node = Q.front(); Q.pop(); for (auto child : adj[node]) { s_path[child] = max(s_path[child], ...
replace
17
21
17
21
TLE
p03166
C++
Time Limit Exceeded
#include <bits/stdc++.h> #define REP(i, n) for (int i = 0; i < n; ++i) #define FOR(i, a, b) for (int i = a; i <= b; ++i) #define FORD(i, b, a) for (int i = b; i >= a; --i) #define sz(v) ((int)v.size()) #define all(v) v.begin(), v.end() #define uni(v) v.erase(unique(all(v)), v.end()) using namespace std; const int m...
#include <bits/stdc++.h> #define REP(i, n) for (int i = 0; i < n; ++i) #define FOR(i, a, b) for (int i = a; i <= b; ++i) #define FORD(i, b, a) for (int i = b; i >= a; --i) #define sz(v) ((int)v.size()) #define all(v) v.begin(), v.end() #define uni(v) v.erase(unique(all(v)), v.end()) using namespace std; const int m...
replace
20
21
20
22
TLE
p03166
C++
Runtime Error
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> // Common file #include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update using namespace std; using namespace __gnu_pbds; typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> o...
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> // Common file #include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update using namespace std; using namespace __gnu_pbds; typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> o...
replace
14
15
14
15
0
p03166
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; } template <class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); } template <class T> inline T sqr(T x) { return x * x; } typedef vector<int> V...
#include <bits/stdc++.h> using namespace std; inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; } template <class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); } template <class T> inline T sqr(T x) { return x * x; } typedef vector<int> V...
replace
72
73
72
73
TLE
p03166
C++
Time Limit Exceeded
#include <bits/stdc++.h> using vi = std::vector<int>; template <class X, class Y> X &remax(X &x, Y y) { return x = (y > x) ? y : x; } const int NMAX = 100100; int nV, nE; vi next[NMAX]; int cnt[NMAX]; int dfs(int x) { for (int y : next[x]) { remax(cnt[x], dfs(y) + 1); } remax(cnt[x], 0); return cnt[x]; } in...
#include <bits/stdc++.h> using vi = std::vector<int>; template <class X, class Y> X &remax(X &x, Y y) { return x = (y > x) ? y : x; } const int NMAX = 100100; int nV, nE; vi next[NMAX]; int cnt[NMAX]; int dfs(int x) { if (cnt[x] != -1) { return cnt[x]; } for (int y : next[x]) { remax(cnt[x], dfs(y) + 1); ...
insert
8
8
8
11
TLE
p03166
C++
Runtime Error
#include <algorithm> //swap function is here #include <bits/stdc++.h> #include <cassert> #include <climits> #include <cstdlib> #include <cstring> #include <fstream> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <sstream> // istringstream buffer(myString); #include <stack> #include <vec...
#include <algorithm> //swap function is here #include <bits/stdc++.h> #include <cassert> #include <climits> #include <cstdlib> #include <cstring> #include <fstream> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <sstream> // istringstream buffer(myString); #include <stack> #include <vec...
delete
148
154
148
148
-11
p03166
C++
Time Limit Exceeded
/* * じょえチャンネル * 高評価・チャンネル登録よろしくおねがいします! * https://www.youtube.com/channel/UCRXsI3FL_kvaVL9zoolBfbQ */ #include <algorithm> #include <bitset> #include <cassert> #include <cfloat> #include <climits> #include <cmath> #include <complex> #include <ctime> #include <deque> #include <fstream> #include <functional> #includ...
/* * じょえチャンネル * 高評価・チャンネル登録よろしくおねがいします! * https://www.youtube.com/channel/UCRXsI3FL_kvaVL9zoolBfbQ */ #include <algorithm> #include <bitset> #include <cassert> #include <cfloat> #include <climits> #include <cmath> #include <complex> #include <ctime> #include <deque> #include <fstream> #include <functional> #includ...
replace
577
578
577
578
TLE