Submission #346035

#TimeUsernameProblemLanguageResultExecution timeMemory
346035Pichon5Birmingham (COCI20_birmingham)C++17
70 / 70
211 ms11240 KiB
#include<bits/stdc++.h> #define lcm(a,b) (a/__gcd(a,b))*b #define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); #define ll long long int #define vi vector<int> #define vll vector<ll> #define pb push_back #define F first #define S second #define mp make_pair //salida rapida "\n" //DECIMALES fixed<<sp(n)<<x<<endl; //gcd(a,b)= ax + by //lCB x&-x //set.erase(it) - ersases the element present at the required index//auto it = s.find(element) //set.find(element) - iterator pointing to the given element if it is present else return pointer pointing to set.end() //set.lower_bound(element) - iterator pointing to element greater than or equal to the given element //set.upper_bound(element) - iterator pointing to element greater than the given element // | ^ //stoll string to long long using namespace std; int n,m,q,k,x,a,b; vector<vi>G; int main() { cin>>n>>m>>q>>k; queue<int>Q; vi dis(n+1,-1); while(q--){ cin>>x; Q.push(x); dis[x]=0; } G.assign(n+1,vi()); for(int i=0;i<m;i++){ cin>>a>>b; G[a].pb(b); G[b].pb(a); } while(!Q.empty()){ int u = Q.front(); Q.pop(); for(auto it : G[u]){ if(dis[it]!=-1){ continue; } dis[it]=dis[u]+1; Q.push(it); } } vll aux; ll K=k; aux.pb(k); for(int i=2;i<=n;i++){ K+=k*i; aux.pb(K); } /*for(int i=1;i<=n;i++){ cout<<dis[i]<<" . "; }*/ for(int i=1;i<=n;i++){ if(dis[i]==0){ cout<<0<<" "; continue; } int b=0,e=n-1,res; while(b<=e){ int mid=(b+e)/2; if(aux[mid]>=dis[i]){ res=mid+1; e=mid-1; }else{ b=mid+1; } } cout<<res<<" "; } return 0; }

Compilation message (stderr)

birmingham.cpp: In function 'int main()':
birmingham.cpp:76:20: warning: 'res' may be used uninitialized in this function [-Wmaybe-uninitialized]
   76 |         cout<<res<<" ";
      |                    ^~~
#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...