Submission #1016313

#TimeUsernameProblemLanguageResultExecution timeMemory
1016313hacizadalRailway (BOI17_railway)C++17
0 / 100
1028 ms36356 KiB
/* :) */ #include <bits/stdc++.h> using namespace std; #define endl '\n' #define ll long long #define pll pair<ll, ll> const int sz = 1e5+5; vector<ll>g[sz]; ll used[sz], par[sz]; map<pll, ll>mp, ans; void dfs(ll v) { used[v] = 1; for (auto u : g[v]){ if (used[u] == 0){ par[u] = v; dfs(u); } } } int main() { ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); ll n, m, k; cin>>n>>m>>k; for (ll i = 1; i<=n-1; i++){ ll u, v; cin>>u>>v; ans[{u, v}] = ans[{v, u}] = i; g[u].push_back(v); g[v].push_back(u); } for (ll i = 1; i<=m; i++){ ll f, x = i, y; cin>>f; set<pll>s; dfs(x); for (ll j = 1; j<=f; j++){ cin>>y; if (y == x) continue; while (par[y] != x){ if (y > par[y]) s.insert({par[y], y}); else s.insert({y, par[y]}); y = par[y]; } if (y > par[y]) s.insert({par[y], y}); else s.insert({y, par[y]}); } for (ll j = 1; j<=n; j++){ par[j] = used[j] = 0; } for (auto j : s){ mp[{j.first, j.second}]++; } } vector<ll>v; for (auto i : mp){ if (i.second >= k){ v.push_back(ans[{i.first.first, i.first.second}]); } //cout<<i.first.first<<' '<<i.first.second<<endl; } cout<<v.size()<<endl; for (ll i = 0; i<v.size(); i++){ cout<<v[i]<<' '; } }

Compilation message (stderr)

railway.cpp: In function 'int main()':
railway.cpp:66:21: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   66 |     for (ll i = 0; i<v.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...