Submission #714266

#TimeUsernameProblemLanguageResultExecution timeMemory
714266vjudge1Event 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); } } } 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<pair<int, int>> arr; for (int i = 1; i <= n; i++) { cin>>S[i]>>E[i]; arr.push_back({E[i], i}) } sort(arr.begin(), arr.end()); for(int i = 0; i < n - 1; i++){ int event = arr[i].second; int next_event = arr[i + 1].second; if(S[next_event] <= E[event] && E[event] <= E[next_event]) adj[event].push_back(next_event); } 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:35:33: error: expected ';' before '}' token
   35 |         arr.push_back({E[i], i})
      |                                 ^
      |                                 ;
   36 |     }
      |     ~