Submission #288503

#TimeUsernameProblemLanguageResultExecution timeMemory
288503davi_bartSimurgh (IOI17_simurgh)C++14
30 / 100
1000 ms11244 KiB
#include "simurgh.h" #include <bits/stdc++.h> using namespace std; #define ll long long #define fi first #define se second #define ld long double /* 4 6 0 1 0 2 0 3 1 2 1 3 2 3 0 1 5 */ int count_common_roads(const vector<int>& r); int ask(set<int> o){ vector<int> x; for(int y:o)x.push_back(y); return count_common_roads(x); } vector<pair<int,int> >kkk; int N; set<int> ans; set<pair<int,int> > p[600]; vector<int> grafo(int pos){ vector<int> group(N+2,-1); set<int> v; vector<bool> vis(N+2,0); queue<pair<int,int> >q; for(int i=0;i<N;i++){ if(vis[i] || i==pos)continue; q.push({i,-1}); while(!q.empty()){ auto &[pp,idx]=q.front(); q.pop(); if(vis[pp])continue; vis[pp]=1; group[pp]=i; if(idx!=-1)v.insert(idx); for(auto x:p[pp]){ if(x.first!=pos)q.push({x.first,x.second}); } } } vector<int> arc[N+2]; for(auto &[a,b]:p[pos]){ arc[group[a]].push_back(b); } vector<int> prendere; vector<bool> sist(N+10,0); for(int i=0;i<N;i++){ if(arc[i].size()==0)continue; v.insert(arc[i][0]); for(int j=0;j<arc[i].size();j++){ if(ans.find(arc[i][j])!=ans.end()){ v.erase(arc[i][0]); v.insert(arc[i][j]); swap(arc[i][0],arc[i][j]); sist[i]=1; break; } } } for(int i=0;i<N;i++){ if(arc[i].size()==0)continue; if(arc[i].size()==1){ prendere.push_back(arc[i][0]); continue; } int ma=ask(v); vector<int> qq={ma}; int prec=arc[i][0]; for(int j=1;j<arc[i].size();j++){ if(sist[i] && kkk[arc[i][j]].first<pos){ qq.push_back(-1); continue; } v.erase(prec); v.insert(arc[i][j]); prec=arc[i][j]; qq.push_back(ask(v)); ma=max(ma,qq.back()); } for(int j=0;j<arc[i].size();j++){ if(qq[j]==ma){ prendere.push_back(arc[i][j]); } } } return prendere; } std::vector<int> find_roads(int n, std::vector<int> u, std::vector<int> v){ N=n; for(int i=0;i<u.size();i++){ p[u[i]].insert({v[i],i}); p[v[i]].insert({u[i],i}); kkk.push_back({min(u[i],v[i]),max(u[i],v[i])}); } for(int i=0;i<N;i++){ auto x=grafo(i); for(int j:x)ans.insert(j); if(ans.size()==N-1)break; } vector<int> sol; for(int x:ans)sol.push_back(x); return sol; }

Compilation message (stderr)

simurgh.cpp: In function 'std::vector<int> grafo(int)':
simurgh.cpp:39:13: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   39 |       auto &[pp,idx]=q.front();
      |             ^
simurgh.cpp:52:13: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   52 |   for(auto &[a,b]:p[pos]){
      |             ^
simurgh.cpp:61:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   61 |     for(int j=0;j<arc[i].size();j++){
      |                 ~^~~~~~~~~~~~~~
simurgh.cpp:81:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   81 |     for(int j=1;j<arc[i].size();j++){
      |                 ~^~~~~~~~~~~~~~
simurgh.cpp:92:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   92 |     for(int j=0;j<arc[i].size();j++){
      |                 ~^~~~~~~~~~~~~~
simurgh.cpp: In function 'std::vector<int> find_roads(int, std::vector<int>, std::vector<int>)':
simurgh.cpp:103:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  103 |   for(int i=0;i<u.size();i++){
      |               ~^~~~~~~~~
simurgh.cpp:111:18: warning: comparison of integer expressions of different signedness: 'std::set<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
  111 |     if(ans.size()==N-1)break;
      |        ~~~~~~~~~~^~~~~
#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...