Submission #1110229

# Submission time Handle Problem Language Result Execution time Memory
1110229 2024-11-09T02:53:34 Z vjudge1 Board Game (JOI24_boardgame) C++17
3 / 100
23 ms 4944 KB
#include<bits/stdc++.h>
#define INF 1e18
#define fi first
#define se second
#define FOR(i, k, n) for(ll i = k; i <= n; i++)
#define FOR1(i, k, n) for(ll i = k; i >= n; i--)
#define pb push_back
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define vi vector<int>
#define pii pair<int, int>
#define vii vector<pii>
#define ll long long
#define vll vector<ll>
#define pll pair<ll, ll>
#define re return 0
#define mii map<int, int>
#define input "BESIEGE.inp"
#define output "BESIEGE.out"
#define rf 	freopen(input, "r", stdin); freopen(output, "w", stdout)
using namespace std;
const int maxn = 5e4 + 5;
const int mod = 1e9 + 7;
const int base = 998244353;
void add(int &a, int b) 
{
	a += b; 
	if(a >= mod) a -= mod; 
	if(a < 0) a += mod; 
}
int dp[maxn], n, m, k;
bool vis[maxn];
int a[maxn];
vi adj[maxn];
void Dijkstra(int u)
{
	FOR(i, 1, n)
		dp[i] = 1e9;
	dp[u] = 0;
	priority_queue<pii, vii, greater<pii>> Q;
	Q.push({0, u});
	while(!Q.empty())
	{
		u = Q.top().se;
		Q.pop();
		if(vis[u])
			continue;
		vis[u] = 1;
		for(auto v : adj[u])
		{
			if(dp[v] > dp[u] + 1)
			{
				dp[v] = dp[u] + 1;
				Q.push({dp[v], v});
			}
		}
	}
}
int main()
{
	fastio;
	cin >> n >> m >> k;
	FOR(i, 1, m)
	{
		int u, v;
		cin >> u >> v;
		adj[u].pb(v);
		adj[v].pb(u);
	}
	string s;
	cin >> s;
	FOR(i, 1, k)
		cin >> a[i];
	Dijkstra(a[1]);
	FOR(i, 1, n)
		cout << dp[i] << "\n";
	re;
}
# Verdict Execution time Memory Grader output
1 Correct 3 ms 1648 KB Output is correct
2 Correct 15 ms 3408 KB Output is correct
3 Correct 22 ms 4944 KB Output is correct
4 Correct 20 ms 4432 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 1616 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 1760 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 1616 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 23 ms 4176 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 23 ms 4176 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 1616 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 1648 KB Output is correct
2 Correct 15 ms 3408 KB Output is correct
3 Correct 22 ms 4944 KB Output is correct
4 Correct 20 ms 4432 KB Output is correct
5 Incorrect 3 ms 1616 KB Output isn't correct
6 Halted 0 ms 0 KB -