Submission #283938

#TimeUsernameProblemLanguageResultExecution timeMemory
283938hank55663Simurgh (IOI17_simurgh)C++14
Compilation error
0 ms0 KiB
#include "simurgh.h" #define x first #define y second #define pb push_back #include<bits/stdc++.h> using namespace std; int f[505]; int f2[505]; int Find(int x){ if(f[x]==x)return x; return f[x]=Find(f[x]); } int Find2(int x){ if(f2[x]==x)return x; return f2[x]=Find2(f2[x]); } int check[250500]; int ok[250500]; std::vector<int> find_roads(int n, std::vector<int> u, std::vector<int> v) { vector<int> ans; int m=u.size(); for(int i = 0;i<n;i++)f2[i]=i; for(int i = 0;i<n;i++){ for(int j=0;j<n;j++)f[j]=j; vector<int> road; vector<int> road2; vector<int> candidate; for(int j = 0;j<m;j++){ if(Find2(u[j])!=Find2(i)&&Find2(v[j])!=Find2(i)){ if(Find(u[j])!=Find(v[j])){ road.pb(j); f[Find(u[j])]=Find(v[j]); } } else if(Find2(u[j])!=Find2(i)||Find2(v[j])!=Find2(i)){ candidate.pb(j); //printf("%d %d\n",i,j); } } map<int,vector<int> > m; for(auto it:candidate){ if(Find2(u[it])==Find2(i)){ m[Find(v[it])].pb(it); } else{ m[Find(u[it])].pb(it); } } vector<pair<int,vector<int> > > v; for(auto it:m){ v.pb(it); road2.pb(it.y[0]); } for(auto it:road){ road2.pb(it); } swap(road,road2); for(int i = 0;i<v.size();i++){ int x=-1; for(auto it:v[i].y){ if(check[it]){ x=it; break; } } if(x!=-1) road[i]=x; } int x=count_common_roads(road); // printf("!\n"); for(int j = 0;j<v.size();j++){ int need=x; int now=road[j]; vector<int> res; if(check[now]&&!ok[now])need++; for(auto it:v[j].y){ if(!check[it]){ road[j]=it; int y=count_common_roads(road); // printf("! %d\n",it); if(y>need){ res.clear(); need=y; } if(y==need){ res.push_back(it); } } } for(auto it:res){ check[it]=1,ok[it]=1,ans.pb(it);//printf("%d\n",it); f2[Find2(v[it])]=Find2(u[it]); } for(auto it:v[j].y){ if(!check[it]){ check[it]=1; ok[it]=0; } } road[j]=now; // printf("%d end\n",i); } } return ans; }

Compilation message (stderr)

simurgh.cpp: In function 'std::vector<int> find_roads(int, std::vector<int>, std::vector<int>)':
simurgh.cpp:58:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, std::vector<int> > >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   58 |   for(int i = 0;i<v.size();i++){
      |                 ~^~~~~~~~~
simurgh.cpp:71:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, std::vector<int> > >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   71 |   for(int j = 0;j<v.size();j++){
      |                 ~^~~~~~~~~
simurgh.cpp:92:19: error: cannot convert '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, std::vector<int> > >, std::pair<int, std::vector<int> > >::value_type' {aka 'std::pair<int, std::vector<int> >'} to 'int'
   92 |     f2[Find2(v[it])]=Find2(u[it]);
      |                   ^
      |                   |
      |                   __gnu_cxx::__alloc_traits<std::allocator<std::pair<int, std::vector<int> > >, std::pair<int, std::vector<int> > >::value_type {aka std::pair<int, std::vector<int> >}
simurgh.cpp:2:11: note:   initializing argument 1 of 'int Find2(int)'
    2 | #define x first
      |           ^
simurgh.cpp:13:15: note: in expansion of macro 'x'
   13 | int Find2(int x){
      |               ^