답안 #1084386

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1084386 2024-09-06T07:25:24 Z Bananabread Passport (JOI23_passport) C++17
16 / 100
2000 ms 98356 KB
#include<bits/stdc++.h>
#define ll long long
#define ntr "\n"
#define mod (ll)(1e9+7)
#define taskname ""
#define frep freopen(taskname".inp","r",stdin); freopen(taskname".out","w",stdout);
using namespace std;
ll l[3001];
ll r[3001];
ll n;
ll q;
int main(){
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    //frep;
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>l[i]>>r[i];
    }
    ll dp[n+1][n+1];
    ll vis[n+1][n+1];
    cin>>q;
    for(int i=1;i<=q;i++){
        ll x;
        cin>>x;
        memset(dp,0x3f,sizeof(dp));
        memset(vis,0,sizeof(vis));
        dp[l[x]][r[x]]=1;
        queue<pair<ll,ll>> q;
        q.push({l[x],r[x]});
        while(!q.empty()){
            ll lu=q.front().first,ru=q.front().second;
            q.pop();
            if(vis[lu][ru]) continue;
            for(int i=lu;i<=ru;i++){
                ll nl=min(lu,l[i]);
                ll nr=max(ru,r[i]);
                if(dp[nl][nr]>dp[lu][ru]+1){
                    dp[nl][nr]=dp[lu][ru]+1;
                    q.push({nl,nr});
                }
            }
        }
        cout<<(dp[1][n]<=1e18 ? dp[1][n] : -1)<<ntr;
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Runtime error 1 ms 604 KB Execution killed with signal 11
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 508 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 2 ms 1628 KB Output is correct
12 Correct 3 ms 1628 KB Output is correct
13 Correct 1 ms 1884 KB Output is correct
14 Correct 1 ms 1628 KB Output is correct
15 Correct 5 ms 1884 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 508 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 2 ms 1628 KB Output is correct
12 Correct 3 ms 1628 KB Output is correct
13 Correct 1 ms 1884 KB Output is correct
14 Correct 1 ms 1628 KB Output is correct
15 Correct 5 ms 1884 KB Output is correct
16 Correct 1051 ms 89428 KB Output is correct
17 Correct 875 ms 97104 KB Output is correct
18 Correct 65 ms 98356 KB Output is correct
19 Correct 72 ms 93008 KB Output is correct
20 Execution timed out 2050 ms 98188 KB Time limit exceeded
21 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 508 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 2 ms 1628 KB Output is correct
12 Correct 3 ms 1628 KB Output is correct
13 Correct 1 ms 1884 KB Output is correct
14 Correct 1 ms 1628 KB Output is correct
15 Correct 5 ms 1884 KB Output is correct
16 Correct 1051 ms 89428 KB Output is correct
17 Correct 875 ms 97104 KB Output is correct
18 Correct 65 ms 98356 KB Output is correct
19 Correct 72 ms 93008 KB Output is correct
20 Execution timed out 2050 ms 98188 KB Time limit exceeded
21 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Runtime error 1 ms 604 KB Execution killed with signal 11
5 Halted 0 ms 0 KB -