Submission #998983

#TimeUsernameProblemLanguageResultExecution timeMemory
998983vjudge1Birmingham (COCI20_birmingham)C++17
70 / 70
101 ms8276 KiB
#include <bits/stdc++.h> using namespace std; const int M = 1e5 + 1; vector<int> nei[M]; int dis[M]; bool vis[M]; void bfs(vector<int> v) { for (int i=0;i<M;i++) dis[i]=M; queue<int> q; for (int i:v) dis[i]=0,q.push(i); while (!q.empty()) { int u=q.front(); q.pop(); for (int i:nei[u]) if (!vis[i] && dis[i]>dis[u]+1) { vis[i]=true; dis[i]=dis[u]+1; q.push(i); } } } int wtf(int d) { for (int i=0;i<=d;i++) if (i*(i+1)/2>=d) return i; } int main() { int n,m,q,k; cin>>n>>m>>q>>k; vector<int> v(q); for (int i=0;i<q;i++) cin>>v[i]; for (int i=0;i<m;i++) { int u,v; cin>>u>>v; nei[u].push_back(v); nei[v].push_back(u); } bfs(v); for (int i=1;i<=n;i++) { int d=(dis[i]+k-1)/k; cout<<wtf(d)<<' '; } cout<<endl; return 0; }

Compilation message (stderr)

birmingham.cpp: In function 'int wtf(int)':
birmingham.cpp:37:1: warning: control reaches end of non-void function [-Wreturn-type]
   37 | }
      | ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...