| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 888760 | vjudge1 | Passport (JOI23_passport) | C++17 | 2091 ms | 6616 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define int long long
#define ff first
#define ss second
#define pb push_back
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;
void fp(string name){freopen((name+".in").c_str(),"r",stdin); freopen((name+".out").c_str(),"w",stdout);}
int pow(int a,int b,int m){int ans=1;while(b){if(b&1){ans=(ans*a)%m;}b>>=1;a=(a*a)%m;}return ans;}
int binpow(int a,int b){int ans=1;while(b){if(b&1){ans=(ans*a);}b>>=1;a=(a*a);}return ans;}
const int N = 2e5 + 10;
int dist[N];
main(){
ios :: sync_with_stdio(0);
cin.tie(0);
// memset(dist, 0x3f3f, sizeof(dist));
int n;
cin >> n;
vector <pair <int,int> > vp(n + 1);
for(int i = 1; i <= n; i++){
cin >> vp[i].ff >> vp[i].ss;
}
//int ans = 0;
int just;
cin >> just;
while(just--){
for(int i = 1; i <= n; i++)dist[i] = 1e9;
int pos;
cin >> pos;
queue<int> q;
q.push(pos);
dist[pos] = 0;
while (!q.empty()) {
int v = q.front();
q.pop();
for (int i = vp[v].ff; i <= vp[v].ss; i++) {
int to = i;
if(dist[to] > dist[v] + 1){
dist[to] = dist[v] + 1;
q.push(to);
}
}
}
int ans = 0;
for(int i = 1; i <= n; i++){
//cout << dist[i] <<" ";
ans = max(dist[i], ans);
}
if(ans == 1e9)
cout << "-1\n";
else
cout <<ans << endl;
}
}
컴파일 시 표준 에러 (stderr) 메시지
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
