Submission #736511

#TimeUsernameProblemLanguageResultExecution timeMemory
736511vjudge1Birmingham (COCI20_birmingham)C++14
70 / 70
104 ms34684 KiB
#include <bits/stdc++.h> using namespace std; #define endl "\n" #define ll long long #define lalala ios_base::sync_with_stdio(false);cin.tie(NULL); #define mod 1000000007 #define N 1000005 #define big 1000000000000000007 #define pb push_back vector<int> kim; int uzak[N]; vector<int> adj[N]; void bfs(){ queue<pair<int,int>> q; for(auto u:kim)q.push({u,0}); while(q.size()){ int x=q.front().first, deg=q.front().second; q.pop(); if(uzak[x]!=-1)continue; uzak[x]=deg; for(auto u:adj[x]){ if(uzak[u]!=-1)continue; q.push({u,deg+1}); } } } int main(){ lalala; memset(uzak,-1,sizeof(uzak)); int n,m,q,k;cin>>n>>m>>q>>k; for(int i=0;i<q;i++){ int a;cin>>a; kim.push_back(a); } vector<ll int> v; v.pb(1);v.pb(k+1); for(int i=2;;i++){ v.pb((i*(i+1)/2)*k+1); if((i*(i+1)/2)*k>n)break; } for(int i=0;i<m;i++){ int a,b;cin>>a>>b; adj[a].push_back(b);adj[b].push_back(a); } bfs(); int yer=0; for(int i=1;i<=n;i++){ cout<<upper_bound(v.begin(),v.end(),uzak[i])-v.begin()<<" "; } }

Compilation message (stderr)

birmingham.cpp: In function 'int main()':
birmingham.cpp:48:7: warning: unused variable 'yer' [-Wunused-variable]
   48 |   int yer=0;
      |       ^~~
#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...