Submission #340394

#TimeUsernameProblemLanguageResultExecution timeMemory
340394HazemBirmingham (COCI20_birmingham)C++14
70 / 70
176 ms13932 KiB
/* ID: tmhazem1 LANG: C++14 TASK: pprime */ #include <bits/stdc++.h> using namespace std; #define S second #define F first #define LL long long const int N = 2e5 + 10; LL LINF = 100000000000000000; LL INF = 1000000000; int MOD = 1e9+7; vector<int>adj[N]; queue<int>que; int dis[N],vis[N]; void bfs(){ while(!que.empty()){ int u = que.front(); que.pop(); if(vis[u])continue; vis[u] = 1; for(auto x:adj[u]) dis[x] = min(dis[x],dis[u]+1),que.push(x); } } int main() { //freopen("out.txt","w",stdout); int n,m,k,q; scanf("%d%d%d%d",&n,&m,&q,&k); for(int i=1;i<=n;i++) dis[i] = INF; for(int i=1;i<=q;i++){ int x;cin>>x; dis[x] = 0; que.push(x); } for(int i=1;i<=m;i++){ int u,v; scanf("%d%d",&u,&v); adj[u].push_back(v); adj[v].push_back(u); } bfs(); for(int i=1;i<=n;i++){ int cur = 0; for(int j=0;;j++) if(cur>=dis[i]){ printf("%d ",j); break; } else cur += k*(j+1); } }

Compilation message (stderr)

birmingham.cpp: In function 'int main()':
birmingham.cpp:43:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   43 |     scanf("%d%d%d%d",&n,&m,&q,&k);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
birmingham.cpp:56:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   56 |         scanf("%d%d",&u,&v);
      |         ~~~~~^~~~~~~~~~~~~~
#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...