// BEGIN CUT HERE
// END CUT HERE
#line 5 "PublicTransitHard.cpp"
#include <iostream>
#include <sstream>
#include <set>
#include <map>
#include <bitset>
#include <algorithm>
#include <utility>
#include <numeric>
#include <functional>
#include <vector>
#include <queue>
#include <stack>
#include <string>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define forl(i, n) for (int i = 1; i <= int(n); i++)
#define ford(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define fore(i, l, r) for (int i = int(l); i <= int(r); i++)
#define correct(x, y, n, m) (0 <= (x) && (x) < (n) && 0 <= (y) && (y) < (m))
#define all(a) (a).begin(), (a).end()
#define sz(a) int((a).size())
#define pb(a) push_back(a)
#define mp(x, y) make_pair((x), (y))
#define ft first
#define sc second
#define x first
#define y second
#define isnan(a) false
#define isinf(a) false
using namespace std;
typedef long long li;
typedef long double ld;
typedef pair<int, int> pt;
template<typename X> inline X abs(const X& a) { return a < 0? -a: a; }
template<typename X> inline X sqr(const X& a) { return a * a; }
const int INF = int(1e9);
const li INF64 = li(1e18);
const ld EPS = 1e-9, PI = 3.1415926535897932384626433832795;
class PublicTransitHard
{
public:
int countValidTeleporters(int N, vector <int> edges, int X);
};
struct value {
pt r[3], d[2];
value() {
forn(i, 2) r[i] = d[i] = mp(0, -1);
r[2] = mp(-1, -1);
}
void addr(pt rv) {
if (r[0] < rv) r[2] = r[1], r[1] = r[0], r[0] = rv;
else if (r[1] < rv) r[2] = r[1], r[1] = rv;
else if (r[2] < rv) r[2] = rv;
}
void addd(pt rd) {
if (d[0] < rd) d[1] = d[0], d[0] = rd;
else if (d[1] < rd) d[1] = rd;
}
int getr(int i1 = -2, int i2 = -2) {
forn(i, 3) if (r[i].y != i1 && r[i].y != i2) return r[i].x;
throw;
}
int getd(int i1 = -2, int i2 = -2) {
forn(i, 2) if (d[i].y != i1 && d[i].y != i2) return d[i].x;
return 0;
}
int getdbyr(int i1) {
int ans = 0, c = 2;
forn(i, 3) if (r[i].y != i1 && c > 0) ans += r[i].x, c--;
return ans;
}
int getid(int val) {
forn(i, 3) if (r[i].x == val) return i;
throw;
}
};
const int N = 2000 + 3;
int n, x, ans;
vector<int> g[N];
value z[N][N];
void solve(int v, int p) {
value& ans = z[v][p];
if (ans.r[2].x != -1) return;
ans.r[2] = mp(0, -1);
forn(i, sz(g[v])) {
int to = g[v][i];
if (to == p) continue;
solve(to, v);
value& next = z[to][v];
ans.addd(mp(ans.r[0].x + next.r[0].x + 1, v));
ans.addr(mp(next.r[0].x + 1, to));
ans.addd(mp(next.d[0].x, to));
}
}
int w[N][N][3];
void dfs1(int rt, int j, int v, int p, int maxl, int d) {
int d1 = z[rt][n].r[j].x;
int d2 = z[v][p].r[0].x;
if (p == n && d1 > x) maxl = -1;
int cmaxl = maxl;
if (p != n && d1 + d2 + d > x) cmaxl = min(cmaxl, x + d - d1 - d2);
w[rt][v][j] = cmaxl;
forn(i, sz(g[v])) {
int to = g[v][i];
if (to == p) continue;
int nmaxl = maxl;
d2 = z[v][p].getr(to);
if (p != n && d1 + d2 + d > x) nmaxl = min(nmaxl, x + d - d1 - d2);
dfs1(rt, j, to, v, nmaxl, d + 1);
}
}
void dfs2(int rt, int v, int p, int d, int maxd, int maxl) {
int j = z[v][n].getid(z[v][n].getr(p));
int cmaxl = min(w[v][rt][j], maxl);
int cmaxd = max(maxd, z[v][p].d[0].x);
if (d <= cmaxl && cmaxd <= x) {
ans += 1 + (d == 0);
}
forn(i, sz(g[v])) {
int to = g[v][i];
if (to == p) continue;
int nmaxd = max(maxd, z[v][p].getd(v, to));
nmaxd = max(nmaxd, z[v][p].getdbyr(to));
j = z[v][n].getid(z[v][to].getr(p));
int nmaxl = min(w[v][rt][j], maxl);
dfs2(rt, to, v, d + 1, nmaxd, nmaxl);
}
}
int PublicTransitHard::countValidTeleporters(int _n, vector <int> ed, int _x) {
n = _n, x = _x, ans = 0;
forn(i, n) g[i].clear();
forn(i, sz(ed)) {
g[i + 1].pb(ed[i]);
g[ed[i]].pb(i + 1);
}
forn(i, n + 1) forn(j, n + 1) z[i][j] = value();
forn(i, n) forn(j, sz(g[i])) solve(g[i][j], i);
forn(i, n) solve(i, n);
forn(i, n) forn(j, 3) dfs1(i, j, i, n, n - 1, 0);
forn(i, n) dfs2(i, i, n, 0, 0, n - 1);
assert(ans % 2 == 0);
ans >>= 1;
return ans;
}
// BEGIN CUT HERE
namespace moj_harness {
int run_test_case(int);
void run_test(int casenum = -1, bool quiet = false) {
if (casenum != -1) {
if (run_test_case(casenum) == -1 && !quiet) {
cerr << "Illegal input! Test case " << casenum << " does not exist." << endl;
}
return;
}
int correct = 0, total = 0;
for (int i=0;; ++i) {
int x = run_test_case(i);
if (x == -1) {
if (i >= 100) break;
continue;
}
correct += x;
++total;
}
if (total == 0) {
cerr << "No test cases run." << endl;
} else if (correct < total) {
cerr << "Some cases FAILED (passed " << correct << " of " << total << ")." << endl;
} else {
cerr << "All " << total << " tests passed!" << endl;
}
}
int verify_case(int casenum, const int &expected, const int &received, clock_t elapsed) {
cerr << "Example " << casenum << "... ";
string verdict;
vector<string> info;
char buf[100];
if (elapsed > CLOCKS_PER_SEC / 200) {
sprintf(buf, "time %.2fs", elapsed * (1.0/CLOCKS_PER_SEC));
info.push_back(buf);
}
if (expected == received) {
verdict = "PASSED";
} else {
verdict = "FAILED";
}
cerr << verdict;
if (!info.empty()) {
cerr << " (";
for (int i=0; i<(int)info.size(); ++i) {
if (i > 0) cerr << ", ";
cerr << info[i];
}
cerr << ")";
}
cerr << endl;
if (verdict == "FAILED") {
cerr << " Expected: " << expected << endl;
cerr << " Received: " << received << endl;
}
return verdict == "PASSED";
}
int run_test_case(int casenum) {
switch (casenum) {
case 0: {
int N = 4;
int edges[] = {0, 1, 2};
int X = 1;
int expected__ = 1;
clock_t start__ = clock();
int received__ = PublicTransitHard().countValidTeleporters(N, vector <int>(edges, edges + (sizeof edges / sizeof edges[0])), X);
return verify_case(casenum, expected__, received__, clock()-start__);
}
case 1: {
int N = 3;
int edges[] = {0, 0};
int X = 2;
int expected__ = 6;
clock_t start__ = clock();
int received__ = PublicTransitHard().countValidTeleporters(N, vector <int>(edges, edges + (sizeof edges / sizeof edges[0])), X);
return verify_case(casenum, expected__, received__, clock()-start__);
}
case 2: {
int N = 6;
int edges[] = {0, 0, 0, 1, 1};
int X = 2;
int expected__ = 1;
clock_t start__ = clock();
int received__ = PublicTransitHard().countValidTeleporters(N, vector <int>(edges, edges + (sizeof edges / sizeof edges[0])), X);
return verify_case(casenum, expected__, received__, clock()-start__);
}
case 3: {
int N = 7;
int edges[] = {0, 1, 0, 1, 2, 4};
int X = 3;
int expected__ = 0;
clock_t start__ = clock();
int received__ = PublicTransitHard().countValidTeleporters(N, vector <int>(edges, edges + (sizeof edges / sizeof edges[0])), X);
return verify_case(casenum, expected__, received__, clock()-start__);
}
case 4: {
int N = 16;
int edges[] = {0, 1, 0, 2, 0, 0, 4, 5, 8, 9, 10, 11, 8, 4, 6};
int X = 7;
int expected__ = 31;
clock_t start__ = clock();
int received__ = PublicTransitHard().countValidTeleporters(N, vector <int>(edges, edges + (sizeof edges / sizeof edges[0])), X);
return verify_case(casenum, expected__, received__, clock()-start__);
}
case 5: {
int N = 56;
int edges[] = {0, 1, 1, 3, 1, 5, 1, 0, 8, 8, 10, 10, 12, 10, 10, 8, 16, 16, 18, 19, 19, 21, 19, 19, 24, 25, 25, 27, 18, 0, 30, 30, 30, 33, 34, 34, 34, 30, 38, 39, 39, 38, 42, 43, 0, 45, 45, 45, 48, 45, 45, 51, 45, 53, 54};
int X = 12;
int expected__ = 610;
clock_t start__ = clock();
int received__ = PublicTransitHard().countValidTeleporters(N, vector <int>(edges, edges + (sizeof edges / sizeof edges[0])), X);
return verify_case(casenum, expected__, received__, clock()-start__);
}
// custom cases
/* case 6: {
int N = ;
int edges[] = ;
int X = ;
int expected__ = ;
clock_t start__ = clock();
int received__ = PublicTransitHard().countValidTeleporters(N, vector <int>(edges, edges + (sizeof edges / sizeof edges[0])), X);
return verify_case(casenum, expected__, received__, clock()-start__);
}*/
/* case 7: {
int N = ;
int edges[] = ;
int X = ;
int expected__ = ;
clock_t start__ = clock();
int received__ = PublicTransitHard().countValidTeleporters(N, vector <int>(edges, edges + (sizeof edges / sizeof edges[0])), X);
return verify_case(casenum, expected__, received__, clock()-start__);
}*/
/* case 8: {
int N = ;
int edges[] = ;
int X = ;
int expected__ = ;
clock_t start__ = clock();
int received__ = PublicTransitHard().countValidTeleporters(N, vector <int>(edges, edges + (sizeof edges / sizeof edges[0])), X);
return verify_case(casenum, expected__, received__, clock()-start__);
}*/
default:
return -1;
}
}
}
int main(int argc, char *argv[]) {
if (argc == 1) {
moj_harness::run_test();
} else {
for (int i=1; i<argc; ++i)
moj_harness::run_test(atoi(argv[i]));
}
}
// END CUT HERE
Ly8gQkVHSU4gQ1VUIEhFUkUKCi8vIEVORCBDVVQgSEVSRQojbGluZSA1ICJQdWJsaWNUcmFuc2l0SGFyZC5jcHAiCiNpbmNsdWRlIDxpb3N0cmVhbT4KI2luY2x1ZGUgPHNzdHJlYW0+CiNpbmNsdWRlIDxzZXQ+CiNpbmNsdWRlIDxtYXA+CiNpbmNsdWRlIDxiaXRzZXQ+CiNpbmNsdWRlIDxhbGdvcml0aG0+CiNpbmNsdWRlIDx1dGlsaXR5PgojaW5jbHVkZSA8bnVtZXJpYz4KI2luY2x1ZGUgPGZ1bmN0aW9uYWw+CiNpbmNsdWRlIDx2ZWN0b3I+CiNpbmNsdWRlIDxxdWV1ZT4KI2luY2x1ZGUgPHN0YWNrPgojaW5jbHVkZSA8c3RyaW5nPgojaW5jbHVkZSA8Y3N0ZGxpYj4KI2luY2x1ZGUgPGNzdGRpbz4KI2luY2x1ZGUgPGNzdHJpbmc+CiNpbmNsdWRlIDxjdGltZT4KI2luY2x1ZGUgPGNtYXRoPgojaW5jbHVkZSA8Y2Fzc2VydD4KI2luY2x1ZGUgPGNsaW1pdHM+CgojZGVmaW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kJY2xvY2tfdCBzdGFydF9fICAgICAgICAgICA9IGNsb2NrKCk7CgkJCWludCByZWNlaXZlZF9fICAgICAgICAgICAgPSBQdWJsaWNUcmFuc2l0SGFyZCgpLmNvdW50VmFsaWRUZWxlcG9ydGVycyhOLCB2ZWN0b3IgPGludD4oZWRnZXMsIGVkZ2VzICsgKHNpemVvZiBlZGdlcyAvIHNpemVvZiBlZGdlc1swXSkpLCBYKTsKCQkJcmV0dXJuIHZlcmlmeV9jYXNlKGNhc2VudW0sIGV4cGVjdGVkX18sIHJlY2VpdmVkX18sIGNsb2NrKCktc3RhcnRfXyk7CgkJfSovCi8qICAgICAgY2FzZSA3OiB7CgkJCWludCBOICAgICAgICAgICAgICAgICAgICAgPSA7CgkJCWludCBlZGdlc1tdICAgICAgICAgICAgICAgPSA7CgkJCWludCBYICAgICAgICAgICAgICAgICAgICAgPSA7CgkJCWludCBleHBlY3RlZF9fICAgICAgICAgICAgPSA7CgoJCQljbG9ja190IHN0YXJ0X18gICAgICAgICAgID0gY2xvY2soKTsKCQkJaW50IHJlY2VpdmVkX18gICAgICAgICAgICA9IFB1YmxpY1RyYW5zaXRIYXJkKCkuY291bnRWYWxpZFRlbGVwb3J0ZXJzKE4sIHZlY3RvciA8aW50PihlZGdlcywgZWRnZXMgKyAoc2l6ZW9mIGVkZ2VzIC8gc2l6ZW9mIGVkZ2VzWzBdKSksIFgpOwoJCQlyZXR1cm4gdmVyaWZ5X2Nhc2UoY2FzZW51bSwgZXhwZWN0ZWRfXywgcmVjZWl2ZWRfXywgY2xvY2soKS1zdGFydF9fKTsKCQl9Ki8KLyogICAgICBjYXNlIDg6IHsKCQkJaW50IE4gICAgICAgICAgICAgICAgICAgICA9IDsKCQkJaW50IGVkZ2VzW10gICAgICAgICAgICAgICA9IDsKCQkJaW50IFggICAgICAgICAgICAgICAgICAgICA9IDsKCQkJaW50IGV4cGVjdGVkX18gICAgICAgICAgICA9IDsKCgkJCWNsb2NrX3Qgc3RhcnRfXyAgICAgICAgICAgPSBjbG9jaygpOwoJCQlpbnQgcmVjZWl2ZWRfXyAgICAgICAgICAgID0gUHVibGljVHJhbnNpdEhhcmQoKS5jb3VudFZhbGlkVGVsZXBvcnRlcnMoTiwgdmVjdG9yIDxpbnQ+KGVkZ2VzLCBlZGdlcyArIChzaXplb2YgZWRnZXMgLyBzaXplb2YgZWRnZXNbMF0pKSwgWCk7CgkJCXJldHVybiB2ZXJpZnlfY2FzZShjYXNlbnVtLCBleHBlY3RlZF9fLCByZWNlaXZlZF9fLCBjbG9jaygpLXN0YXJ0X18pOwoJCX0qLwoJCWRlZmF1bHQ6CgkJCXJldHVybiAtMTsKCQl9Cgl9Cn0KIAoKaW50IG1haW4oaW50IGFyZ2MsIGNoYXIgKmFyZ3ZbXSkgewoJaWYgKGFyZ2MgPT0gMSkgewoJCW1val9oYXJuZXNzOjpydW5fdGVzdCgpOwoJfSBlbHNlIHsKCQlmb3IgKGludCBpPTE7IGk8YXJnYzsgKytpKQoJCQltb2pfaGFybmVzczo6cnVuX3Rlc3QoYXRvaShhcmd2W2ldKSk7Cgl9Cn0KLy8gRU5EIENVVCBIRVJFCgo=
Main.java:4: error: illegal character: '#'
#line 5 "PublicTransitHard.cpp"
^
Main.java:4: error: class, interface, or enum expected
#line 5 "PublicTransitHard.cpp"
^
Main.java:5: error: illegal character: '#'
#include <iostream>
^
Main.java:6: error: illegal character: '#'
#include <sstream>
^
Main.java:7: error: illegal character: '#'
#include <set>
^
Main.java:8: error: illegal character: '#'
#include <map>
^
Main.java:9: error: illegal character: '#'
#include <bitset>
^
Main.java:10: error: illegal character: '#'
#include <algorithm>
^
Main.java:11: error: illegal character: '#'
#include <utility>
^
Main.java:12: error: illegal character: '#'
#include <numeric>
^
Main.java:13: error: illegal character: '#'
#include <functional>
^
Main.java:14: error: illegal character: '#'
#include <vector>
^
Main.java:15: error: illegal character: '#'
#include <queue>
^
Main.java:16: error: illegal character: '#'
#include <stack>
^
Main.java:17: error: illegal character: '#'
#include <string>
^
Main.java:18: error: illegal character: '#'
#include <cstdlib>
^
Main.java:19: error: illegal character: '#'
#include <cstdio>
^
Main.java:20: error: illegal character: '#'
#include <cstring>
^
Main.java:21: error: illegal character: '#'
#include <ctime>
^
Main.java:22: error: illegal character: '#'
#include <cmath>
^
Main.java:23: error: illegal character: '#'
#include <cassert>
^
Main.java:24: error: illegal character: '#'
#include <climits>
^
Main.java:26: error: illegal character: '#'
#define forn(i, n) for (int i = 0; i < int(n); i++)
^
Main.java:26: error: class, interface, or enum expected
#define forn(i, n) for (int i = 0; i < int(n); i++)
^
Main.java:26: error: class, interface, or enum expected
#define forn(i, n) for (int i = 0; i < int(n); i++)
^
Main.java:27: error: illegal character: '#'
#define forl(i, n) for (int i = 1; i <= int(n); i++)
^
Main.java:27: error: class, interface, or enum expected
#define forl(i, n) for (int i = 1; i <= int(n); i++)
^
Main.java:27: error: class, interface, or enum expected
#define forl(i, n) for (int i = 1; i <= int(n); i++)
^
Main.java:28: error: illegal character: '#'
#define ford(i, n) for (int i = int(n) - 1; i >= 0; i--)
^
Main.java:28: error: class, interface, or enum expected
#define ford(i, n) for (int i = int(n) - 1; i >= 0; i--)
^
Main.java:28: error: class, interface, or enum expected
#define ford(i, n) for (int i = int(n) - 1; i >= 0; i--)
^
Main.java:29: error: illegal character: '#'
#define fore(i, l, r) for (int i = int(l); i <= int(r); i++)
^
Main.java:29: error: class, interface, or enum expected
#define fore(i, l, r) for (int i = int(l); i <= int(r); i++)
^
Main.java:29: error: class, interface, or enum expected
#define fore(i, l, r) for (int i = int(l); i <= int(r); i++)
^
Main.java:30: error: illegal character: '#'
#define correct(x, y, n, m) (0 <= (x) && (x) < (n) && 0 <= (y) && (y) < (m))
^
Main.java:31: error: illegal character: '#'
#define all(a) (a).begin(), (a).end()
^
Main.java:32: error: illegal character: '#'
#define sz(a) int((a).size())
^
Main.java:33: error: illegal character: '#'
#define pb(a) push_back(a)
^
Main.java:34: error: illegal character: '#'
#define mp(x, y) make_pair((x), (y))
^
Main.java:35: error: illegal character: '#'
#define ft first
^
Main.java:36: error: illegal character: '#'
#define sc second
^
Main.java:37: error: illegal character: '#'
#define x first
^
Main.java:38: error: illegal character: '#'
#define y second
^
Main.java:39: error: illegal character: '#'
#define isnan(a) false
^
Main.java:40: error: illegal character: '#'
#define isinf(a) false
^
Main.java:44: error: class, interface, or enum expected
typedef long long li;
^
Main.java:45: error: class, interface, or enum expected
typedef long double ld;
^
Main.java:46: error: class, interface, or enum expected
typedef pair<int, int> pt;
^
Main.java:48: error: class, interface, or enum expected
template<typename X> inline X abs(const X& a) { return a < 0? -a: a; }
^
Main.java:48: error: class, interface, or enum expected
template<typename X> inline X abs(const X& a) { return a < 0? -a: a; }
^
Main.java:49: error: class, interface, or enum expected
template<typename X> inline X sqr(const X& a) { return a * a; }
^
Main.java:52: error: class, interface, or enum expected
const li INF64 = li(1e18);
^
Main.java:53: error: class, interface, or enum expected
const ld EPS = 1e-9, PI = 3.1415926535897932384626433832795;
^
Main.java:57: error: illegal start of type
public:
^
Main.java:57: error: ';' expected
public:
^
Main.java:58: error: invalid method declaration; return type required
int countValidTeleporters(int N, vector <int> edges, int X);
^
Main.java:61: error: class, interface, or enum expected
struct value {
^
Main.java:63: error: class, interface, or enum expected
value() {
^
Main.java:65: error: class, interface, or enum expected
r[2] = mp(-1, -1);
^
Main.java:66: error: class, interface, or enum expected
}
^
Main.java:69: error: class, interface, or enum expected
else if (r[1] < rv) r[2] = r[1], r[1] = rv;
^
Main.java:70: error: class, interface, or enum expected
else if (r[2] < rv) r[2] = rv;
^
Main.java:71: error: class, interface, or enum expected
}
^
Main.java:74: error: class, interface, or enum expected
else if (d[1] < rd) d[1] = rd;
^
Main.java:75: error: class, interface, or enum expected
}
^
Main.java:78: error: class, interface, or enum expected
throw;
^
Main.java:79: error: class, interface, or enum expected
}
^
Main.java:82: error: class, interface, or enum expected
return 0;
^
Main.java:83: error: class, interface, or enum expected
}
^
Main.java:86: error: class, interface, or enum expected
forn(i, 3) if (r[i].y != i1 && c > 0) ans += r[i].x, c--;
^
Main.java:87: error: class, interface, or enum expected
return ans;
^
Main.java:88: error: class, interface, or enum expected
}
^
Main.java:91: error: class, interface, or enum expected
throw;
^
Main.java:92: error: class, interface, or enum expected
}
^
Main.java:95: error: class, interface, or enum expected
const int N = 2000 + 3;
^
Main.java:97: error: class, interface, or enum expected
int n, x, ans;
^
Main.java:98: error: class, interface, or enum expected
vector<int> g[N];
^
Main.java:99: error: class, interface, or enum expected
value z[N][N];
^
Main.java:101: error: class, interface, or enum expected
void solve(int v, int p) {
^
Main.java:103: error: class, interface, or enum expected
if (ans.r[2].x != -1) return;
^
Main.java:104: error: class, interface, or enum expected
ans.r[2] = mp(0, -1);
^
Main.java:106: error: class, interface, or enum expected
forn(i, sz(g[v])) {
^
Main.java:108: error: class, interface, or enum expected
if (to == p) continue;
^
Main.java:109: error: class, interface, or enum expected
solve(to, v);
^
Main.java:110: error: class, interface, or enum expected
value& next = z[to][v];
^
Main.java:111: error: class, interface, or enum expected
ans.addd(mp(ans.r[0].x + next.r[0].x + 1, v));
^
Main.java:112: error: class, interface, or enum expected
ans.addr(mp(next.r[0].x + 1, to));
^
Main.java:113: error: class, interface, or enum expected
ans.addd(mp(next.d[0].x, to));
^
Main.java:114: error: class, interface, or enum expected
}
^
Main.java:119: error: class, interface, or enum expected
void dfs1(int rt, int j, int v, int p, int maxl, int d) {
^
Main.java:121: error: class, interface, or enum expected
int d2 = z[v][p].r[0].x;
^
Main.java:122: error: class, interface, or enum expected
if (p == n && d1 > x) maxl = -1;
^
Main.java:124: error: class, interface, or enum expected
int cmaxl = maxl;
^
Main.java:125: error: class, interface, or enum expected
if (p != n && d1 + d2 + d > x) cmaxl = min(cmaxl, x + d - d1 - d2);
^
Main.java:126: error: class, interface, or enum expected
w[rt][v][j] = cmaxl;
^
Main.java:128: error: class, interface, or enum expected
forn(i, sz(g[v])) {
^
Main.java:130: error: class, interface, or enum expected
if (to == p) continue;
^
Main.java:131: error: class, interface, or enum expected
int nmaxl = maxl;
^
Main.java:132: error: class, interface, or enum expected
d2 = z[v][p].getr(to);
^
Main.java:133: error: class, interface, or enum expected
if (p != n && d1 + d2 + d > x) nmaxl = min(nmaxl, x + d - d1 - d2);
^
100 errors