This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
#define int long long
#define ll pair<int,int>
using namespace std;
const int N=5005;
int danhdau[N][N];
int mask[N];
int kq[N];
int n,m;
void bfs(int u)
{
for (int i=1;i<=n;i++) mask[i]=-1;
mask[u]=0;
queue<int> q;
q.push(u);
while (q.size())
{
int u=q.front();
q.pop();
for (int v=1;v<=n;v++)
{
if (danhdau[u][v]==1) continue;
if (mask[v]!=-1) continue;
mask[v]=mask[u]+1;
q.push(v);
}
}
for (int i=u+1;i<=n;i++)
{
if (mask[i]!=-1) kq[mask[i]]++;
}
}
signed main()
{
// freopen("kk.inp","r",stdin);
// freopen("kk.out","w",stdout);
//freopen("traffic.inp","r",stdin);
//freopen("traffic.out","w",stdout);
ios_base::sync_with_stdio(0);
cin.tie(NULL);
cout.tie(NULL);
cin >> n >> m;
for (int i=1;i<=m;i++)
{
int u,v;
cin >> u >> v;
danhdau[u][v]=1;
danhdau[v][u]=1;
}
for (int i=1;i<=n;i++)
{
bfs(i);
}
for (int i=1;i<n;i++) cout << kq[i] << " ";
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |