Submission #238422

#TimeUsernameProblemLanguageResultExecution timeMemory
238422stev2005Birmingham (COCI20_birmingham)C++17
15 / 70
138 ms8532 KiB
#include<vector> #include<queue> #include<cstdio> using namespace std; const int MAXN=(1<<17); int n,m,q1,k; int q_el[MAXN],used[MAXN]; vector<int>v[MAXN]; void read() { scanf("%d%d%d%d",&n,&m,&q1,&k); for(int i=0;i<q1;i++) scanf("%d",&q_el[i]); int x,y; for(int i=0;i<m;i++) { scanf("%d%d",&x,&y); v[x].push_back(y); v[y].push_back(x); } } void BFS() { queue<int>q; int w,nb,i,sz; for(int i=0;i<q1;i++) { q.push(q_el[i]); used[q_el[i]]=1; } while(!q.empty()) { w=q.front(); q.pop(); sz=v[w].size(); for(i=0;i<sz;i++) { nb=v[w][i]; if(!used[nb]) { used[nb]=used[w]+1; q.push(nb); } } } } void ans() { int rez; for(int i=1;i<=n;i++) { rez=used[i]-1; rez=(rez%k)?rez/k+1:rez/k; printf("%d ",rez); } } int main() { read(); BFS(); ans(); return 0; }

Compilation message (stderr)

birmingham.cpp: In function 'void read()':
birmingham.cpp:11:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d%d%d",&n,&m,&q1,&k);
  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
birmingham.cpp:13:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d",&q_el[i]);
   ~~~~~^~~~~~~~~~~~~~~
birmingham.cpp:17:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d%d",&x,&y);
   ~~~~~^~~~~~~~~~~~~~
#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...