제출 #38547

#제출 시각아이디문제언어결과실행 시간메모리
38547oTTo_22경찰관과 강도 (BOI14_coprobber)C++14
0 / 100
3 ms660 KiB
#include <bits/stdc++.h> #include "coprobber.h" #define se second #define fi first using namespace std; int n,pp; bool g[500][500],viz[500]; int start(int N, bool A[MAX_N][MAX_N]) { for (int i=0; i<MAX_N; i++) for (int j=0; j<MAX_N; j++) g[i][j]=A[i][j]; n=N; return 0; } int nextMove(int R) { int st=start(n,g); bool used[n]; int p[n]; int dis=0; for (int i=0; i<n; i++) { p[i]=-1; used[i]=0; } queue < pair < int,int > > q; q.push({st,0}); while (!q.empty()) { pair < int,int > v=q.front(); q.pop(); used[v.fi]=1; if (v.fi==R) { dis=v.se; break; } for (int i=0; i<n; i++) if (g[v.fi][i] && !used[i] && !viz[i]) { p[i]=v.fi; q.push({i,v.se+1}); } } if (dis==1) return R; if (dis==2) return st; int k=R; while (p[k]!=st) k=p[k]; viz[k]=1; return k; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...