Submission #584202

#TimeUsernameProblemLanguageResultExecution timeMemory
584202AGEBirmingham (COCI20_birmingham)C++14
70 / 70
209 ms42340 KiB
#include<bits/stdc++.h> #define F first #define S second #define pb push_back #define int long long using namespace std; const int N=1e6,M=2e3,mod=1e9+7; int a[12]={31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; vector<int>adj[N]; int dist[N],ans[N]; main() { queue<int>qq; int n,m,q,k; cin>>n>>m>>q>>k; vector<int>v; for(int i=0;i<q;i++){ int x; cin>>x; v.pb(x); } for(int i=0;i<m;i++){ int x,y; cin>>x>>y; adj[x].pb(y); adj[y].pb(x); } for(int i=1;i<=n;i++) dist[i]=1e18; for(int i=0;i<v.size();i++) qq.push(v[i]),dist[v[i]]=0; while(!qq.empty()){ int node=qq.front(); qq.pop(); for(auto x:adj[node]){ if(dist[x]>dist[node]+1){ dist[x]=dist[node]+1; qq.push(x); } } } ans[0]=0; int i=0; int step=1; while(i<=1e6){ int target=i+(k*step); if(target>1e6) break; int lst=i; i++; while(i<=target) ans[i]=ans[lst]+1,i++; i=target; step++; } for(int i=1;i<=n;i++) cout<<ans[dist[i]]<<" "; cout<<endl; return 0; }

Compilation message (stderr)

birmingham.cpp:11:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   11 | main()
      | ^~~~
birmingham.cpp: In function 'int main()':
birmingham.cpp:39:18: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |     for(int i=0;i<v.size();i++)
      |                 ~^~~~~~~~~
#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...