// yukicoder: No.845 最長の切符 // 2019.6.9 bal4u #include #if 1 #define gc() getchar_unlocked() #else #define gc() getchar() #endif int in() { // 非負整数の入力 int n = 0, c = gc(); do n = 10 * n + (c & 0xf); while ((c = gc()) >= '0'); return n; } typedef struct { int a, c, p; } Q; Q q[10000]; int top; int N, M, MASK; int map[17][17]; int to[17][17], ds[17][17], hi[17]; int dfs(int s) { int i, a, b, c, p, ans = 0; top = 1, q[0].a = s, q[0].c = 0, q[0].p = 1< ans) ans = c; for (i = 0; i < hi[a]; i++) { b = to[a][i]; if (((p | ~(1< ans) ans = k; } printf("%d\n", ans); return 0; }