結果
| 問題 | 
                            No.1382 Travel in Mitaru city
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2021-02-07 21:58:22 | 
| 言語 | C++14  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 1,286 bytes | 
| コンパイル時間 | 1,648 ms | 
| コンパイル使用メモリ | 178,128 KB | 
| 実行使用メモリ | 796,680 KB | 
| 最終ジャッジ日時 | 2024-07-04 15:23:30 | 
| 合計ジャッジ時間 | 6,316 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge3 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 2 WA * 1 MLE * 1 -- * 64 | 
ソースコード
#include<bits/stdc++.h>
using namespace std;
const int MAX_N = 1e5+2;
int n,m,s,t;
int u0,v0;
vector<int> p;
vector<int> dist;
vector< vector<int> > adj;
void bfs()
{
    priority_queue< pair<int, pair<int,int> > > pq; /// y , x , v
    pq.push({0,{p[s],s}});
    while(!pq.empty())
    {
        pair<int, pair<int,int> > tmp = pq.top();
        pq.pop();
        if(dist[tmp.second.second] > tmp.first) continue;
        dist[tmp.second.second] = tmp.first;
        for(auto x : adj[tmp.second.second])
        {
            if(p[x] < tmp.second.first && dist[x] < dist[tmp.second.second]+1)
            {
                pq.push({tmp.first+1,{p[x],x}});
            }
            else if(p[x] >= tmp.second.first && dist[x] < dist[tmp.second.second])
            {
                pq.push({tmp.first,{tmp.second.first,x}});
            }
        }
    }
    cout<<dist[t]<<endl;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin>>n>>m>>s>>t;
    adj = vector< vector<int> >(n+1);
    dist = vector<int>(n+1,0);
    p = vector<int>(n+1,0);
    for(int i=1; i<=n; i++)
    {
        cin>>p[i];
    }
    for(int i=0; i<m; i++)
    {
        cin>>u0>>v0;
        adj[u0].push_back(v0);
        adj[v0].push_back(u0);
    }
    bfs();
}