제출 #1120164

#제출 시각아이디문제언어결과실행 시간메모리
1120164vjudge1Event Hopping (BOI22_events)C++14
0 / 100
1595 ms8108 KiB
#include <bits/stdc++.h> using namespace std; #define f first #define s second typedef int ll; vector<ll> g[200100]; ll d[200100]; bool ok(pair<ll, pair<ll, ll>> a, pair<ll, pair<ll, ll>> b) { return (b.s.f <= a.f); } void solve() { ll n; cin>>n; ll Q; cin>>Q; vector<pair<ll, pair<ll, ll>>> v; for(ll i=1; i<=n; i++) { ll l,r; cin>>l>>r; v.push_back({r, {l, i}}); } sort(v.begin(), v.end()); for(ll i=0; i<v.size(); i++) { for(ll j=i+1; j<v.size(); j++) { if(ok(v[i], v[j])) { g[v[i].s.s].push_back(v[j].s.s); } } } while(Q--) { ll x,y; cin>>x>>y; queue<ll> q; for(ll i=1; i<=n; i++) d[i]=1e9; d[x]=0; q.push(x); while(!q.empty()) { ll v=q.front(); q.pop(); for(auto to: g[v]) { if(d[to] > d[v]+1) { d[to]=d[v]+1; q.push(to); } } } if(d[y] == 1e9) cout<<"impossible\n"; else cout<<d[y]<<'\n'; } } signed main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int t=1; // cin>>t; while(t--) { solve(); cout<<'\n'; } }

컴파일 시 표준 에러 (stderr) 메시지

events.cpp: In function 'void solve()':
events.cpp:20:18: warning: comparison of integer expressions of different signedness: 'll' {aka 'int'} and 'std::vector<std::pair<int, std::pair<int, int> > >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   20 |     for(ll i=0; i<v.size(); i++) {
      |                 ~^~~~~~~~~
events.cpp:21:24: warning: comparison of integer expressions of different signedness: 'll' {aka 'int'} and 'std::vector<std::pair<int, std::pair<int, int> > >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   21 |         for(ll j=i+1; j<v.size(); j++) {
      |                       ~^~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...