#include #include #include using namespace std; int N,K; int R[5000]; long X[5000]; long dist[5001]; bool use[5000]; vector >G[5001]; bool check(vectors) { for(int i=0;i<=N;i++) { G[i].clear(); dist[i]=1e18; } for(int i=0;idist[u]+c) { dist[v]=dist[u]+c; ch=true; } } if(!ch)return true; } return false; } bool ans[5000]; void solve(vectordel) { assert(!del.empty()); if(del.size()==1) { ans[del[0]]=true; return; } vectorL,R; for(int i:del) { L.push_back(i); swap(L,R); } if(check(L))solve(L); if(check(R))solve(R); } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); cin>>N>>K; for(int i=0;i>R[i]>>X[i]; if(check(vector())) { for(int i=0;idel(N); for(int i=0;i