結果
| 問題 | No.3797 Express Elevators and Emergency Stairs |
| ユーザー |
|
| 提出日時 | 2026-11-13 23:23:16 |
| 言語 | C++23 (gcc 15.3.0 + boost 1.92.0 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 525 ms / 2,000 ms |
| + 110µs | |
| コード長 | 1,604 bytes |
| 記録 | |
| コンパイル時間 | 2,858 ms |
| コンパイル使用メモリ | 356,420 KB |
| 実行使用メモリ | 44,792 KB |
| 最終ジャッジ日時 | 2026-11-13 23:23:25 |
| 合計ジャッジ時間 | 6,731 ms |
|
ジャッジサーバーID (参考情報) |
judge4_0 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 26 |
ソースコード
#include <bits/stdc++.h>
#define ull unsigned ll
#define ll long long
#define ld long double
#define INFL (ll)3e18
#define INF (int)2e9
#define MOD (ll)998244353
#define MODO (ll)(1e9+7)
using namespace std;
template<typename T>istream&operator>>(istream&is,vector<T>&v);
template<typename... Ts>istream&operator>>(istream&is,tuple<Ts...>& t);
template<typename T1,typename T2>istream&operator>>(istream&is,pair<T1,T2>&p){is>>p.first>>p.second;return is;}
template<typename T>istream&operator>>(istream&is,vector<T>&v){for(T&in:v)is>>in;return is;}
template<typename... Ts>istream& operator>>(istream& is, tuple<Ts...>& t) {apply([&](auto&... args) {((is >> args), ...);},t);return is;}
int main(void){
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n;
cin >> n;
map<int,vector<int>> e;
vector<int> f;
int a,b;
for(int i = 0;i < n;i++){
cin >> a >> b;
e[a].push_back(b);
f.push_back(a);
}
sort(f.begin(),f.end());
set<int> r;
deque<int> d;
d.push_back(1);
r.insert(1);
while(!d.empty()){
int t = d.front();
d.pop_front();
auto lb = lower_bound(f.begin(),f.end(),t);
if(lb != f.begin()){
lb = prev(lb);
if(!r.count(*lb)){
r.insert(*lb);
d.push_back(*lb);
}
}
if(e.count(t)){
for(auto i:e[t]){
if(!r.count(i)){
r.insert(i);
d.push_back(i);
}
}
}
}
cout << *r.rbegin() << endl;
}