Submission #752923

#TimeUsernameProblemLanguageResultExecution timeMemory
752923bgnbvnbvPort Facility (JOI17_port_facility)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #define ll long long #define pll pair<ll, ll> #define pii pair<ll, pll> #define pb push_back #define fi first #define se second using namespace std; const int N = 2e6+5; const ll mod = 1e9 + 7; const int base = 40; ll n, m, k, t, a[N], b[N], tong, dp[N], lab[N], ans; char c; vector<ll> adj[N], kq; pll p[N]; ll pw(ll k, ll n) { ll total = 1; for(; n; n >>= 1) { if(n & 1)total = total * k % mod; k = k * k % mod; } return total; } ll findp(ll u) { return lab[u] < 0 ? u : lab[u] = findp(lab[u]); } void hop(ll u, ll v) { if(lab[u] > lab[v])swap(u, v); lab[u] += lab[v]; lab[v] = u; } void sol() { cin >> n; fill_n(lab, n*2+4, -1); for(int i = 1; i <= n; i ++) { cin >> p[i].fi >> p[i].se; } sort(p+1, p+1+n); set<pll> st; for(int i = 1; i <= n; i ++) { auto l = st.lower_bound({p[i].fi, 0ll}), r = st.upper_bound({p[i].se, n*2+1}); if(l != st.end() && r != st.begin() && (*l).fi < p[i].se) { r = prev(r); while(true) { pll x = *l; ll u = findp(i), v = findp(x.se+n); if(u != v)hop(u, v); u = findp(i+n), v = findp(x.se); if(u != v)hop(u, v); if(l==rbreak; ++l; } } st.insert({p[i].se, i}); } for(int i = 1; i <= n*2; i ++) { if(i <= n && findp(i) == findp(i+n)) { cout << 0; return; } if(lab[i] < 0)++ans; } cout << pw(2, ans/2); } int main() { cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0); int test = 1; //cin >> test; while (test-- > 0) sol(); return 0; }

Compilation message (stderr)

port_facility.cpp: In function 'void sol()':
port_facility.cpp:62:20: warning: init-statement in selection statements only available with '-std=c++17' or '-std=gnu++17'
   62 |                 if(l==rbreak;
      |                    ^
port_facility.cpp:62:23: error: 'rbreak' was not declared in this scope
   62 |                 if(l==rbreak;
      |                       ^~~~~~
port_facility.cpp:63:20: error: expected ')' before ';' token
   63 |                 ++l;
      |                    ^
      |                    )
port_facility.cpp:62:19: note: to match this '('
   62 |                 if(l==rbreak;
      |                   ^
port_facility.cpp:63:17: error: could not convert 'l.std::_Rb_tree_const_iterator<std::pair<long long int, long long int> >::operator++()' from 'std::_Rb_tree_const_iterator<std::pair<long long int, long long int> >::_Self' to 'bool'
   63 |                 ++l;
      |                 ^~~
      |                 |
      |                 std::_Rb_tree_const_iterator<std::pair<long long int, long long int> >::_Self