Submission #1084384

# Submission time Handle Problem Language Result Execution time Memory
1084384 2024-09-06T07:20:44 Z Bananabread Passport (JOI23_passport) C++17
16 / 100
2000 ms 49236 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];
    cin>>q;
    for(int i=1;i<=q;i++){
        ll x;
        cin>>x;
        memset(dp,0x3f,sizeof(dp));
        dp[l[x]][r[x]]=1;
        for(ll i=n;i>0;i--){
            for(ll j=i;j<=n;j++){
                if(dp[i][j]>=1e18) continue;
                for(int u=i;u<=j;u++){
                    ll nl=min(i,l[u]);
                    ll nr=max(j,r[u]);
                    dp[nl][nr]=min(dp[nl][nr],dp[i][j]+1);
                }
            }
        }
        cout<<(dp[1][n]<=1e18 ? dp[1][n] : -1)<<ntr;
    }
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 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 -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 460 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 2 ms 860 KB Output is correct
12 Correct 4 ms 1116 KB Output is correct
13 Correct 1 ms 1116 KB Output is correct
14 Correct 1 ms 860 KB Output is correct
15 Correct 4 ms 1116 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 460 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 2 ms 860 KB Output is correct
12 Correct 4 ms 1116 KB Output is correct
13 Correct 1 ms 1116 KB Output is correct
14 Correct 1 ms 860 KB Output is correct
15 Correct 4 ms 1116 KB Output is correct
16 Correct 1666 ms 43092 KB Output is correct
17 Correct 1280 ms 48916 KB Output is correct
18 Correct 48 ms 49232 KB Output is correct
19 Correct 60 ms 46828 KB Output is correct
20 Execution timed out 2080 ms 49236 KB Time limit exceeded
21 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 460 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 2 ms 860 KB Output is correct
12 Correct 4 ms 1116 KB Output is correct
13 Correct 1 ms 1116 KB Output is correct
14 Correct 1 ms 860 KB Output is correct
15 Correct 4 ms 1116 KB Output is correct
16 Correct 1666 ms 43092 KB Output is correct
17 Correct 1280 ms 48916 KB Output is correct
18 Correct 48 ms 49232 KB Output is correct
19 Correct 60 ms 46828 KB Output is correct
20 Execution timed out 2080 ms 49236 KB Time limit exceeded
21 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 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 -