Submission #845167

#TimeUsernameProblemLanguageResultExecution timeMemory
845167vjudge1Birmingham (COCI20_birmingham)C++17
20 / 70
170 ms8940 KiB
#include <iostream> #include <bits/stdc++.h> using namespace std; #define MOD 1000000007 #define ll long long #define pri pair<int,int> #define prl pair<ll,ll> #define vi vector<int> #define vl vector<ll> #define vp vector<pair<int,int>> #define vpl vector<pair<ll,ll>> #define re return 0 #define sqrt sqrtl struct node { int val; vector<int> adj; int length=1e9; }; int32_t main() { int n,m,k,q;cin>>n>>m>>q>>k; queue<int> que; vector<node> nodes(n+1); for (int i = 0;i<q;i++) { int x;cin>>x; que.push(x); nodes[x].length = 0; } for (int i = 0;i<m;i++ ){ int a,b;cin>>a>>b; nodes[a].adj.push_back(b); nodes[b].adj.push_back(a); } while (que.size()) { auto f = que.front(); for (int i = 0; i<nodes[f].adj.size();i++) { if(nodes[nodes[f].adj[i]].length > nodes[f].length+1) { nodes[nodes[f].adj[i]].length = nodes[f].length+1; que.push(nodes[f].adj[i]); } } que.pop(); } for (int i = 1;i<=n;i++){ int x = nodes[i].length; int res =ceil((-1 + sqrt(1+(8*x)/k)) / 2); cout<<res<<" "; }cout<<endl; return 0; }

Compilation message (stderr)

birmingham.cpp: In function 'int32_t main()':
birmingham.cpp:37:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   37 |         for (int i = 0; i<nodes[f].adj.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...