답안 #1056819

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1056819 2024-08-13T11:34:50 Z PikachudoraEHE 악어의 지하 도시 (IOI11_crocodile) C++14
100 / 100
231 ms 64976 KB
#include "crocodile.h"
#include<bits/stdc++.h>
#define pii pair<int,int>
#define fi first
#define se second
using namespace std;
const int N = 1e5+5;
vector<pii>adj[N];pii dp[N];int vis[N];
priority_queue<pii,vector<pii>,greater<pii>>pq;
int travel_plan(int n, int m, int R[][2], int L[], int K, int P[]){
    for(int i=0;i<m;i++){
       int u = R[i][0];int v=R[i][1];int w = L[i];
       /*pii a;
       auto &[x,y]=a;
       cin >> x >> y;*/
       adj[u].push_back({v,w});
       adj[v].push_back({u,w});
    }
    for(int i=0;i<n;i++){
        dp[i]={INT_MAX,INT_MAX};
    }
    for(int i=0;i<K;i++){
        dp[P[i]]={0,0};
        pq.push({0,P[i]});
    }
    while(!pq.empty()){
        auto[ww,u]=pq.top();
        pq.pop();
        if(vis[u])continue;
        vis[u]=1;
        for(auto[v,w]:adj[u]){
            if(ww+w<dp[v].se){
                dp[v].se=ww+w;
                if(ww+w<dp[v].fi)swap(dp[v].fi,dp[v].se);
                if(dp[v].se<INT_MAX)pq.push({dp[v].se,v});
            }
        }
    }
  return dp[0].se;
}

Compilation message

crocodile.cpp: In function 'int travel_plan(int, int, int (*)[2], int*, int, int*)':
crocodile.cpp:27:13: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   27 |         auto[ww,u]=pq.top();
      |             ^
crocodile.cpp:31:17: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   31 |         for(auto[v,w]:adj[u]){
      |                 ^
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 6492 KB Output is correct
2 Correct 1 ms 6492 KB Output is correct
3 Correct 1 ms 6492 KB Output is correct
4 Correct 1 ms 6492 KB Output is correct
5 Correct 2 ms 6492 KB Output is correct
6 Correct 1 ms 6492 KB Output is correct
7 Correct 1 ms 6492 KB Output is correct
8 Correct 1 ms 6492 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 6492 KB Output is correct
2 Correct 1 ms 6492 KB Output is correct
3 Correct 1 ms 6492 KB Output is correct
4 Correct 1 ms 6492 KB Output is correct
5 Correct 2 ms 6492 KB Output is correct
6 Correct 1 ms 6492 KB Output is correct
7 Correct 1 ms 6492 KB Output is correct
8 Correct 1 ms 6492 KB Output is correct
9 Correct 1 ms 6748 KB Output is correct
10 Correct 1 ms 6492 KB Output is correct
11 Correct 1 ms 6492 KB Output is correct
12 Correct 2 ms 6748 KB Output is correct
13 Correct 3 ms 7004 KB Output is correct
14 Correct 1 ms 6492 KB Output is correct
15 Correct 1 ms 6492 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 6492 KB Output is correct
2 Correct 1 ms 6492 KB Output is correct
3 Correct 1 ms 6492 KB Output is correct
4 Correct 1 ms 6492 KB Output is correct
5 Correct 2 ms 6492 KB Output is correct
6 Correct 1 ms 6492 KB Output is correct
7 Correct 1 ms 6492 KB Output is correct
8 Correct 1 ms 6492 KB Output is correct
9 Correct 1 ms 6748 KB Output is correct
10 Correct 1 ms 6492 KB Output is correct
11 Correct 1 ms 6492 KB Output is correct
12 Correct 2 ms 6748 KB Output is correct
13 Correct 3 ms 7004 KB Output is correct
14 Correct 1 ms 6492 KB Output is correct
15 Correct 1 ms 6492 KB Output is correct
16 Correct 188 ms 61388 KB Output is correct
17 Correct 34 ms 18772 KB Output is correct
18 Correct 43 ms 20052 KB Output is correct
19 Correct 231 ms 64976 KB Output is correct
20 Correct 131 ms 53940 KB Output is correct
21 Correct 17 ms 12380 KB Output is correct
22 Correct 157 ms 51496 KB Output is correct