Submission #1124227

#TimeUsernameProblemLanguageResultExecution timeMemory
1124227tuannmBirmingham (COCI20_birmingham)C++20
70 / 70
96 ms7876 KiB
#include<bits/stdc++.h> #define ii pair<int, int> #define ll pair<long long, long long> #define fi first #define se second #define pb push_back using namespace std; const int mod[2] = {1000000007, 998244353}; const int N = 1e5 + 1; const string NAME = "rumor"; int n, m, q, k, d[N]; vector<int> adj[N]; queue<int> que; void inp(){ cin >> n >> m >> q >> k; for(int i = 1; i <= n; ++i) d[i] = -1; for(int i = 1; i <= q; ++i){ int u; cin >> u; d[u] = 0; que.push(u); } for(int i = 1; i <= m; ++i){ int u, v; cin >> u >> v; adj[u].pb(v); adj[v].pb(u); } } void solve(){ while(!que.empty()){ int u = que.front(); que.pop(); for(int v : adj[u]) if(d[v] == -1) d[v] = d[u] + 1, que.push(v); } for(int i = 1; i <= n; ++i){ if(!d[i]){ cout << "0 "; continue; } int l = 1, r = n, ans = n; while(l <= r){ int mid = l + r >> 1; if(1LL * mid * (mid + 1) * k / 2 >= d[i]) ans = mid, r = mid - 1; else l = mid + 1; } cout << ans << " "; } } int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); if(fopen((NAME + ".inp").c_str(), "r")){ freopen((NAME + ".inp").c_str(), "r", stdin); freopen((NAME + ".out").c_str(), "w", stdout); } inp(); solve(); }

Compilation message (stderr)

birmingham.cpp: In function 'int main()':
birmingham.cpp:72:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   72 |         freopen((NAME + ".inp").c_str(), "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
birmingham.cpp:73:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   73 |         freopen((NAME + ".out").c_str(), "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#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...