Submission #714281

#TimeUsernameProblemLanguageResultExecution timeMemory
714281vjudge1Event Hopping (BOI22_events)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #define ll long long #define endl '\n' using namespace std; const int MAX = 3e5 + 5; vector<int> adj[100001]; int color[100001], dis[100001]; void bfs(int s){ queue<int> q; q.push(s); dis[s] = 0; color[s] = 1; while(!q.empty()){ int u = q.front(); q.pop(); for(auto v : adj[u]){ if(color[v]) continue; color[v] = 1; dis[v] = dis[u] + 1; q.push(v); } } } struct event{ int s, e, i; bool operator<(event other){ if(e == other.e){ return s < other.s; } return e < other.e; } }; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n, q; cin>>n>>q; vector<int> S(n + 1), E(n + 1); vector<event> arr; for (int i = 1; i <= n; i++) { cin>>S[i]>>E[i]; arr.push_back({S[i], E[i], i}); } sort(arr.begin(), arr.end()); for(int i = 0; i < n - 1; i++){ int first = arr[i].second; int second = arr[i + 1].second; if(S[second] <= E[first] && E[first] <= E[second]) adj[first].push_back(second); } while(q--){ memset(color, 0, sizeof(color)); memset(dis, -1, sizeof(dis)); int s, e; cin>>s>>e; bfs(s); if(dis[e] != -1) cout<<dis[e]<<endl; else cout<<"impossible\n"; } }

Compilation message (stderr)

events.cpp: In function 'int main()':
events.cpp:48:28: error: '__gnu_cxx::__alloc_traits<std::allocator<event>, event>::value_type' {aka 'struct event'} has no member named 'second'
   48 |         int first = arr[i].second;
      |                            ^~~~~~
events.cpp:49:33: error: '__gnu_cxx::__alloc_traits<std::allocator<event>, event>::value_type' {aka 'struct event'} has no member named 'second'
   49 |         int second = arr[i + 1].second;
      |                                 ^~~~~~