Submission #978550

# Submission time Handle Problem Language Result Execution time Memory
978550 2024-05-09T10:23:59 Z vjudge1 Passport (JOI23_passport) C++17
Compilation error
0 ms 0 KB
#include<bits/stdc++.h>
#define sz size()
#define ll long long
using namespace std;
const ll N = 200200;
const ll INF = 1e18;

void solve()
{
    ll n, Q, i, j, k;
    cin >> n;

    ll l[n + 1], r[n + 1];
    for(i = 1; i <= n; ++i)
        cin >> l[i] >> r[i];

    cin >> Q;
    while(Q--)
    {
        ll start;
        cin >> start;
        ll cl = start, cr = start;

        vector<ll> d(n + 1, INF);
        d[start] = 0;
        multiset<pair<ll, ll>> q;
        q.insert({0, start});
        while(q.sz)
        {
            auto [x, s] = *q.begin();
            q.erase(q.find({x, s}));

            for(ll t = l[s]; t <= min(cl, s); ++t)
            {
                if(d[t] < x + 1) continue;
                q.erase(s.find({d[t], t}});
                d[t] = x + 1;
                q.insert(s.find({d[t], t}});
            }
            cl = min(cl, l[s]);
            for(ll t = max(s, cr); t <= r[s]; ++t)
            {
                if(d[t] < x + 1) continue;
                q.erase(s.find({d[t], t}});
                d[t] = x + 1;
                q.insert(s.find({d[t], t}});
            }
            cr = max(cr, r[s]);
        }
        ll ans = max(d[1], d[n]);
        cout << (ans < INF ? ans : -1) << '\n';
    }
}

signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    solve();
}

Compilation message

passport.cpp: In function 'void solve()':
passport.cpp:36:27: error: request for member 'find' in 's', which is of non-class type 'std::tuple_element<1, std::pair<long long int, long long int> >::type' {aka 'long long int'}
   36 |                 q.erase(s.find({d[t], t}});
      |                           ^~~~
passport.cpp:36:41: error: expected ')' before '}' token
   36 |                 q.erase(s.find({d[t], t}});
      |                               ~         ^
      |                                         )
passport.cpp:36:42: error: expected primary-expression before ')' token
   36 |                 q.erase(s.find({d[t], t}});
      |                                          ^
passport.cpp:37:19: error: 't' was not declared in this scope
   37 |                 d[t] = x + 1;
      |                   ^
passport.cpp:38:28: error: request for member 'find' in 's', which is of non-class type 'std::tuple_element<1, std::pair<long long int, long long int> >::type' {aka 'long long int'}
   38 |                 q.insert(s.find({d[t], t}});
      |                            ^~~~
passport.cpp:38:42: error: expected ')' before '}' token
   38 |                 q.insert(s.find({d[t], t}});
      |                                ~         ^
      |                                          )
passport.cpp:38:43: error: expected primary-expression before ')' token
   38 |                 q.insert(s.find({d[t], t}});
      |                                           ^
passport.cpp:22:24: warning: unused variable 'cr' [-Wunused-variable]
   22 |         ll cl = start, cr = start;
      |                        ^~
passport.cpp:40:13: error: 'cl' was not declared in this scope; did you mean 'l'?
   40 |             cl = min(cl, l[s]);
      |             ^~
      |             l
passport.cpp:40:28: error: 's' was not declared in this scope
   40 |             cl = min(cl, l[s]);
      |                            ^
passport.cpp:41:31: error: 'cr' was not declared in this scope; did you mean 'r'?
   41 |             for(ll t = max(s, cr); t <= r[s]; ++t)
      |                               ^~
      |                               r
passport.cpp:43:20: error: 'd' was not declared in this scope
   43 |                 if(d[t] < x + 1) continue;
      |                    ^
passport.cpp:43:27: error: 'x' was not declared in this scope
   43 |                 if(d[t] < x + 1) continue;
      |                           ^
passport.cpp:44:17: error: 'q' was not declared in this scope
   44 |                 q.erase(s.find({d[t], t}});
      |                 ^
passport.cpp:44:33: error: 'd' was not declared in this scope
   44 |                 q.erase(s.find({d[t], t}});
      |                                 ^
passport.cpp:44:41: error: expected ')' before '}' token
   44 |                 q.erase(s.find({d[t], t}});
      |                               ~         ^
      |                                         )
passport.cpp:44:42: error: expected primary-expression before ')' token
   44 |                 q.erase(s.find({d[t], t}});
      |                                          ^
passport.cpp:45:17: error: 'd' was not declared in this scope
   45 |                 d[t] = x + 1;
      |                 ^
passport.cpp:45:19: error: 't' was not declared in this scope
   45 |                 d[t] = x + 1;
      |                   ^
passport.cpp:45:24: error: 'x' was not declared in this scope
   45 |                 d[t] = x + 1;
      |                        ^
passport.cpp:46:17: error: 'q' was not declared in this scope
   46 |                 q.insert(s.find({d[t], t}});
      |                 ^
passport.cpp:46:42: error: expected ')' before '}' token
   46 |                 q.insert(s.find({d[t], t}});
      |                                ~         ^
      |                                          )
passport.cpp:10:17: warning: unused variable 'j' [-Wunused-variable]
   10 |     ll n, Q, i, j, k;
      |                 ^
passport.cpp:10:20: warning: unused variable 'k' [-Wunused-variable]
   10 |     ll n, Q, i, j, k;
      |                    ^
passport.cpp: At global scope:
passport.cpp:46:43: error: expected unqualified-id before ')' token
   46 |                 q.insert(s.find({d[t], t}});
      |                                           ^
passport.cpp:47:13: error: expected declaration before '}' token
   47 |             }
      |             ^
passport.cpp:48:13: error: 'cr' does not name a type
   48 |             cr = max(cr, r[s]);
      |             ^~
passport.cpp:49:9: error: expected declaration before '}' token
   49 |         }
      |         ^
passport.cpp:50:22: error: 'd' was not declared in this scope
   50 |         ll ans = max(d[1], d[n]);
      |                      ^
passport.cpp:50:28: error: 'd' was not declared in this scope
   50 |         ll ans = max(d[1], d[n]);
      |                            ^
passport.cpp:50:30: error: 'n' was not declared in this scope
   50 |         ll ans = max(d[1], d[n]);
      |                              ^
passport.cpp:51:9: error: 'cout' does not name a type
   51 |         cout << (ans < INF ? ans : -1) << '\n';
      |         ^~~~
passport.cpp:52:5: error: expected declaration before '}' token
   52 |     }
      |     ^
passport.cpp:53:1: error: expected declaration before '}' token
   53 | }
      | ^