Submission #1112989

# Submission time Handle Problem Language Result Execution time Memory
1112989 2024-11-15T11:00:27 Z Aviansh Airplane (NOI23_airplane) C++17
10 / 100
597 ms 8528 KB
#include <bits/stdc++.h>

using namespace std;
int n,m;
signed main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> n >> m;
    assert(n<=2000);
    assert(m<=4000);
    int a[n];
    for(int &i : a){
        cin >> i;
        assert(i<=2000);
    }
    vector<int>g[n];
    for(int i = 0;i<m;i++){
        int a,b;
        cin >> a >> b;
        a--;b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    priority_queue<array<int,3>,vector<array<int,3>>,greater<array<int,3>>>pq;
    pq.push({0,0,0});
    bool vis[2005][2005];
    for(int i = 0;i<2005;i++){
        for(int j = 0;j<2005;j++){
            vis[i][j]=0;
        }
    }
    //height,place,downbool
    long long ans = 0;
    while(!pq.empty()){
        array<int,3>cur = pq.top();
        //cout << cur[0] << " " << cur[1] << " " << cur[2] << " " << cur[3] << "\n";
        pq.pop();
        if(cur[1]>2000){
            continue;
        }
        if(cur[1]==0&&cur[2]==n-1){
            ans=cur[0];
            break;
        }
        if(vis[cur[1]][cur[2]]){
            continue;
        }
        vis[cur[1]][cur[2]]=1;
        if(!vis[cur[1]+1][cur[2]])
            pq.push({cur[0]+1,cur[1]+1,cur[2]});
        if(cur[1]>a[cur[2]]&&!vis[cur[1]-1][cur[2]]){
            pq.push({cur[0]+1,cur[1]-1,cur[2]});
        }
        for(int i : g[cur[2]]){
            if(cur[1]-1>=a[i]&&!vis[cur[1]-1][i]){
                pq.push({cur[0]+1,cur[1]-1,i});
                //vis[cur[1]-1][i]=1;
            }
            if(cur[1]>=a[i]&&!vis[cur[1]][i]){
                pq.push({cur[0]+1,cur[1],i});
                //vis[cur[1]][i]=1;
            }
            if(cur[1]+1>=a[i]&&!vis[cur[1]+1][i]){
                pq.push({cur[0]+1,cur[1]+1,i});
                //vis[cur[1]+1][i]=1;
            }
        }
    }
    cout << ans;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 4 ms 4176 KB Output is correct
2 Runtime error 9 ms 8528 KB Execution killed with signal 6
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 4176 KB Output is correct
2 Correct 4 ms 4176 KB Output is correct
3 Correct 4 ms 4332 KB Output is correct
4 Correct 4 ms 4176 KB Output is correct
5 Correct 5 ms 4188 KB Output is correct
6 Correct 444 ms 4688 KB Output is correct
7 Correct 177 ms 4688 KB Output is correct
8 Correct 434 ms 4872 KB Output is correct
9 Correct 14 ms 4636 KB Output is correct
10 Correct 431 ms 4872 KB Output is correct
11 Correct 7 ms 4432 KB Output is correct
12 Correct 468 ms 4744 KB Output is correct
13 Correct 12 ms 4688 KB Output is correct
14 Correct 597 ms 4680 KB Output is correct
15 Correct 366 ms 4680 KB Output is correct
16 Correct 13 ms 4856 KB Output is correct
17 Correct 63 ms 4688 KB Output is correct
18 Correct 5 ms 4176 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 4176 KB Output is correct
2 Correct 4 ms 4176 KB Output is correct
3 Correct 4 ms 4332 KB Output is correct
4 Correct 4 ms 4176 KB Output is correct
5 Correct 5 ms 4188 KB Output is correct
6 Correct 444 ms 4688 KB Output is correct
7 Correct 177 ms 4688 KB Output is correct
8 Correct 434 ms 4872 KB Output is correct
9 Correct 14 ms 4636 KB Output is correct
10 Correct 431 ms 4872 KB Output is correct
11 Correct 7 ms 4432 KB Output is correct
12 Correct 468 ms 4744 KB Output is correct
13 Correct 12 ms 4688 KB Output is correct
14 Correct 597 ms 4680 KB Output is correct
15 Correct 366 ms 4680 KB Output is correct
16 Correct 13 ms 4856 KB Output is correct
17 Correct 63 ms 4688 KB Output is correct
18 Correct 5 ms 4176 KB Output is correct
19 Runtime error 10 ms 8528 KB Execution killed with signal 6
20 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 4176 KB Output is correct
2 Runtime error 9 ms 8528 KB Execution killed with signal 6
3 Halted 0 ms 0 KB -