/* Sample solution to Exact Orienteering from NWERC'14. * * Algorithm: guess midpoint, use meet in the middle to reduce to * 2-sum * * Author: Per Austrin */ #include #include #include using namespace std; typedef vector vi; int N; long long L, d[20][20]; vi genpartial(int s, int M, long long t) { vi W, R; W.push_back(s); for (int i = 0; (1< L) break; } R.push_back(l); } while (next_permutation(W.begin()+1, W.end()-1)); sort(R.begin(), R.end()); return R; } bool hastour() { int all = (1<<(N-1))-1; for (int S = 1; S <= all; ++S) { int w = 0; for (int i = 0; i < N-1; ++i) if (S & (1<= 0) { if (A[a]+B[b] == L) return true; if (A[a]+B[b] < L) ++a; else if (A[a]+B[b] > L) --b; } } } return false; } int main(void) { scanf("%d%lld", &N, &L); for (int i = 0; i < N; ++i) for (int j = 0; j < N; ++j) scanf("%lld", d[i]+j); printf("%s\n", hastour() ? "possible" : "impossible"); return 0; }