Submission #238449

#TimeUsernameProblemLanguageResultExecution timeMemory
238449vankataBirmingham (COCI20_birmingham)C++14
70 / 70
250 ms12040 KiB
#include<bits/stdc++.h> using namespace std; const int MAXN = (int )(1<<17); vector<long long >v[MAXN]; vector <long long > rig; long long n,m,q,k,used[MAXN]; void BFS() { long long i,j; queue<long long >q; for(auto nb:rig) { used[nb]=true; q.push(nb); } while(!q.empty()) { i=q.front(); q.pop(); for(auto nb:v[i]) { if(!used[nb]) { used[nb]=used[i]+1; q.push(nb); } } } } void read() { long long i,j,x,y; cin>>n>>m>>q>>k; for(i=0;i<q;i++) { cin>>x; rig.push_back(x); } for(i=0;i<m;i++) { cin>>x>>y; v[x].push_back(y); v[y].push_back(x); } } void solve() { long long i,ans=0; for(i=1;i<=n;i++) { used[i]--; ans= used[i]/k; if(used[i]%k)ans++; ans*=2; used[i]=sqrt(ans); if(used[i]*(used[i]+1)<ans)used[i]++; cout<<used[i]<<" "; }cout<<endl; } int main() { read(); BFS(); solve(); return 0; }

Compilation message (stderr)

birmingham.cpp: In function 'void BFS()':
birmingham.cpp:9:18: warning: unused variable 'j' [-Wunused-variable]
     long long  i,j;
                  ^
birmingham.cpp: In function 'void read()':
birmingham.cpp:32:18: warning: unused variable 'j' [-Wunused-variable]
     long long  i,j,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...