Submission #928247

# Submission time Handle Problem Language Result Execution time Memory
928247 2024-02-16T06:04:05 Z Darren0724 Passport (JOI23_passport) C++17
16 / 100
1519 ms 1031244 KB
#include <bits/stdc++.h>
using namespace std;
#define LCBorz ios_base::sync_with_stdio(false); cin.tie(0);
#define all(x) x.begin(), x.end()
#define endl '\n'
const int N=305;
const int INF=1e9;
inline int id(int a,int b){
    return a*N+b;
}
int32_t main() {
    LCBorz;
    int n;cin>>n;
    vector<int> adj[N*N],dis(N*N,INF);
    vector<int> b(N),c(N);
    for(int i=1;i<=n;i++){
        cin>>b[i]>>c[i];
        for(int j=1;j<=i;j++){
            for(int k=i;k<=n;k++){
                adj[id(j,k)].push_back(id(min(b[i],j),max(c[i],k)));
                //cout<<id(j,k)<<' '<<id(min(b[i],j),max(c[i],k))<<endl;
            }
        }
    }
    int q1;cin>>q1;
    int p;cin>>p;
    queue<int> q;
    q.push(id(b[p],c[p]));
    dis[id(b[p],c[p])]=1;
    while(q.size()){
        int p=q.front();
        q.pop();
        for(int j:adj[p]){
            if(dis[j]==INF){
                dis[j]=dis[p]+1;
                q.push(j);
            }
        }
    }
    int ans=dis[id(1,n)];
    cout<<(ans==INF?-1:ans)<<endl;

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2904 KB Output is correct
2 Correct 2 ms 2908 KB Output is correct
3 Correct 2 ms 2892 KB Output is correct
4 Runtime error 9 ms 11680 KB Execution killed with signal 11
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2908 KB Output is correct
2 Correct 2 ms 2908 KB Output is correct
3 Correct 2 ms 2908 KB Output is correct
4 Correct 2 ms 2892 KB Output is correct
5 Correct 2 ms 2908 KB Output is correct
6 Correct 2 ms 2908 KB Output is correct
7 Correct 2 ms 2908 KB Output is correct
8 Correct 2 ms 2908 KB Output is correct
9 Correct 2 ms 2908 KB Output is correct
10 Correct 2 ms 2908 KB Output is correct
11 Correct 38 ms 25560 KB Output is correct
12 Correct 43 ms 27996 KB Output is correct
13 Correct 43 ms 29008 KB Output is correct
14 Correct 38 ms 25628 KB Output is correct
15 Correct 43 ms 29060 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2908 KB Output is correct
2 Correct 2 ms 2908 KB Output is correct
3 Correct 2 ms 2908 KB Output is correct
4 Correct 2 ms 2892 KB Output is correct
5 Correct 2 ms 2908 KB Output is correct
6 Correct 2 ms 2908 KB Output is correct
7 Correct 2 ms 2908 KB Output is correct
8 Correct 2 ms 2908 KB Output is correct
9 Correct 2 ms 2908 KB Output is correct
10 Correct 2 ms 2908 KB Output is correct
11 Correct 38 ms 25560 KB Output is correct
12 Correct 43 ms 27996 KB Output is correct
13 Correct 43 ms 29008 KB Output is correct
14 Correct 38 ms 25628 KB Output is correct
15 Correct 43 ms 29060 KB Output is correct
16 Runtime error 1519 ms 1031244 KB Execution killed with signal 11
17 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2908 KB Output is correct
2 Correct 2 ms 2908 KB Output is correct
3 Correct 2 ms 2908 KB Output is correct
4 Correct 2 ms 2892 KB Output is correct
5 Correct 2 ms 2908 KB Output is correct
6 Correct 2 ms 2908 KB Output is correct
7 Correct 2 ms 2908 KB Output is correct
8 Correct 2 ms 2908 KB Output is correct
9 Correct 2 ms 2908 KB Output is correct
10 Correct 2 ms 2908 KB Output is correct
11 Correct 38 ms 25560 KB Output is correct
12 Correct 43 ms 27996 KB Output is correct
13 Correct 43 ms 29008 KB Output is correct
14 Correct 38 ms 25628 KB Output is correct
15 Correct 43 ms 29060 KB Output is correct
16 Runtime error 1519 ms 1031244 KB Execution killed with signal 11
17 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2904 KB Output is correct
2 Correct 2 ms 2908 KB Output is correct
3 Correct 2 ms 2892 KB Output is correct
4 Runtime error 9 ms 11680 KB Execution killed with signal 11
5 Halted 0 ms 0 KB -