Submission #1110217

# Submission time Handle Problem Language Result Execution time Memory
1110217 2024-11-09T02:40:39 Z vjudge1 Board Game (JOI24_boardgame) C++17
3 / 100
20 ms 6736 KB
#include<bits/stdc++.h>
#define fi first
#define se second
#define ll long long
#define pb push_back
using namespace std;
int n,m,k,dis[100005],root[1000005];
vector<int> adj[100005];
string x;
bool vis[100005];
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
//	freopen(".INP","r",stdin);
//	freopen(".OUT","w",stdout);
	cin>>n>>m>>k;
	for(int i=1;i<=n;i++)
	{
		dis[i]=1e9;
	}
	for(int i=1;i<=m;i++)
	{
		int u,v;
		cin>>u>>v;
		adj[u].pb(v);
		adj[v].pb(u);
	}
	cin>>x;
	for(int i=1;i<=k;i++) cin>>root[i];
	
	priority_queue<pair<int,int>> q;
	q.push({0,root[1]});
	dis[root[1]]=0;
	while(!q.empty())
	{
		int a=q.top().se;q.pop();
		if(vis[a]) continue;
		vis[a]=true;
		for(auto b:adj[a])
		{
			if(dis[b]>dis[a]+1)
			{
				dis[b]=dis[a]+1;
				q.push({-dis[b],b});
			}
		}
	}
	for(int i=1;i<=n;i++)
	{
		cout<<dis[i]<<"\n";
	}
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4688 KB Output is correct
2 Correct 11 ms 5844 KB Output is correct
3 Correct 20 ms 6736 KB Output is correct
4 Correct 17 ms 6736 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 4688 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 4688 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 4688 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 19 ms 6736 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 19 ms 6736 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 4688 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4688 KB Output is correct
2 Correct 11 ms 5844 KB Output is correct
3 Correct 20 ms 6736 KB Output is correct
4 Correct 17 ms 6736 KB Output is correct
5 Incorrect 2 ms 4688 KB Output isn't correct
6 Halted 0 ms 0 KB -