답안 #136560

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
136560 2019-07-25T14:03:38 Z miguel 악어의 지하 도시 (IOI11_crocodile) C++14
100 / 100
815 ms 72640 KB
#include<bits/stdc++.h>
#include<crocodile.h>
using namespace std;
#define pb push_back
#define dbg(x) cout << #x << '=' << x << '\n';
#define ll long long
#define x first
#define y second
#define pi pair <int, int>
#define pii pair <int, pi>
#define vi vector <int>
const ll mod = 998244353;
vector <pi> g[100001];
int t[100001], viz[100001];
priority_queue<pi, vector<pi>, greater<pi>> pq;

int travel_plan(int n, int m, int r[][2], int l[], int k, int p[]){
    for(int i=0; i<n; i++) t[i]=1000000001;
    for(int i=0; i<k; i++) t[p[i]]=0;
    for(int i=0; i<m; i++){
        g[r[i][0]].pb({r[i][1], l[i]});
        g[r[i][1]].pb({r[i][0], l[i]});
    }
    fill(viz, viz+n, 0);
    for(int i=0; i<k; i++) pq.push({0, p[i]}), viz[p[i]]=1;
    while(!pq.empty()){
        int nod=pq.top().y, cost=pq.top().x;
        //cout<<nod<<" "<<cost<<" "<<viz[nod]<<"\n";
        pq.pop();
        if(viz[nod]==0) viz[nod]++;
        else if(viz[nod]==1){
            viz[nod]++;
            if(nod==0) return cost;
            for(pi i: g[nod]) pq.push({cost+i.y, i.x});
        }
    }
}

Compilation message

crocodile.cpp: In function 'int travel_plan(int, int, int (*)[2], int*, int, int*)':
crocodile.cpp:37:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 2680 KB Output is correct
2 Correct 4 ms 2680 KB Output is correct
3 Correct 5 ms 2760 KB Output is correct
4 Correct 6 ms 2808 KB Output is correct
5 Correct 6 ms 2780 KB Output is correct
6 Correct 5 ms 2808 KB Output is correct
7 Correct 6 ms 2808 KB Output is correct
8 Correct 6 ms 2808 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 2680 KB Output is correct
2 Correct 4 ms 2680 KB Output is correct
3 Correct 5 ms 2760 KB Output is correct
4 Correct 6 ms 2808 KB Output is correct
5 Correct 6 ms 2780 KB Output is correct
6 Correct 5 ms 2808 KB Output is correct
7 Correct 6 ms 2808 KB Output is correct
8 Correct 6 ms 2808 KB Output is correct
9 Correct 8 ms 3064 KB Output is correct
10 Correct 5 ms 2680 KB Output is correct
11 Correct 6 ms 2936 KB Output is correct
12 Correct 10 ms 3576 KB Output is correct
13 Correct 8 ms 3192 KB Output is correct
14 Correct 4 ms 2680 KB Output is correct
15 Correct 5 ms 2808 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 2680 KB Output is correct
2 Correct 4 ms 2680 KB Output is correct
3 Correct 5 ms 2760 KB Output is correct
4 Correct 6 ms 2808 KB Output is correct
5 Correct 6 ms 2780 KB Output is correct
6 Correct 5 ms 2808 KB Output is correct
7 Correct 6 ms 2808 KB Output is correct
8 Correct 6 ms 2808 KB Output is correct
9 Correct 8 ms 3064 KB Output is correct
10 Correct 5 ms 2680 KB Output is correct
11 Correct 6 ms 2936 KB Output is correct
12 Correct 10 ms 3576 KB Output is correct
13 Correct 8 ms 3192 KB Output is correct
14 Correct 4 ms 2680 KB Output is correct
15 Correct 5 ms 2808 KB Output is correct
16 Correct 815 ms 72640 KB Output is correct
17 Correct 177 ms 13784 KB Output is correct
18 Correct 141 ms 15324 KB Output is correct
19 Correct 724 ms 67404 KB Output is correct
20 Correct 367 ms 49604 KB Output is correct
21 Correct 61 ms 7672 KB Output is correct
22 Correct 680 ms 46812 KB Output is correct