Submission #728584

#TimeUsernameProblemLanguageResultExecution timeMemory
728584groguThousands Islands (IOI22_islands)C++17
Compilation error
0 ms0 KiB
#include "islands.h" #include <iostream> #include <vector> #include <variant> #include <set> #define dbg(x) cerr<<#x<<": "<<x<<endl #define ll int #define pll pair<ll,ll> #define pb push_back #define popb pop_back using namespace std; #define maxn 405 ll n,m; vector<ll> g[maxn]; ll id[maxn][maxn]; set<pll> sss; vector<ll> gen(vector<ll> v){ vector<ll> ans; for(ll i = 0;i<=v.size()/2-1;i++) ans.pb(v[i]); for(ll i = v.size()-1;i>=v.size()/2;i--) ans.pb(v[i]); for(ll i = v.size()/2 - 1;i>=0;i--) ans.pb(v[i]); for(ll i = v.size()/2;i<=v.size()-1;i++) ans.pb(v[i]); return ans; } bool vis[maxn]; vector<ll> cur; bool naso = 0; vector<ll> cyc; void dfs1(ll u,ll p){ vis[u] = 1; cur.pb(u); for(ll s : g[u]){ if(s==p) continue; if(vis[s]){ while(cur.size()){ cyc.pb(cur.back()); if(cur.back()==s) break; cur.popb(); } naso = 1; return; } dfs1(s,u); if(naso) return; } cur.popb(); } void dfs2(ll u,ll p,ll en){ cur.pb(u); if(u==en){ naso = 1; return; } for(ll s : g[u]){ if(s==p) continue; dfs2(s,u,en); if(naso) return; } cur.popb(); } variant<bool, vector<int>> find_journey(int N, int M, vector<int> U, vector<int> V) { n = N; m = M; for(ll &x : U) x++; for(ll &x : V) x++; if(n==2){ vector<vector<ll> > cnt(3); for(ll i = 0;i<m;i++){ ll x = U[i],y = V[i]; cnt[x].pb(i); } bool ok = cnt[1].size()>=2&&cnt[2].size()>=1; if(!ok) return ok; ll x = cnt[1][0],y = cnt[1][1]; ll z = cnt[2][0]; vector<ll> ans; ans.pb(x); ans.pb(z); ans.pb(y); ans.pb(x); ans.pb(z); ans.pb(y); return ans; } for(ll i = 0;i<m;i++){ ll x = U[i],y = V[i]; g[x].pb(y); id[x][y] = i; sss.insert({x,y}); } if(n<=400&&sss.size()==n*(n-1)/2&&m==n*(n-1)/2){ ll x = id[1][2]; ll y = id[2][3]; ll z = id[3][1]; ll rx = id[2][1]; ll ry = id[3][2]; ll rz = id[1][3]; vector<ll> ans = gen({x,y,z,rx,ry,rz}); return ans; } dfs1(1,1); if(!naso) return naso; return 1; vector<ll> v; for(ll i = 0;i<cyc.size();i++) v.pb(id[v[i]][v[i+1]]); for(ll i = 0;i<cyc.size();i++) v.pb(id[v[i+1]][v[i]]); v = gen(v); cur.clear(); naso = 0; dfs2(1,1,cyc.back()); vector<ll> ans; }

Compilation message (stderr)

islands.cpp: In function 'std::vector<int> gen(std::vector<int>)':
islands.cpp:19:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   19 |     for(ll i = 0;i<=v.size()/2-1;i++) ans.pb(v[i]);
      |                  ~^~~~~~~~~~~~~~
islands.cpp:20:28: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   20 |     for(ll i = v.size()-1;i>=v.size()/2;i--) ans.pb(v[i]);
      |                           ~^~~~~~~~~~~~
islands.cpp:22:28: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |     for(ll i = v.size()/2;i<=v.size()-1;i++) ans.pb(v[i]);
      |                           ~^~~~~~~~~~~~
islands.cpp: In function 'std::variant<bool, std::vector<int, std::allocator<int> > > find_journey(int, int, std::vector<int>, std::vector<int>)':
islands.cpp:69:25: warning: unused variable 'y' [-Wunused-variable]
   69 |             ll x = U[i],y = V[i];
      |                         ^
islands.cpp:91:26: warning: comparison of integer expressions of different signedness: 'std::set<std::pair<int, int> >::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   91 |     if(n<=400&&sss.size()==n*(n-1)/2&&m==n*(n-1)/2){
      |                ~~~~~~~~~~^~~~~~~~~~~
islands.cpp:103:12: error: could not convert '1' from 'int' to 'std::variant<bool, std::vector<int, std::allocator<int> > >'
  103 |     return 1;
      |            ^
      |            |
      |            int
islands.cpp:105:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  105 |     for(ll i = 0;i<cyc.size();i++) v.pb(id[v[i]][v[i+1]]);
      |                  ~^~~~~~~~~~~
islands.cpp:106:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  106 |     for(ll i = 0;i<cyc.size();i++) v.pb(id[v[i+1]][v[i]]);
      |                  ~^~~~~~~~~~~