# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
887374 | HossamHero7 | Passport (JOI23_passport) | C++14 | 2068 ms | 28744 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define endl '\n'
int dp[2501][2501];
int n;
vector<pair<int,int>> v;
int solve(int l,int r){
if(l == 0 && r == n-1) return 0;
int &ret = dp[l][r];
if(~ret) return ret;
ret = 1e9;
for(int i=l;i<=r;i++){
int L = min(l , v[i].first);
int R = max(r , v[i].second);
if(l == L && r == R) continue;
ret = min(ret , solve(L,R) + 1);
}
return ret;
}
void solve(){
cin>>n;
v.resize(n);
for(auto &[a,b] : v) cin>>a>>b , a -- , b--;
memset(dp,-1,sizeof(dp));
int q;
cin>>q;
while(q--){
int x;
cin>>x;
x --;
int ans = solve(x,x);
cout<<(ans >= 1e9 ? -1 : ans)<<endl;
}
}
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
int t=1;
//cin>>t;
while(t--){
solve();
}
return 0;
}
컴파일 시 표준 에러 (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... |