답안 #1112903

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1112903 2024-11-15T08:31:15 Z Aviansh Airplane (NOI23_airplane) C++17
0 / 100
1000 ms 46320 KB
#include <bits/stdc++.h>

using namespace std;

signed main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n,m;
    cin >> n >> m;
    int a[n];
    for(int &i : a){
        cin >> i;
    }
    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);
    }
    set<array<int,2>>vis;
    set<int>vis1;
    priority_queue<array<int,3>,vector<array<int,3>>,greater<array<int,3>>>pq;
    pq.push({0,0,0});
    long long ans = 0;
    while(!pq.empty()){
        array<int,3>cur = pq.top();
        //cout <<cur[0] << " " << cur[1] << " " << cur[2] << "\n";
        pq.pop();
        if(vis.find({cur[1],cur[2]})!=vis.end())
            continue;
        if(cur[1]==0&&cur[2]==n-1){
            ans=cur[0];
            break;
        }
        int cura = cur[1];
        vis.insert({cur[1],cur[2]});
        vis1.insert(cur[2]);
        if(cura>a[cur[2]]){
            if(vis.find({a[cur[2]],cur[2]})==vis.end())
                pq.push({cur[0]+cura-a[cur[2]],a[cur[2]],cur[2]});
        }
        for(int i : g[cur[2]]){
            if(vis1.find(i)!=vis1.end()){
                continue;
            }
            if(cura+1>=a[i]){
                if(vis.find({cura+1,i})==vis.end())
                    pq.push({cur[0]+1,cura+1,i});
            }
            else{
                if(vis.find({a[i],i})==vis.end())
                    pq.push({a[i]-cura+cur[0],a[i],i});
            }
            if(cura-1>=a[i]){
                if(vis.find({cura-1,i})==vis.end())
                    pq.push({cur[0]+1,cura-1,i});
            }
            if(cura>=a[i]){
                if(vis.find({cura,i})==vis.end())
                    pq.push({cur[0]+1,cura,i});
            }
        }
    }
    cout << ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Execution timed out 1048 ms 46320 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 189 ms 6904 KB Output is correct
7 Correct 42 ms 2128 KB Output is correct
8 Correct 123 ms 4392 KB Output is correct
9 Correct 6 ms 848 KB Output is correct
10 Correct 43 ms 2600 KB Output is correct
11 Correct 3 ms 592 KB Output is correct
12 Correct 45 ms 2440 KB Output is correct
13 Correct 12 ms 1108 KB Output is correct
14 Correct 16 ms 1360 KB Output is correct
15 Correct 15 ms 1236 KB Output is correct
16 Correct 9 ms 1104 KB Output is correct
17 Incorrect 25 ms 1676 KB Output isn't correct
18 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 189 ms 6904 KB Output is correct
7 Correct 42 ms 2128 KB Output is correct
8 Correct 123 ms 4392 KB Output is correct
9 Correct 6 ms 848 KB Output is correct
10 Correct 43 ms 2600 KB Output is correct
11 Correct 3 ms 592 KB Output is correct
12 Correct 45 ms 2440 KB Output is correct
13 Correct 12 ms 1108 KB Output is correct
14 Correct 16 ms 1360 KB Output is correct
15 Correct 15 ms 1236 KB Output is correct
16 Correct 9 ms 1104 KB Output is correct
17 Incorrect 25 ms 1676 KB Output isn't correct
18 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Execution timed out 1048 ms 46320 KB Time limit exceeded
3 Halted 0 ms 0 KB -