Submission #881861

#TimeUsernameProblemLanguageResultExecution timeMemory
881861djs100201Thousands Islands (IOI22_islands)C++17
Compilation error
0 ms0 KiB
#include "islands.h" #include <variant> #include<bits/stdc++.h> #define all(v) v.begin(),v.end() using namespace std; using ll = int; using P = pair<ll, ll>; using PP = pair<ll, P>; const ll n_ = 1e5 + 505, inf = (ll)2e9 * (ll)1e9 + 7, mod = 998244353; ll n, m, tc = 1, a, b, c, d, sum, x, y, z, base, ans, k; vector<P>rev[n_]; ll prob[n_],out[n_],checked[n_]; set<P>v[n_],edge[n_]; P To[n_]; variant<bool, std::vector<int>> find_journey(int N, int M, std::vector<int> U, std::vector<int> V) { n=N,m=M; for(int i=0;i<m;i++){ out[U[i]]++; v[U[i]].insert({V[i],i}); rev[V[i]].push_back({U[i],i}); } fill(prob,prob+n+1,1); //가능성이 존재한다. queue<ll>q; for(int i=0;i<n;i++){ if(v[i].size())continue; q.push(i); } while(q.size()){ a=q.front(); q.pop(); prob[a]=0; for(auto nxt:rev[a]){ v[nxt.first].erase({a,nxt.second}); if(v[nxt.first].size()==0)q.push(nxt.first); } } ll now=0; vector<int>ret,ret_rev; while(1){ if(!v[now].size())return false; if(v[now].size()==1){ ret.push_back((*v[now].begin()).second); ret_rev.push_back((*v[now].begin()).second); queue<ll>q; q.push(now); ll tmp=(*v[now].begin()).first; while(q.size()){ x=q.front(); q.pop(); for(auto nxt:v[x])rev[nxt.first].erase({x,nxt.second}); v[x].clear(); for(auto nxt:rev[x]){ v[nxt.first].erase({x,nxt.second}); if(v[nxt.first].size()==0)q.push(nxt.first); } } now = tmp; } else{ for(int i=0;i<n;i++){ if(i==now || !v[i].size())continue; auto cur=*v[i].begin(); edge[i].insert(cur); } auto it=v[now].end(); it--; edge[now].insert(*it); it--; edge[now].insert(*it); x=now; ll bef=-1,cnt=0; vector<int>inv(m); while(1){ P nxt; for(auto i:edge[x]){ if(i.second==bef)continue; nxt=i; bef=i.second; break; } if(inv[nxt.second])cnt--; else cnt++; inv[nxt.second]^=1; edge[nxt.first].insert({x,nxt.second}); edge[x].erase(nxt); ret.push_back(nxt.second); x=nxt.first; if(now==0 && cnt==0)break; } break; } } reverse(all(ret_rev)); for(auto i:ret_rev)ret.push_back(i); return ret; }

Compilation message (stderr)

islands.cpp:9:40: warning: integer overflow in expression of type 'll' {aka 'int'} results in '1321730048' [-Woverflow]
    9 | const ll n_ = 1e5 + 505, inf = (ll)2e9 * (ll)1e9 + 7, mod = 998244353;
      |                                ~~~~~~~~^~~~~~~~~
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:51:58: error: no matching function for call to 'std::vector<std::pair<int, int> >::erase(<brace-enclosed initializer list>)'
   51 |     for(auto nxt:v[x])rev[nxt.first].erase({x,nxt.second});
      |                                                          ^
In file included from /usr/include/c++/10/vector:67,
                 from islands.h:2,
                 from islands.cpp:1:
/usr/include/c++/10/bits/stl_vector.h:1430:7: note: candidate: 'std::vector<_Tp, _Alloc>::iterator std::vector<_Tp, _Alloc>::erase(std::vector<_Tp, _Alloc>::const_iterator) [with _Tp = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >; std::vector<_Tp, _Alloc>::iterator = std::vector<std::pair<int, int> >::iterator; std::vector<_Tp, _Alloc>::const_iterator = std::vector<std::pair<int, int> >::const_iterator]'
 1430 |       erase(const_iterator __position)
      |       ^~~~~
/usr/include/c++/10/bits/stl_vector.h:1430:28: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::vector<std::pair<int, int> >::const_iterator'
 1430 |       erase(const_iterator __position)
      |             ~~~~~~~~~~~~~~~^~~~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1457:7: note: candidate: 'std::vector<_Tp, _Alloc>::iterator std::vector<_Tp, _Alloc>::erase(std::vector<_Tp, _Alloc>::const_iterator, std::vector<_Tp, _Alloc>::const_iterator) [with _Tp = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >; std::vector<_Tp, _Alloc>::iterator = std::vector<std::pair<int, int> >::iterator; std::vector<_Tp, _Alloc>::const_iterator = std::vector<std::pair<int, int> >::const_iterator]'
 1457 |       erase(const_iterator __first, const_iterator __last)
      |       ^~~~~
/usr/include/c++/10/bits/stl_vector.h:1457:7: note:   candidate expects 2 arguments, 1 provided